@@ -44,6 +44,20 @@ describe("Field.subscribing", () => {
|
44 | 44 | expect(form.getRegisteredFields()).toEqual(["foo", "bar", "baz"]); |
45 | 45 | }); |
46 | 46 | |
| 47 | +it("should allow register and unregister", () => { |
| 48 | +const form = createForm({ onSubmit: onSubmitMock }); |
| 49 | +const config = { |
| 50 | +getValidator: () => () => Promise.resolve("err"), |
| 51 | +silent: true, |
| 52 | +}; |
| 53 | +// register |
| 54 | +const unsuscribe = form.registerField("foo", () => {}, {}, config); |
| 55 | +// unsuscribe |
| 56 | +unsuscribe(); |
| 57 | + |
| 58 | +expect(form.getRegisteredFields()).toEqual([]); |
| 59 | +}); |
| 60 | + |
47 | 61 | it("should provide a access to field state", () => { |
48 | 62 | const form = createForm({ onSubmit: onSubmitMock }); |
49 | 63 | form.registerField("foo", () => {}, {}); |
|