diff options
| author | kPherox <admin@mail.kr-kp.com> | 2019-11-17 22:34:00 +0900 |
|---|---|---|
| committer | kPherox <admin@mail.kr-kp.com> | 2020-06-10 03:48:49 +0900 |
| commit | cc4691a4efec91318284869164419d286bda44a5 (patch) | |
| tree | a94f2af07960c69552d1385765e4ced02caf7fc4 /test/unit/specs/modules | |
| parent | de9cc033df32a4668ac8d05a770312c029d20c4c (diff) | |
Fix merging array field for users
Diffstat (limited to 'test/unit/specs/modules')
| -rw-r--r-- | test/unit/specs/modules/users.spec.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/unit/specs/modules/users.spec.js b/test/unit/specs/modules/users.spec.js index 670acfc8..dfa5684d 100644 --- a/test/unit/specs/modules/users.spec.js +++ b/test/unit/specs/modules/users.spec.js @@ -18,6 +18,42 @@ describe('The users module', () => { expect(state.users).to.eql([user]) expect(state.users[0].name).to.eql('Dude') }) + + it('merging array field in new information for old users', () => { + const state = cloneDeep(defaultState) + const user = { + id: '1', + fields: [ + { name: 'Label 1', value: 'Content 1' } + ] + } + const firstModUser = { + id: '1', + fields: [ + { name: 'Label 2', value: 'Content 2' }, + { name: 'Label 3', value: 'Content 3' } + ] + } + const secondModUser = { + id: '1', + fields: [ + { name: 'Label 4', value: 'Content 4' } + ] + } + + mutations.addNewUsers(state, [user]) + expect(state.users[0].fields).to.have.length(1) + expect(state.users[0].fields[0].name).to.eql('Label 1') + + mutations.addNewUsers(state, [firstModUser]) + expect(state.users[0].fields).to.have.length(2) + expect(state.users[0].fields[0].name).to.eql('Label 2') + expect(state.users[0].fields[1].name).to.eql('Label 3') + + mutations.addNewUsers(state, [secondModUser]) + expect(state.users[0].fields).to.have.length(1) + expect(state.users[0].fields[0].name).to.eql('Label 4') + }) }) describe('findUser', () => { |
