Skip to content

Commit

Permalink
Fix some typos in the replacements
Browse files Browse the repository at this point in the history
Fixes #10
Fixes #8
  • Loading branch information
sindresorhus committed Jun 6, 2020
1 parent 4058138 commit 5258c74
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
12 changes: 6 additions & 6 deletions replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,18 @@ module.exports = [

// Turkish
['ş', 's'],
['Ş', 's'],
['Ş', 'S'],
['ç', 'c'],
['Ç', 'c'],
['Ç', 'C'],
['ğ', 'g'],
['Ğ', 'g'],
['Ğ', 'G'],
['ı', 'i'],
['İ', 'i'],
['İ', 'I'],

// Armenian
['ա', 'a'],
['բ', 'b'],
['գ', 'ɡ'],
['գ', 'g'],
['դ', 'd'],
['ե', 'ye'],
['զ', 'z'],
Expand Down Expand Up @@ -642,7 +642,7 @@ module.exports = [
['Ē', 'E'],
['Ģ', 'G'],
['Ī', 'I'],
['Ķ', 'k'],
['Ķ', 'K'],
['Ļ', 'L'],
['Ņ', 'N'],
['Ū', 'U'],
Expand Down
15 changes: 14 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from 'ava';
import transliterate from '.';
import replacements from './replacements';

test('main', t => {
t.is(transliterate('Foo ÿ'), 'Foo y');
Expand All @@ -18,6 +19,18 @@ test('customReplacements option', t => {
}), 'Zuerich');
});

test('all replacements are ASCII', t => {
const MAX_ASCII_CHARACTER_CODE = 127;

for (const [original, replacement] of replacements) {
if (replacement === '') {
continue;
}

t.true(replacement.charCodeAt(0) <= MAX_ASCII_CHARACTER_CODE, `${original}${replacement} (code: ${replacement.charCodeAt(0)})`);
}
});

test('supports German umlauts', t => {
t.is(transliterate('ä ö ü Ä Ö Ü ß'), 'ae oe ue Ae Oe Ue ss');
});
Expand Down Expand Up @@ -51,7 +64,7 @@ test('supports Romanian', t => {
});

test('supports Turkish', t => {
t.is(transliterate('İ ı Ş ş Ç ç Ğ ğ'), 'i i s s c c g g');
t.is(transliterate('İ ı Ş ş Ç ç Ğ ğ'), 'I i S s C c G g');
});

test('supports Armenian', t => {
Expand Down

0 comments on commit 5258c74

Please sign in to comment.