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.
68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
import { jest } from '@jest/globals';
|
|
import docsifyInit from '../helpers/docsify-init.js';
|
|
|
|
// Suite
|
|
// -----------------------------------------------------------------------------
|
|
describe('Docs Site', function () {
|
|
// Tests
|
|
// ---------------------------------------------------------------------------
|
|
test('coverpage renders and is unchanged', async () => {
|
|
// Override Math.random implementation to prevent random gradient values
|
|
// used as background image from causing test to fail
|
|
const mathSpy = jest.spyOn(Math, 'random').mockReturnValue(0.5);
|
|
|
|
await docsifyInit({
|
|
config: {
|
|
coverpage: 'docs/_coverpage.md',
|
|
},
|
|
markdown: {
|
|
homepage: '# Hello World',
|
|
},
|
|
waitForSelector: '.cover-main > *',
|
|
});
|
|
|
|
const coverpageElm = document.querySelector('section.cover');
|
|
|
|
// Test snapshots
|
|
expect(mathSpy).toHaveBeenCalled();
|
|
expect(coverpageElm).not.toBeNull();
|
|
expect(coverpageElm.outerHTML).toMatchSnapshot();
|
|
});
|
|
|
|
test('sidebar renders and is unchanged', async () => {
|
|
await docsifyInit({
|
|
config: {
|
|
loadSidebar: 'docs/_sidebar.md',
|
|
},
|
|
markdown: {
|
|
homepage: '# Hello World',
|
|
},
|
|
waitForSelector: '.sidebar-nav > ul',
|
|
});
|
|
|
|
const sidebarElm = document.querySelector('.sidebar');
|
|
|
|
// Test snapshots
|
|
expect(sidebarElm).not.toBeNull();
|
|
expect(sidebarElm.outerHTML).toMatchSnapshot();
|
|
});
|
|
|
|
test('navbar renders and is unchanged', async () => {
|
|
await docsifyInit({
|
|
config: {
|
|
loadNavbar: 'docs/_navbar.md',
|
|
},
|
|
markdown: {
|
|
homepage: '# Hello World',
|
|
},
|
|
waitForSelector: '.app-nav > ul',
|
|
});
|
|
|
|
const navbarElm = document.querySelector('nav.app-nav');
|
|
|
|
// Test snapshots
|
|
expect(navbarElm).not.toBeNull();
|
|
expect(navbarElm.outerHTML).toMatchSnapshot();
|
|
});
|
|
});
|