aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2022-08-23 21:52:17 +0300
committerHenry Jameson <me@hjkos.com>2022-08-23 21:52:17 +0300
commitcd7380efe74b791c042c2d7af307dadbc3acd99f (patch)
tree54aaf9eb79cc805ed409ddf364dad1733f957c38 /test/unit
parentbd7356376ec9137da674f146a89c17ed62f56bc3 (diff)
parent361aea13998bfba512a81422d3d0ca5b13ee60ee (diff)
Merge remote-tracking branch 'origin/develop' into navigation-update
* origin/develop: Update dependency opn to v5 fix notices being under the navbar, also change offset to use variable fix modals not having proper z index reduce indexes to be below 9999 so that develop error messages appear above Do not allow to find by name in findUser() Use lookup endpoint to obtain users by nickname Use $ for id UserProfile routes Allow opening profile: multiChoiceProprties record, anonymous access Allow opening profile when clicking an avatar inside of user popover
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/specs/components/user_profile.spec.js5
-rw-r--r--test/unit/specs/modules/users.spec.js44
2 files changed, 43 insertions, 6 deletions
diff --git a/test/unit/specs/components/user_profile.spec.js b/test/unit/specs/components/user_profile.spec.js
index 0fbab722..dc0b938a 100644
--- a/test/unit/specs/components/user_profile.spec.js
+++ b/test/unit/specs/components/user_profile.spec.js
@@ -15,6 +15,7 @@ const actions = {
const testGetters = {
findUser: state => getters.findUser(state.users),
+ findUserByName: state => getters.findUserByName(state.users),
relationship: state => getters.relationship(state.users),
mergedConfig: state => ({
colors: '',
@@ -95,6 +96,7 @@ const externalProfileStore = createStore({
credentials: ''
},
usersObject: { 100: extUser },
+ usersByNameObject: {},
users: [extUser],
relationships: {}
}
@@ -163,7 +165,8 @@ const localProfileStore = createStore({
currentUser: {
credentials: ''
},
- usersObject: { 100: localUser, testuser: localUser },
+ usersObject: { 100: localUser },
+ usersByNameObject: { testuser: localUser },
users: [localUser],
relationships: {}
}
diff --git a/test/unit/specs/modules/users.spec.js b/test/unit/specs/modules/users.spec.js
index dfa5684d..3073f507 100644
--- a/test/unit/specs/modules/users.spec.js
+++ b/test/unit/specs/modules/users.spec.js
@@ -57,24 +57,27 @@ describe('The users module', () => {
})
describe('findUser', () => {
- it('returns user with matching screen_name', () => {
+ it('does not return user with matching screen_name', () => {
const user = { screen_name: 'Guy', id: '1' }
const state = {
usersObject: {
- 1: user,
+ 1: user
+ },
+ usersByNameObject: {
guy: user
}
}
const name = 'Guy'
- const expected = { screen_name: 'Guy', id: '1' }
- expect(getters.findUser(state)(name)).to.eql(expected)
+ expect(getters.findUser(state)(name)).to.eql(undefined)
})
it('returns user with matching id', () => {
const user = { screen_name: 'Guy', id: '1' }
const state = {
usersObject: {
- 1: user,
+ 1: user
+ },
+ usersByNameObject: {
guy: user
}
}
@@ -83,4 +86,35 @@ describe('The users module', () => {
expect(getters.findUser(state)(id)).to.eql(expected)
})
})
+
+ describe('findUserByName', () => {
+ it('returns user with matching screen_name', () => {
+ const user = { screen_name: 'Guy', id: '1' }
+ const state = {
+ usersObject: {
+ 1: user
+ },
+ usersByNameObject: {
+ guy: user
+ }
+ }
+ const name = 'Guy'
+ const expected = { screen_name: 'Guy', id: '1' }
+ expect(getters.findUserByName(state)(name)).to.eql(expected)
+ })
+
+ it('does not return user with matching id', () => {
+ const user = { screen_name: 'Guy', id: '1' }
+ const state = {
+ usersObject: {
+ 1: user
+ },
+ usersByNameObject: {
+ guy: user
+ }
+ }
+ const id = '1'
+ expect(getters.findUserByName(state)(id)).to.eql(undefined)
+ })
+ })
})