Skip to content

Commit

Permalink
Merge pull request #488 from blackflux/dev
Browse files Browse the repository at this point in the history
[Gally]: master <- dev
  • Loading branch information
simlu committed Aug 5, 2019
2 parents c657e0f + 14d660d commit dd02c4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/plugin/strategies.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = {
});
return changeset.concat(existing);
},
'append-new': (existing, changeset) => existing.concat(changeset.filter(e => !existing.includes(e))),
'merge-shallow': (existing, changeset) => Object.assign(existing, changeset),
'merge-deep': (existing, changeset) => deepmerge(existing, changeset, { arrayMerge }),
'default-shallow': (existing, changeset) => Object.assign(changeset, existing),
Expand Down
8 changes: 8 additions & 0 deletions test/plugin/strategies.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ describe('Integration strategies.js', () => {
.to.deep.equal(['new', 'title1', 'title2', '', 'text']);
});

it('Testing Merge Strategy: append-new', () => {
const existing = ['title1', 'title2', '', 'new', 'text'];
expect(strategies['append-new'](existing, ['new']))
.to.deep.equal(['title1', 'title2', '', 'new', 'text']);
expect(strategies['append-new'](existing, ['new2']))
.to.deep.equal(['title1', 'title2', '', 'new', 'text', 'new2']);
});

describe('Testing Deep Merge', () => {
it('Testing Array Concat', () => {
const existing = { a: { b: ['c'] } };
Expand Down

0 comments on commit dd02c4b

Please sign in to comment.