-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathdocsify.test.js
More file actions
80 lines (70 loc) · 2.57 KB
/
docsify.test.js
File metadata and controls
80 lines (70 loc) · 2.57 KB
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
77
78
79
80
const docsifyInit = require('../helpers/docsify-init');
// Suite
// -----------------------------------------------------------------------------
describe('Docsify', function() {
// Tests
// ---------------------------------------------------------------------------
it('global APIs are available', async () => {
await docsifyInit();
// If the script was built successfully for production, then it should load
// and the following APIs should be available:
expect(await page.evaluate(() => typeof window.Docsify)).toEqual('object');
expect(await page.evaluate(() => typeof window.Docsify.util)).toEqual(
'object'
);
expect(await page.evaluate(() => typeof window.Docsify.dom)).toEqual(
'object'
);
expect(await page.evaluate(() => typeof window.Docsify.get)).toEqual(
'function'
);
expect(await page.evaluate(() => typeof window.Docsify.slugify)).toEqual(
'function'
);
expect(await page.evaluate(() => typeof window.Docsify.version)).toEqual(
'string'
);
expect(await page.evaluate(() => typeof window.DocsifyCompiler)).toEqual(
'function'
);
expect(await page.evaluate(() => typeof window.marked)).toEqual('function');
expect(await page.evaluate(() => typeof window.Prism)).toEqual('object');
});
test('allows $docsify configuration to be a function', async () => {
const testConfig = jest.fn(vm => {
expect(vm).toBeInstanceOf(Object);
expect(vm.constructor.name).toEqual('Docsify');
expect(vm.$fetch).toBeInstanceOf(Function);
expect(vm.$resetEvents).toBeInstanceOf(Function);
expect(vm.route).toBeInstanceOf(Object);
});
await docsifyInit({
config: testConfig,
});
expect(typeof Docsify).toEqual('object');
expect(testConfig).toHaveBeenCalled();
});
test('provides the hooks and vm API to plugins', async () => {
const testConfig = jest.fn(vm => {
const vm1 = vm;
return {
plugins: [
function(hook, vm2) {
expect(vm1).toEqual(vm2);
expect(hook.init).toBeInstanceOf(Function);
expect(hook.beforeEach).toBeInstanceOf(Function);
expect(hook.afterEach).toBeInstanceOf(Function);
expect(hook.doneEach).toBeInstanceOf(Function);
expect(hook.mounted).toBeInstanceOf(Function);
expect(hook.ready).toBeInstanceOf(Function);
},
],
};
});
await docsifyInit({
config: testConfig,
});
expect(typeof Docsify).toEqual('object');
expect(testConfig).toHaveBeenCalled();
});
});