forked from docsifyjs/docsify
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.test.js
76 lines (65 loc) · 2.14 KB
/
search.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
72
73
74
75
76
const docsifyInit = require('../helpers/docsify-init');
// Suite
// -----------------------------------------------------------------------------
describe('Search Plugin Tests', function() {
// Tests
// ---------------------------------------------------------------------------
test('search readme', async () => {
const docsifyInitConfig = {
markdown: {
homepage: `
# Hello World
This is the homepage.
`,
sidebar: `
- [Home page](/)
- [Test Page](test)
`,
},
routes: {
'/test.md': `
# Test Page
This is a custom route.
`,
},
scriptURLs: ['/lib/plugins/search.min.js'],
};
await docsifyInit(docsifyInitConfig);
await page.fill('input[type=search]', 'hello');
await expect(page).toEqualText('.results-panel h2', 'Hello World');
await page.click('.clear-button');
await page.fill('input[type=search]', 'test');
await expect(page).toEqualText('.results-panel h2', 'Test Page');
});
test('search ignore title', async () => {
const docsifyInitConfig = {
markdown: {
homepage: `
# Hello World
This is the homepage.
`,
sidebar: `
- [Home page](/)
- [GitHub Pages](github)
`,
},
routes: {
'/github.md': `
# GitHub Pages
This is the GitHub Pages.
## GitHub Pages ignore1 <!-- {docsify-ignore} -->
There're three places to populate your docs for your Github repository1.
## GitHub Pages ignore2 {docsify-ignore}
There're three places to populate your docs for your Github repository2.
`,
},
scriptURLs: ['/lib/plugins/search.min.js'],
};
await docsifyInit(docsifyInitConfig);
await page.fill('input[type=search]', 'repository1');
await expect(page).toEqualText('.results-panel h2', 'GitHub Pages ignore1');
await page.click('.clear-button');
await page.fill('input[type=search]', 'repository2');
await expect(page).toEqualText('.results-panel h2', 'GitHub Pages ignore2');
});
});