port slug unit tests to uvu

pull/6811/head
Conduitry 5 years ago
parent beffea63ff
commit cfce79fb99

@ -10,7 +10,7 @@
"build": "node scripts/update.js && npm run copy-workers && svelte-kit build",
"update": "node scripts/update.js --force=true",
"start": "node build",
"test": "mocha -r esm test/**",
"test": "uvu test",
"deploy": "make deploy"
},
"dependencies": {

@ -1,5 +1,5 @@
import slugify from '@sindresorhus/slugify';
import {SLUG_SEPARATOR} from '../../config';
import {SLUG_SEPARATOR} from '../../config.js';
/* url-safe processor */

@ -1,10 +1,15 @@
import {strict as assert} from 'assert';
import {urlsafeSlugProcessor, unicodeSafeProcessor} from '../../src/utils/slug';
import {SLUG_SEPARATOR as _} from '../../config';
import * as uvu from 'uvu';
import * as assert from 'uvu/assert';
import {urlsafeSlugProcessor, unicodeSafeProcessor} from '../../src/utils/slug.js';
import {SLUG_SEPARATOR as _} from '../../config.js';
describe('slug', () => {
describe('urlsafeSlugProcessor', () => {
describe('ascii', () => {
function run(name, func) {
const suite = uvu.suite(name);
func(suite);
suite.run();
}
run('urlsafeSlugProcessor -> ascii', it => {
it('space separated words', () => {
assert.equal(
urlsafeSlugProcessor('Text expressions'),
@ -60,7 +65,8 @@ describe('slug', () => {
);
});
});
describe('unicode', () => {
run('urlsafeSlugProcessor - unicode', it => {
it('should translate symbols to English', () => {
assert.equal(
urlsafeSlugProcessor('Ich ♥ Deutsch'),
@ -74,7 +80,8 @@ describe('slug', () => {
);
});
});
describe('cyricllic', () => {
run('urlsafeSlugProcessor -> cyrillic', it => {
it('space separated words', () => {
assert.equal(
urlsafeSlugProcessor('Всплытие и перехват событий'),
@ -130,20 +137,21 @@ describe('slug', () => {
);
});
});
describe('ascii + cyricllic', () => {
run('urlsafeSlugProcessor -> ascii + cyrillic', it => {
it('space separated words', () => {
assert.equal(
urlsafeSlugProcessor('Всплытие и export перехват событий'),
`Vsplytie${_}i${_}export${_}perehvat${_}sobytij`
);
});
it('ascii word concatenated to a cyricllic word', () => {
it('ascii word concatenated to a cyrillic word', () => {
assert.equal(
urlsafeSlugProcessor('exportВсплытие'),
'exportVsplytie'
);
});
it('cyricllic word concatenated to an ascii word', () => {
it('cyrillic word concatenated to an ascii word', () => {
assert.equal(
urlsafeSlugProcessor('Всплытиеexport'),
`Vsplytieexport`
@ -210,10 +218,8 @@ describe('slug', () => {
);
});
});
});
describe('unicodeSafeProcessor (preserve unicode)', () => {
describe('ascii', () => {
run('unicodeSafeProcessor (preserve unicode) -> ascii', it => {
it('space separated words', () => {
assert.equal(
unicodeSafeProcessor('Text expressions'),
@ -269,7 +275,8 @@ describe('slug', () => {
);
});
});
describe('unicode', () => {
run('unicodeSafeProcessor (preserve unicode) -> unicode', it => {
it('should preserve symbols', () => {
assert.equal(
unicodeSafeProcessor('Ich ♥ Deutsch'),
@ -283,7 +290,8 @@ describe('slug', () => {
);
});
});
describe('cyricllic', () => {
run('unicodeSafeProcessor (preserve unicode) -> cyrillic', it => {
it('space separated words', () => {
assert.equal(
unicodeSafeProcessor('Всплытие и перехват событий'),
@ -339,20 +347,21 @@ describe('slug', () => {
);
});
});
describe('ascii + cyricllic', () => {
run('unicodeSafeProcessor (preserve unicode) -> ascii + cyrillic', it => {
it('space separated words', () => {
assert.equal(
unicodeSafeProcessor('Всплытие и export перехват событий'),
`Всплытие${_}и${_}export${_}перехват${_}событий`
);
});
it('ascii word concatenated to a cyricllic word', () => {
it('ascii word concatenated to a cyrillic word', () => {
assert.equal(
unicodeSafeProcessor('exportВсплытие'),
`export${_}Всплытие`
);
});
it('cyricllic word concatenated to an ascii word', () => {
it('cyrillic word concatenated to an ascii word', () => {
assert.equal(
unicodeSafeProcessor('Всплытиеexport'),
`Всплытие${_}export`
@ -419,5 +428,3 @@ describe('slug', () => {
);
});
});
});
});

Loading…
Cancel
Save