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

Commit a18e163

Browse files
authored
Merge pull request #901 from nikitka/master
Immutable support in actions.xor
2 parents c65f6a6 + d6f3f2a commit a18e163

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/actions/model-actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function createModelActions(s = defaultStrategies) {
7474
const valueWithoutItem = value.filter((_item) => !iteratee(_item));
7575

7676
return (s.length(value) === s.length(valueWithoutItem))
77-
? [...value, item]
77+
? s.push(value, item)
7878
: valueWithoutItem;
7979
}, s.array, 3);
8080

test/actions-spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ describe('model action creators', () => {
6565

6666
fn(dispatch, getState);
6767
});
68+
69+
it('should change a collection by pushing an item to it via symmetric difference', done => {
70+
const fn = actions.xor('foo.bar', 4);
71+
const dispatch = action => {
72+
done(assert.deepEqual(
73+
action.value,
74+
[1, 2, 3, 4]));
75+
};
76+
const getState = () => ({
77+
foo: {
78+
bar: [1, 2, 3],
79+
},
80+
});
81+
82+
fn(dispatch, getState);
83+
});
6884
});
6985

7086
describe('actions.push() thunk', () => {

0 commit comments

Comments
 (0)