Skip to content

Commit a384a31

Browse files
committed
test(forms): cover the deprecated disabled signatures
`hidden()` and `readonly()` have tests for their deprecated function syntax, but `disabled()` had none for passing a function or a string directly. Add a spec for each. Tested with `//packages/forms/signals/test/node:test`. Both specs fail if `disabled()` ignores a function or string passed directly.
1 parent c9bf9a7 commit a384a31

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎packages/forms/signals/test/node/field_node.spec.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,37 @@ describe('FieldNode', () => {
971971
},
972972
]);
973973
});
974+
975+
it('supports deprecated function syntax', () => {
976+
const f = form(
977+
signal({a: 1, b: 2}),
978+
(p) => {
979+
disabled(p.a, ({value}) => value() !== 2);
980+
},
981+
{injector: TestBed.inject(Injector)},
982+
);
983+
984+
expect(f.a().disabled()).toBe(true);
985+
f.a().value.set(2);
986+
expect(f.a().disabled()).toBe(false);
987+
});
988+
989+
it('supports deprecated string syntax', () => {
990+
const f = form(
991+
signal({a: 1, b: 2}),
992+
(p) => {
993+
disabled(p.a, 'a cannot be changed');
994+
},
995+
{injector: TestBed.inject(Injector)},
996+
);
997+
998+
expect(f.a().disabledReasons()).toEqual([
999+
{
1000+
fieldTree: f.a,
1001+
message: 'a cannot be changed',
1002+
},
1003+
]);
1004+
});
9741005
});
9751006

9761007
describe('readonly', () => {

0 commit comments

Comments
 (0)