-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
/
Copy pathsidebar.test.js
71 lines (62 loc) · 2.01 KB
/
sidebar.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
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
71
const docsifyInit = require('../helpers/docsify-init');
const { test, expect } = require('./fixtures/docsify-init-fixture');
// Suite
// -----------------------------------------------------------------------------
test.describe('Sidebar Tests', () => {
// Tests
// ---------------------------------------------------------------------------
test('Active Test', async ({ page }) => {
const docsifyInitConfig = {
markdown: {
sidebar: `
- [Test Space](test%20space)
- [Test _](test_foo)
- [Test -](test-foo)
- [Test .](test.foo)
- [Test >](test>foo)
- [Test](test)
`,
},
routes: {
'/test space.md': `
# Test Space
`,
'/test_foo.md': `
# Test _
`,
'/test-foo.md': `
# Test -
`,
'/test.foo.md': `
# Test .
`,
'/test>foo.md': `
# Test >
`,
'/test.md': `
# Test page
`,
},
};
const activeLinkElm = page.locator('.sidebar-nav li[class=active]');
await docsifyInit(docsifyInitConfig);
await page.click('a[href="#/test%20space"]');
await expect(activeLinkElm).toHaveText('Test Space');
expect(page.url()).toMatch(/\/test%20space$/);
await page.click('a[href="#/test_foo"]');
await expect(activeLinkElm).toHaveText('Test _');
expect(page.url()).toMatch(/\/test_foo$/);
await page.click('a[href="#/test-foo"]');
await expect(activeLinkElm).toHaveText('Test -');
expect(page.url()).toMatch(/\/test-foo$/);
await page.click('a[href="#/test.foo"]');
expect(page.url()).toMatch(/\/test.foo$/);
await expect(activeLinkElm).toHaveText('Test .');
await page.click('a[href="#/test>foo"]');
await expect(activeLinkElm).toHaveText('Test >');
expect(page.url()).toMatch(/\/test%3Efoo$/);
await page.click('a[href="#/test"]');
await expect(activeLinkElm).toHaveText('Test');
expect(page.url()).toMatch(/\/test$/);
});
});