Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 677df88

Browse files
authored
Merge pull request #502 from lasergoat/master
add unit test for #500
2 parents 9622205 + a01fb72 commit 677df88

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/field-actions-spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,29 @@ Object.keys(testContexts).forEach((testKey) => {
8787
retouched: true,
8888
}, 'field retouched after submit');
8989
});
90+
91+
it('should be able to set change an object to null without throwing an error', () => {
92+
// this is a weird one, but because $form is now
93+
// stuffed into the store in each model that is an object
94+
// the sub fields updater expects to find it.
95+
// so if it is studdenly changed to null,
96+
// the .$form breaks. in the code, we just added
97+
// a condition like subField && subField.$form.
98+
// this test will ensure that condition stays functioning
99+
const reducer = formReducer('foo', { a: {} });
100+
let didThrow = false;
101+
102+
try {
103+
reducer(
104+
undefined,
105+
actions.change('foo.a', null)
106+
);
107+
} catch (e) {
108+
didThrow = true;
109+
}
110+
111+
assert.isFalse(didThrow);
112+
});
90113
});
91114

92115
describe('reset()', () => {

0 commit comments

Comments
 (0)