fix value update for match detections (#11417)
This commit is contained in:
parent
935ae9d238
commit
e6ff647343
|
@ -96,6 +96,17 @@ describe("UriOptionComponent", () => {
|
|||
expect(component["uriForm"].enabled).toBe(false);
|
||||
});
|
||||
|
||||
it("should update form when `writeValue` is invoked", () => {
|
||||
expect(component["uriForm"].value).toEqual({ uri: null, matchDetection: null });
|
||||
|
||||
component.writeValue({ uri: "example.com", matchDetection: UriMatchStrategy.Exact });
|
||||
|
||||
expect(component["uriForm"].value).toEqual({
|
||||
uri: "example.com",
|
||||
matchDetection: UriMatchStrategy.Exact,
|
||||
});
|
||||
});
|
||||
|
||||
describe("match detection", () => {
|
||||
it("should hide the match detection select by default", () => {
|
||||
fixture.detectChanges();
|
||||
|
|
|
@ -149,12 +149,12 @@ export class UriOptionComponent implements ControlValueAccessor {
|
|||
}
|
||||
|
||||
// NG_VALUE_ACCESSOR implementation
|
||||
writeValue(value: any): void {
|
||||
writeValue(value: { uri: string; matchDetection: UriMatchStrategySetting | null }): void {
|
||||
if (value) {
|
||||
this.uriForm.setValue(
|
||||
{
|
||||
uri: value.uri ?? "",
|
||||
matchDetection: value.match ?? null,
|
||||
matchDetection: value.matchDetection ?? null,
|
||||
},
|
||||
{ emitEvent: false },
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue