-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Copy pathindex.spec.js
54 lines (46 loc) · 1.52 KB
/
index.spec.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
/**
* @jest-environment node
*/
const { createApp } = require('@vuepress/core')
const { path: { resolve }, fs } = require('@vuepress/shared-utils')
function testForExistence (app, name, existence = true) {
test(`${existence ? '' : 'in'}existence: ${name}`, () => {
expect(fs.existsSync(resolve(app.outDir, name))).toBe(existence)
})
}
describe('plugin-public-files: source folder', () => {
const app = createApp({
sourceDir: resolve(__dirname, 'docs-1')
})
beforeAll(async () => {
await app.process()
await app.build()
}, 60000)
testForExistence(app, 'foo.txt')
testForExistence(app, 'baz.txt')
testForExistence(app, 'bar/foo.txt')
testForExistence(app, 'bar/baz.txt')
testForExistence(app, 'index.html')
testForExistence(app, 'readme.md', false)
testForExistence(app, '.dotfile', false)
testForExistence(app, '.dotfolder', false)
testForExistence(app, 'bar/readme.md', false)
})
describe('plugin-public-files: assets folder', () => {
const app = createApp({
sourceDir: resolve(__dirname, 'docs-2')
})
beforeAll(async () => {
await app.process()
await app.build()
}, 60000)
testForExistence(app, 'foo.txt')
testForExistence(app, 'assets/bar.png')
testForExistence(app, 'assets/.dotfile')
testForExistence(app, 'assets/.dotfolder/foo.txt')
testForExistence(app, 'bar.png', false)
testForExistence(app, 'baz.ignore', false)
testForExistence(app, '.dotfile', false)
testForExistence(app, '.dotfolder', false)
testForExistence(app, 'assets/baz.ignore', false)
})