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

Commit dfa13cd

Browse files
committed
add test to reproduce issue #528
1 parent 502ad8d commit dfa13cd

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test/model-actions-spec.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { assert } from 'chai';
22
import { combineReducers } from 'redux';
33
import Immutable from 'immutable';
4-
import { actions, modelReducer, formReducer, track } from '../src';
4+
import { actions, modelReducer, formReducer, track, combineForms } from '../src';
55
import {
66
actions as immutableActions,
77
modelReducer as immutableModelReducer,
@@ -22,6 +22,27 @@ describe('model actions', () => {
2222
assert.deepEqual(actual, { bar: 'string' });
2323
});
2424

25+
it('should load array values and form values', () => {
26+
const reducer = combineForms({
27+
user: {
28+
username: '',
29+
items: [{name: 'item 1'}]
30+
},
31+
})
32+
const DATA = {
33+
username: 'loaded',
34+
items: [{name: 'item 1'}, {name: 'item 2'}],
35+
};
36+
const initial = reducer(undefined, {});
37+
const actual = reducer({}, actions.load('user', DATA));
38+
39+
assert.equal(actual.forms.user.items.$form.model, "user.items");
40+
assert.equal(actual.forms.user.items[0].$form.model, "user.items.0");
41+
assert.equal(actual.forms.user.items[0].name.model, "user.items.0.name");
42+
assert.equal(actual.forms.user.items[1].$form.model, "user.items.1");
43+
assert.equal(actual.forms.user.items[1].name.model, "user.items.1.name");
44+
});
45+
2546
it('should load model and form stay untouched', () => {
2647
const reducer = combineReducers({
2748
foo: modelReducer('foo'),

0 commit comments

Comments
 (0)