From a593c2cb8cf77ea1d894a941c29858630e703a36 Mon Sep 17 00:00:00 2001 From: shpuld Date: Mon, 28 Jan 2019 21:21:11 +0200 Subject: [PATCH] Make userByName case-insensitive --- src/modules/users.js | 2 +- test/unit/specs/modules/users.spec.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/modules/users.js b/src/modules/users.js index d83f0dd898..181946b409 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -91,7 +91,7 @@ export const getters = { userById: state => id => state.users.find(user => user.id === id), userByName: state => name => - state.users.find(user => user.screen_name === name) + state.users.find(user => user.screen_name.toLowerCase() === name.toLowerCase()) } export const defaultState = { diff --git a/test/unit/specs/modules/users.spec.js b/test/unit/specs/modules/users.spec.js index b0f3c51eeb..4d49ee2424 100644 --- a/test/unit/specs/modules/users.spec.js +++ b/test/unit/specs/modules/users.spec.js @@ -45,6 +45,17 @@ describe('The users module', () => { const expected = { screen_name: 'Guy', id: '1' } expect(getters.userByName(state)(name)).to.eql(expected) }) + + it('returns user with matching screen_name with different case', () => { + 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) + }) }) describe('getUserById', () => {