New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Date Value Validators): Propagate valueRequiredValidator to child component (DSP-1188) #251
Changes from 1 commit
efdd557
c05e0fd
d113e0b
2f243dd
0c39de5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ class TestDateInputComponent implements ControlValueAccessor, MatFormFieldContro | |
@Input() required: boolean; | ||
@Input() shouldLabelFloat: boolean; | ||
@Input() errorStateMatcher: ErrorStateMatcher; | ||
@Input() valueRequiredValidator = true; | ||
|
||
errorState = false; | ||
focused = false; | ||
|
@@ -116,6 +117,26 @@ class TestHostCreateValueComponent implements OnInit { | |
} | ||
} | ||
|
||
/** | ||
* Test host component to simulate parent component. | ||
*/ | ||
@Component({ | ||
template: ` | ||
<dsp-date-value #inputVal [mode]="mode" [valueRequiredValidator]="false"></dsp-date-value>` | ||
}) | ||
class TestHostCreateValueNoValueRequiredComponent implements OnInit { | ||
|
||
@ViewChild('inputVal') inputValueComponent: DateValueComponent; | ||
|
||
mode: 'read' | 'update' | 'create' | 'search'; | ||
|
||
ngOnInit() { | ||
|
||
this.mode = 'create'; | ||
|
||
} | ||
} | ||
|
||
describe('DateValueComponent', () => { | ||
|
||
beforeEach(async(() => { | ||
|
@@ -130,6 +151,7 @@ describe('DateValueComponent', () => { | |
TestDateInputComponent, | ||
TestHostDisplayValueComponent, | ||
TestHostCreateValueComponent, | ||
TestHostCreateValueNoValueRequiredComponent, | ||
KnoraDatePipe | ||
] | ||
}) | ||
|
@@ -611,5 +633,24 @@ describe('DateValueComponent', () => { | |
|
||
}); | ||
|
||
describe('create a date value no required value', () => { | ||
|
||
let testHostComponent: TestHostCreateValueNoValueRequiredComponent; | ||
let testHostFixture: ComponentFixture<TestHostCreateValueNoValueRequiredComponent>; | ||
|
||
beforeEach(() => { | ||
testHostFixture = TestBed.createComponent(TestHostCreateValueNoValueRequiredComponent); | ||
testHostComponent = testHostFixture.componentInstance; | ||
testHostFixture.detectChanges(); | ||
|
||
expect(testHostComponent).toBeTruthy(); | ||
expect(testHostComponent.inputValueComponent).toBeTruthy(); | ||
}); | ||
|
||
it('should not create an empty value', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe also check that the form is valid. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in c05e0fd |
||
expect(testHostComponent.inputValueComponent.getNewValue()).toEqual(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also a test to check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in c05e0fd |
||
}); | ||
|
||
}); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a test to
projects/dsp-ui/src/lib/viewer/values/date-value/date-input/date-input.component.spec.ts
? Maybe just check for the form to be valid.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in c05e0fd