MM-14461: make @-mentions (and searches) case insensitive (#2641)

This commit is contained in:
Jesse Hallam 2019-03-13 09:37:56 -04:00 committed by GitHub
parent 8719d3f227
commit 692953e860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 1 deletions

View file

@ -27,7 +27,7 @@ export const getMatchTermForAtMention = (() => {
lastValue = value;
lastIsSearch = isSearch;
if (match) {
lastMatchTerm = isSearch ? match[1] : match[2];
lastMatchTerm = (isSearch ? match[1] : match[2]).toLowerCase();
} else {
lastMatchTerm = null;
}

View file

@ -0,0 +1,59 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import assert from 'assert';
import {
getMatchTermForAtMention,
} from 'app/selectors/autocomplete';
/* eslint-disable max-nested-callbacks */
describe('Selectors.Autocomplete', () => {
describe('getMatchTermForAtMention', () => {
describe('match non-search at mentions', () => {
const testCases = [
['@', ''],
['@a', 'a'],
['@match', 'match'],
['@Username', 'username'],
['@USERNAME', 'username'],
['not a match', null],
];
testCases.forEach((testCase) => {
it(testCase[0], () => {
const value = testCase[0];
const isSearch = false;
const expected = testCase[1];
const actual = getMatchTermForAtMention(value, isSearch);
assert.equal(expected, actual);
});
});
});
describe('match search at mentions', () => {
const testCases = [
['from:', ''],
['from:a', 'a'],
['from:match', 'match'],
['from:not a match', null],
['from:Username', 'username'],
['from:USERNAME', 'username'],
['from: space', 'space'],
];
testCases.forEach((testCase) => {
it(testCase[0], () => {
const value = testCase[0];
const isSearch = true;
const expected = testCase[1];
const actual = getMatchTermForAtMention(value, isSearch);
assert.equal(expected, actual);
});
});
});
});
});