Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Support aliases #31

Merged
merged 5 commits into from
Aug 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"jsx-dom": "^5.1.2",
"pluralize": "^6.0.0",
"remove-accents": "tyxla/remove-accents#8025d6cd35900226f6c1d4dd709ad653fb74357b",
"seamless-immutable": "^7.1.2"
},
"devDependencies": {
Expand Down
46 changes: 46 additions & 0 deletions src/core/__tests__/findAllMatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,49 @@ test('Should detect plurals', (t) => {
},
]);
});

test('Should detect aliases', (t) => {
const text = 'Frost, Yen, YenCon, QG and light cavalries';
const matchedRanges = findAllMatches(DICTIONARY, text);
t.deepEqual(matchedRanges, [
{
entryKey: 'frost',
entryValue: 'Biting Frost',
start: 0,
end: 5,
}, {
entryKey: 'yen',
entryValue: 'Yennefer',
start: 7,
end: 10,
}, {
entryKey: 'yencon',
entryValue: 'Yennefer: The Conjurer',
start: 12,
end: 18,
}, {
entryKey: 'qg',
entryValue: 'Queensguard',
start: 20,
end: 22,
}, {
entryKey: 'light cavalries',
entryValue: 'Dun Banner Light Cavalry',
start: 27,
end: 42,
},
]);
});

test('Should work around accentuated letters', (t) => {
const text = 'Schirru';
const matchedRanges = findAllMatches(DICTIONARY, text);
t.deepEqual(matchedRanges, [
{
entryKey: 'schirru',
entryValue: 'Schirrú',
start: 0,
end: 7,
},
]);
});
Loading