Skip to content

chore: restore test of global APIs based on loading a script tag #1416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/integration/docsify.test.js → test/e2e/docsify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@ const docsifyInit = require('../helpers/docsify-init');
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);
Expand Down
4 changes: 2 additions & 2 deletions test/integration/global-apis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import initGlobalAPI from '../../src/core/global-api.js';

// Suite
// -----------------------------------------------------------------------------
describe('Global APIs', function() {
describe('initGlobalAPI', function() {
// Tests
// ---------------------------------------------------------------------------
test('APIs are available', () => {
test('it makes Docsify APIs available globally', () => {
initGlobalAPI();

expect(typeof window.Docsify).toEqual('object');
Expand Down