aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs/modules/users.spec.js
diff options
context:
space:
mode:
authorHJ <spam@hjkos.com>2018-12-31 01:57:22 +0000
committerHJ <spam@hjkos.com>2018-12-31 01:57:22 +0000
commit7aa42c01eb5f05c2e3ed71fc52be6a30e45802bf (patch)
tree2071ec16f17bc714817575ad7699707f92cb664b /test/unit/specs/modules/users.spec.js
parent1316ed43a5d203294cb7a41bb19d5fca98f5cea1 (diff)
parentfb8f774383f122d3254748f7f97ab6c562a5c339 (diff)
Merge branch 'fix/profile-with-no-statuses-not-loading' into 'develop'
Fix profiles without statuses not loading See merge request pleroma/pleroma-fe!445
Diffstat (limited to 'test/unit/specs/modules/users.spec.js')
-rw-r--r--test/unit/specs/modules/users.spec.js74
1 files changed, 51 insertions, 23 deletions
diff --git a/test/unit/specs/modules/users.spec.js b/test/unit/specs/modules/users.spec.js
index 812ba632..af60c9b3 100644
--- a/test/unit/specs/modules/users.spec.js
+++ b/test/unit/specs/modules/users.spec.js
@@ -1,34 +1,62 @@
import { cloneDeep } from 'lodash'
-import { defaultState, mutations } from '../../../../src/modules/users.js'
+import { defaultState, mutations, getters } from '../../../../src/modules/users.js'
describe('The users module', () => {
- it('adds new users to the set, merging in new information for old users', () => {
- const state = cloneDeep(defaultState)
- const user = { id: 1, name: 'Guy' }
- const modUser = { id: 1, name: 'Dude' }
-
- mutations.addNewUsers(state, [user])
- expect(state.users).to.have.length(1)
- expect(state.users).to.eql([user])
-
- mutations.addNewUsers(state, [modUser])
- expect(state.users).to.have.length(1)
- expect(state.users).to.eql([user])
- expect(state.users[0].name).to.eql('Dude')
- })
+ describe('mutations', () => {
+ it('adds new users to the set, merging in new information for old users', () => {
+ const state = cloneDeep(defaultState)
+ const user = { id: 1, name: 'Guy' }
+ const modUser = { id: 1, name: 'Dude' }
+
+ mutations.addNewUsers(state, [user])
+ expect(state.users).to.have.length(1)
+ expect(state.users).to.eql([user])
+
+ mutations.addNewUsers(state, [modUser])
+ expect(state.users).to.have.length(1)
+ expect(state.users).to.eql([user])
+ expect(state.users[0].name).to.eql('Dude')
+ })
+
+ it('sets a mute bit on users', () => {
+ const state = cloneDeep(defaultState)
+ const user = { id: 1, name: 'Guy' }
- it('sets a mute bit on users', () => {
- const state = cloneDeep(defaultState)
- const user = { id: 1, name: 'Guy' }
+ mutations.addNewUsers(state, [user])
+ mutations.setMuted(state, {user, muted: true})
- mutations.addNewUsers(state, [user])
- mutations.setMuted(state, {user, muted: true})
+ expect(user.muted).to.eql(true)
- expect(user.muted).to.eql(true)
+ mutations.setMuted(state, {user, muted: false})
- mutations.setMuted(state, {user, muted: false})
+ expect(user.muted).to.eql(false)
+ })
+ })
+
+ describe('getUserByName', () => {
+ it('returns user with matching screen_name', () => {
+ const state = {
+ users: [
+ { screen_name: 'Guy', id: 1 }
+ ]
+ }
+ const name = 'Guy'
+ const expected = { screen_name: 'Guy', id: 1 }
+ expect(getters.userByName(state)(name)).to.eql(expected)
+ })
+ })
- expect(user.muted).to.eql(false)
+ describe('getUserById', () => {
+ it('returns user with matching id', () => {
+ const state = {
+ users: [
+ { screen_name: 'Guy', id: 1 }
+ ]
+ }
+ const id = 1
+ const expected = { screen_name: 'Guy', id: 1 }
+ expect(getters.userById(state)(id)).to.eql(expected)
+ })
})
})