Skip to content

Commit

Permalink
Fix linking of nicks on parsed messages && related tests (#1648)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsOnlyBinary committed Feb 14, 2022
1 parent 4807fb9 commit 619bc75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/libs/MessageParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function matchUser(word, userList) {
let nickIdx = 0;

const trimWord = trim(word, punc);
let normWord = trimWord.toLowerCase();
let normWord = trimWord.toUpperCase();

if (hasProp.call(userList, normWord)) {
user = userList[normWord];
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/MessageParser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ describe('MessageParser.js', () => {
it('should return valid user blocks', () => {
// mock users list
let users = {
testnick1: { nick: 'TestNick1', username: 'testnick1', colour: '#a1fc5d' },
testnick2: { nick: 'TestNick2', username: 'testnick2', colour: '#7363fe' },
testnick3: { nick: 'TestNick3', username: 'testnick3' },
TESTNICK1: { nick: 'TestNick1', username: 'testnick1', colour: '#a1fc5d' },
TESTNICK2: { nick: 'TestNick2', username: 'testnick2', colour: '#7363fe' },
TESTNICK3: { nick: 'TestNick3', username: 'testnick3' },
};
let tests = [
['testnick1', 'testnick1'],
Expand All @@ -91,15 +91,15 @@ describe('MessageParser.js', () => {

expect(userBlocks.length).toEqual(1);
expect(userBlocks[0].meta.user).toEqual(compare);
expect(userBlocks[0].meta.colour).toEqual(users[compare.toLowerCase()].colour);
expect(userBlocks[0].meta.colour).toEqual(users[compare.toUpperCase()].colour);
});
});

it('should reject invalid users', () => {
// mock users list
let users = {
testnick1: { nick: 'TestNick1', username: 'testnick1' },
testnick2: { nick: 'TestNick2', username: 'testnick2' },
TESTNICK1: { nick: 'TestNick1', username: 'testnick1' },
TESTNICK2: { nick: 'TestNick2', username: 'testnick2' },
};
let tests = ['notauser', 'ttestnick', 'testnick11', 'ttestnick11'];

Expand Down

0 comments on commit 619bc75

Please sign in to comment.