mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
BREAKING: The new project layout might break in some tooling setups. We've added an exports field to `package.json` to specify where statements like `import ... from 'docsify'` will import from, and left the `main` and `unpkg` fields as-is for backwards compatibility with the global <script> import method. Most people who use a non-module `<script>` tag to import Docsify will not notice a difference. Anyone else who is importing Docsify into a specilized build setup using `import` statements has a chance of being broken, so we've marked this as BREAKING.
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
import { jest } from '@jest/globals';
|
|
import docsifyInit from '../helpers/docsify-init.js';
|
|
|
|
// Suite
|
|
// -----------------------------------------------------------------------------
|
|
describe('Docsify', function () {
|
|
// Tests
|
|
// ---------------------------------------------------------------------------
|
|
test('allows $docsify configuration to be a function', async () => {
|
|
const testConfig = jest.fn(vm => {
|
|
expect(vm).toBeInstanceOf(Object);
|
|
expect(vm.constructor.name).toBe('Docsify');
|
|
expect(vm.$fetch).toBeInstanceOf(Function);
|
|
expect(vm.$resetEvents).toBeInstanceOf(Function);
|
|
expect(vm.route).toBeInstanceOf(Object);
|
|
});
|
|
|
|
await docsifyInit({
|
|
config: testConfig,
|
|
});
|
|
|
|
expect(typeof Docsify).toBe('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).toBe('object');
|
|
expect(testConfig).toHaveBeenCalled();
|
|
});
|
|
});
|