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);
|
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", () => {
|
describe("match detection", () => {
|
||||||
it("should hide the match detection select by default", () => {
|
it("should hide the match detection select by default", () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
|
@ -149,12 +149,12 @@ export class UriOptionComponent implements ControlValueAccessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NG_VALUE_ACCESSOR implementation
|
// NG_VALUE_ACCESSOR implementation
|
||||||
writeValue(value: any): void {
|
writeValue(value: { uri: string; matchDetection: UriMatchStrategySetting | null }): void {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.uriForm.setValue(
|
this.uriForm.setValue(
|
||||||
{
|
{
|
||||||
uri: value.uri ?? "",
|
uri: value.uri ?? "",
|
||||||
matchDetection: value.match ?? null,
|
matchDetection: value.matchDetection ?? null,
|
||||||
},
|
},
|
||||||
{ emitEvent: false },
|
{ emitEvent: false },
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue