|
1 | 1 | import { assert } from 'chai';
|
2 | 2 | import { combineReducers } from 'redux';
|
3 | 3 | 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'; |
5 | 6 | import {
|
6 | 7 | actions as immutableActions,
|
7 | 8 | modelReducer as immutableModelReducer,
|
8 | 9 | } from '../immutable';
|
| 10 | +import createTestStore from 'redux-test-store'; |
| 11 | + |
| 12 | +import { testCreateStore } from './utils'; |
9 | 13 |
|
10 | 14 | describe('model actions', () => {
|
11 | 15 | const testItems = [
|
@@ -112,6 +116,28 @@ describe('model actions', () => {
|
112 | 116 | assert.equal(actual.fooForm.$form.pristine, true);
|
113 | 117 | assert.equal(actual.fooForm.$form.touched, false);
|
114 | 118 | });
|
| 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 | + }); |
115 | 141 | });
|
116 | 142 |
|
117 | 143 | describe('change()', () => {
|
|
0 commit comments