-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump reqired node to 18, swap
tap
for node:test
Node's built-in test runner works great!
- Loading branch information
Showing
4 changed files
with
73 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,53 @@ | ||
import { test } from 'tap'; | ||
import { test } from 'node:test'; | ||
import { strict as assert } from 'node:assert'; | ||
import { simplify } from '../index.mjs'; | ||
|
||
test('simplify', t => { | ||
test('simplify', async t => { | ||
|
||
t.test('lowercases', t => { | ||
t.equal(simplify('Aldo'), 'aldo'); | ||
t.end(); | ||
await t.test('lowercases', t => { | ||
assert.equal(simplify('Aldo'), 'aldo'); | ||
}); | ||
|
||
t.test('replaces diacritics', t => { | ||
t.equal(simplify('André'), 'andre'); | ||
t.end(); | ||
await t.test('replaces diacritics', t => { | ||
assert.equal(simplify('André'), 'andre'); | ||
}); | ||
|
||
t.test('removes spaces', t => { | ||
t.equal(simplify('Jimmy Choo'), 'jimmychoo'); | ||
t.end(); | ||
await t.test('removes spaces', t => { | ||
assert.equal(simplify('Jimmy Choo'), 'jimmychoo'); | ||
}); | ||
|
||
t.test('removes various dashes', t => { | ||
t.equal(simplify('PTV - Metropolitan'), 'ptvmetropolitan'); // hypen | ||
t.equal(simplify('PTV – Metropolitan'), 'ptvmetropolitan'); // en dash (U+2013) | ||
t.equal(simplify('PTV — Metropolitan'), 'ptvmetropolitan'); // em dash (U+2014) | ||
t.equal(simplify('PTV ― Metropolitan'), 'ptvmetropolitan'); // horizontal bar (U+2015) | ||
t.end(); | ||
await t.test('removes various dashes', t => { | ||
assert.equal(simplify('PTV - Metropolitan'), 'ptvmetropolitan'); // hypen | ||
assert.equal(simplify('PTV – Metropolitan'), 'ptvmetropolitan'); // en dash (U+2013) | ||
assert.equal(simplify('PTV — Metropolitan'), 'ptvmetropolitan'); // em dash (U+2014) | ||
assert.equal(simplify('PTV ― Metropolitan'), 'ptvmetropolitan'); // horizontal bar (U+2015) | ||
}); | ||
|
||
t.test('removes unprintable unicode (like RTL/LTR marks, zero width space, zero width nonjoiner)', t => { | ||
t.equal(simplify('\u200FJim\u200Bmy\u200CChoo\u200E'), 'jimmychoo'); | ||
t.end(); | ||
await t.test('removes unprintable unicode (like RTL/LTR marks, zero width space, zero width nonjoiner)', t => { | ||
assert.equal(simplify('\u200FJim\u200Bmy\u200CChoo\u200E'), 'jimmychoo'); | ||
}); | ||
|
||
t.test('removes punctuation', t => { | ||
t.equal(simplify('K+K Schuh-Center'), 'kkschuhcenter'); | ||
t.end(); | ||
await t.test('removes punctuation', t => { | ||
assert.equal(simplify('K+K Schuh-Center'), 'kkschuhcenter'); | ||
}); | ||
|
||
t.test('replaces & with and', t => { | ||
t.equal(simplify('Johnston & Murphy'), 'johnstonandmurphy'); | ||
t.end(); | ||
await t.test('replaces & with and', t => { | ||
assert.equal(simplify('Johnston & Murphy'), 'johnstonandmurphy'); | ||
}); | ||
|
||
t.test('replaces ß (eszett) with ss', t => { | ||
t.equal(simplify('Beßon'), 'besson'); | ||
t.end(); | ||
await t.test('replaces ß (eszett) with ss', t => { | ||
assert.equal(simplify('Beßon'), 'besson'); | ||
}); | ||
|
||
t.test('replaces İ (0130) or i̇ (0069 0307) with i', t => { // #5017, #8261 for examples | ||
t.equal(simplify('İnşaat'), 'insaat'); | ||
t.equal(simplify('i̇nşaat'), 'insaat'); | ||
t.end(); | ||
await t.test('replaces İ (0130) or i̇ (0069 0307) with i', t => { // #5017, #8261 for examples | ||
assert.equal(simplify('İnşaat'), 'insaat'); | ||
assert.equal(simplify('i̇nşaat'), 'insaat'); | ||
}); | ||
|
||
t.test('returns empty string if no input', t => { | ||
t.equal(simplify(), ''); | ||
t.equal(simplify(null), ''); | ||
t.equal(simplify({}), ''); | ||
t.end(); | ||
await t.test('returns empty string if no input', t => { | ||
assert.equal(simplify(), ''); | ||
assert.equal(simplify(null), ''); | ||
assert.equal(simplify({}), ''); | ||
}); | ||
|
||
t.end(); | ||
}); |