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

Commit 1c2fed9

Browse files
committed
Test for issue #722
1 parent e539702 commit 1c2fed9

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

test/model-actions-spec.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { assert } from 'chai';
22
import { combineReducers } from 'redux';
33
import Immutable from 'immutable';
4-
import { actions, modelReducer, formReducer, track, combineForms } from '../src';
4+
import thunk from 'redux-thunk';
5+
import { actions, modelReducer, formReducer, track, combineForms, createForms } from '../src';
56
import {
67
actions as immutableActions,
78
modelReducer as immutableModelReducer,
89
} from '../immutable';
10+
import createTestStore from 'redux-test-store';
11+
12+
import { testCreateStore } from './utils';
913

1014
describe('model actions', () => {
1115
const testItems = [
@@ -112,6 +116,28 @@ describe('model actions', () => {
112116
assert.equal(actual.fooForm.$form.pristine, true);
113117
assert.equal(actual.fooForm.$form.touched, false);
114118
});
119+
120+
it('after load model actions on non-set field should not fail', () => {
121+
const reducer = createForms({
122+
foo: {
123+
bar: '',
124+
},
125+
});
126+
127+
const store = createTestStore(testCreateStore({
128+
...reducer
129+
}, thunk));
130+
131+
store.dispatch(actions.load('foo', { bar: 'string' }));
132+
const actual = store.getState();
133+
assert.deepEqual(actual.foo, { bar: 'string' });
134+
assert.equal(actual.forms.$form.pristine, true);
135+
assert.equal(actual.forms.$form.touched, false);
136+
137+
138+
store.dispatch(actions.focus('foo.notExist', { silent: true }));
139+
store.dispatch(actions.blur('foo.notExist'));
140+
});
115141
});
116142

117143
describe('change()', () => {

0 commit comments

Comments
 (0)