Skip to content

Commit 3966b6e

Browse files
committed
chore: restore test of global APIs based on loading a script tag
1 parent 8cf9fd8 commit 3966b6e

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

test/integration/docsify.test.js renamed to test/e2e/docsify.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ const docsifyInit = require('../helpers/docsify-init');
55
describe('Docsify', function() {
66
// Tests
77
// ---------------------------------------------------------------------------
8+
it('global APIs are available', async () => {
9+
await docsifyInit();
10+
11+
// If the script was built successfully for production, then it should load
12+
// and the following APIs should be available:
13+
expect(await page.evaluate(() => typeof window.Docsify)).toEqual('object');
14+
expect(await page.evaluate(() => typeof window.Docsify.util)).toEqual(
15+
'object'
16+
);
17+
expect(await page.evaluate(() => typeof window.Docsify.dom)).toEqual(
18+
'object'
19+
);
20+
expect(await page.evaluate(() => typeof window.Docsify.get)).toEqual(
21+
'function'
22+
);
23+
expect(await page.evaluate(() => typeof window.Docsify.slugify)).toEqual(
24+
'function'
25+
);
26+
expect(await page.evaluate(() => typeof window.Docsify.version)).toEqual(
27+
'string'
28+
);
29+
expect(await page.evaluate(() => typeof window.DocsifyCompiler)).toEqual(
30+
'function'
31+
);
32+
expect(await page.evaluate(() => typeof window.marked)).toEqual('function');
33+
expect(await page.evaluate(() => typeof window.Prism)).toEqual('object');
34+
});
35+
836
test('allows $docsify configuration to be a function', async () => {
937
const testConfig = jest.fn(vm => {
1038
expect(vm).toBeInstanceOf(Object);

test/integration/global-apis.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import initGlobalAPI from '../../src/core/global-api.js';
22

33
// Suite
44
// -----------------------------------------------------------------------------
5-
describe('Global APIs', function() {
5+
describe('initGlobalAPI', function() {
66
// Tests
77
// ---------------------------------------------------------------------------
8-
test('APIs are available', () => {
8+
test('it makes Docsify APIs available globally', () => {
99
initGlobalAPI();
1010

1111
expect(typeof window.Docsify).toEqual('object');

0 commit comments

Comments
 (0)