users.spec.js 1013 B

12345678910111213141516171819202122232425262728293031323334
  1. import { cloneDeep } from 'lodash'
  2. import { defaultState, mutations } from '../../../../src/modules/users.js'
  3. describe('The users module', () => {
  4. it('adds new users to the set, merging in new information for old users', () => {
  5. const state = cloneDeep(defaultState)
  6. const user = { id: 1, name: 'Guy' }
  7. const modUser = { id: 1, name: 'Dude' }
  8. mutations.addNewUsers(state, [user])
  9. expect(state.users).to.have.length(1)
  10. expect(state.users).to.eql([user])
  11. mutations.addNewUsers(state, [modUser])
  12. expect(state.users).to.have.length(1)
  13. expect(state.users).to.eql([user])
  14. expect(state.users[0].name).to.eql('Dude')
  15. })
  16. it('sets a mute bit on users', () => {
  17. const state = cloneDeep(defaultState)
  18. const user = { id: 1, name: 'Guy' }
  19. mutations.addNewUsers(state, [user])
  20. mutations.setMuted(state, {user, muted: true})
  21. expect(user.muted).to.eql(true)
  22. mutations.setMuted(state, {user, muted: false})
  23. expect(user.muted).to.eql(false)
  24. })
  25. })