MCPcopy
hub / github.com/final-form/final-form / prepareFormSubscriber

Function prepareFormSubscriber

src/FinalForm.subscribing.test.ts:8–28  ·  view source on GitHub ↗
(fieldName, subscription, config = {})

Source from the content-addressed store, hash-verified

6
7describe("FinalForm.subscribing", () => {
8 const prepareFormSubscriber = (fieldName, subscription, config = {}) => {
9 const form = createForm({ onSubmit: onSubmitMock, ...config });
10 const spy = jest.fn();
11 form.subscribe(spy, subscription);
12 expect(spy).toHaveBeenCalled();
13 expect(spy).toHaveBeenCalledTimes(1);
14
15 let blur;
16 let change;
17 let focus;
18 form.registerField(
19 fieldName,
20 (fieldState) => {
21 blur = fieldState.blur;
22 change = fieldState.change;
23 focus = fieldState.focus;
24 },
25 {},
26 );
27 return { blur, change, focus, spy };
28 };
29
30 it("should throw an error if no callback is given", () => {
31 const form = createForm({ onSubmit: onSubmitMock });

Callers 1

Calls 1

createFormFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…