-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
urlify.test.js
45 lines (37 loc) · 1.4 KB
/
urlify.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { urlify } from './urlify';
// load window.XRegExp polyfill
import { XRegExp } from '../../../wagtail/admin/static_src/wagtailadmin/js/vendor/xregexp.min';
window.XRegExp = XRegExp;
describe('urlify', () => {
beforeAll(() => {
// load window.URLify
require('../../../wagtail/admin/static_src/wagtailadmin/js/vendor/urlify')
.default;
});
describe('urlify with unicode slugs disabled (default)', () => {
it('should return a correct slug which is escaped by urlify', () => {
expect(urlify('This & That')).toBe('this-that');
expect(urlify('Lisboa é ótima à beira-mar')).toBe(
'lisboa-e-otima-a-beira-mar',
);
});
});
describe('urlify with unicode slugs enabled', () => {
const options = { unicodeSlugsEnabled: true };
it('should return a correct slug which is escaped by urlify', () => {
expect(urlify('Before', options)).toBe('before');
expect(urlify('The', options)).toBe('the');
expect(urlify('Before the sun rises', options)).toBe(
'before-the-sun-rises',
);
expect(urlify('ON', options)).toBe('on');
expect(urlify('ON this day in november', options)).toBe(
'on-this-day-in-november',
);
expect(urlify('This & That', options)).toBe('this-that');
expect(urlify('Lisboa é ótima à beira-mar', options)).toBe(
'lisboa-é-ótima-à-beira-mar',
);
});
});
});