deno.land / x / lume@v2.1.4 / tests / slugify_urls.test.ts

slugify_urls.test.ts
نووسراو ببینە
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { assertStrictEquals as equals } from "../deps/assert.ts";import { assertSiteSnapshot, build, getSite } from "./utils.ts";import slugifyUrls from "../plugins/slugify_urls.ts";import createSlugifier from "../core/slugifier.ts";
Deno.test("slugify_urls plugin", async (t) => { const site = getSite({ src: "slugify_urls", });
site.use(slugifyUrls()); site.copy([".css"]); site.copy("_headers");
await build(site); await assertSiteSnapshot(t, site);});
Deno.test("slugify_urls plugin (static files)", async (t) => { const site = getSite({ src: "slugify_urls", });
site.use(slugifyUrls({ extensions: "*", })); site.copy([".css"]); site.copy("_headers");
await build(site); await assertSiteSnapshot(t, site);});
Deno.test("slugify clean urls", () => { const slugify = createSlugifier();
equals(slugify("Hello / World"), "hello/world"); equals(slugify("hello_/_world"), "hello/world"); equals(slugify("200,000*7"), "200-000-7"); equals(slugify("img/Image 2 .png"), "img/image-2.png");});
Deno.test("slugify replacement chars", () => { const slugify = createSlugifier();
equals(slugify("Ð"), "d"); equals(slugify("ð"), "d"); equals(slugify("№"), "no");});
Deno.test("slugify forbidden characters and words", () => { const slugify = createSlugifier({ stopWords: ["or", "and", "the"], });
equals(slugify(""), ""); equals(slugify("the man or the woman"), "man-woman"); equals(slugify(" forks and knives "), "forks-knives"); equals(slugify("went down the road"), "went-down-road");});
Deno.test("slugify support unicode characters", () => { const slugify = createSlugifier();
equals( slugify("Lume 支持中文,中文标点。?、【】{}!¥()"), "lume-zhichizhongwen-zhongwenbiaodian", );});
lume

Version Info

Tagged at
7 months ago