Merge branch 'main' of github.com:jarnaiz/final-form into jarnaiz-main · final-form/final-form@b152502

Original file line numberDiff line numberDiff line change

@@ -44,6 +44,20 @@ describe("Field.subscribing", () => {

4444

expect(form.getRegisteredFields()).toEqual(["foo", "bar", "baz"]);

4545

});

4646
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+
4761

it("should provide a access to field state", () => {

4862

const form = createForm({ onSubmit: onSubmitMock });

4963

form.registerField("foo", () => {}, {});