Files
habitica/test/api/unit/libs/stringUtils.test.js
Carlton McFarlane f2bcdd21de fix(banned words): fix partial matching of words containing diacritic… (#12444)
* fix(banned words): fix partial matching of words containing diacritics against banned words list (#12309)

* lint: remove whitespace to fix error

* test: add test to prevent partial matching of words containing diacritics against banned words list (#12309)

* doc: add link to Unicode table of diacritical marks (#12309)
2020-10-26 12:14:04 +01:00

18 lines
730 B
JavaScript

import { getMatchesByWordArray } from '../../../../website/server/libs/stringUtils';
import bannedWords from '../../../../website/server/libs/bannedWords';
describe('stringUtils', () => {
describe('getMatchesByWordArray', () => {
it('check all banned words are matched', async () => {
const message = bannedWords.join(',').replace(/\\/g, '');
const matches = getMatchesByWordArray(message, bannedWords);
expect(matches.length).to.equal(bannedWords.length);
});
it('doesn\'t flag names with accented characters', () => {
const name = 'TESTPLACEHOLDERSWEARWORDHEREé';
const matches = getMatchesByWordArray(name, bannedWords);
expect(matches.length).to.equal(0);
});
});
});