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.
72 lines
2.0 KiB
JavaScript
72 lines
2.0 KiB
JavaScript
import docsifyInit from '../helpers/docsify-init.js';
|
|
import { test, expect } from './fixtures/docsify-init-fixture.js';
|
|
|
|
// Suite
|
|
// -----------------------------------------------------------------------------
|
|
test.describe('Sidebar Tests', () => {
|
|
// Tests
|
|
// ---------------------------------------------------------------------------
|
|
test('Active Test', async ({ page }) => {
|
|
const docsifyInitConfig = {
|
|
markdown: {
|
|
sidebar: `
|
|
- [Test Space](test%20space)
|
|
- [Test _](test_foo)
|
|
- [Test -](test-foo)
|
|
- [Test .](test.foo)
|
|
- [Test >](test>foo)
|
|
- [Test](test)
|
|
`,
|
|
},
|
|
routes: {
|
|
'/test space.md': `
|
|
# Test Space
|
|
`,
|
|
'/test_foo.md': `
|
|
# Test _
|
|
`,
|
|
'/test-foo.md': `
|
|
# Test -
|
|
`,
|
|
'/test.foo.md': `
|
|
# Test .
|
|
`,
|
|
'/test>foo.md': `
|
|
# Test >
|
|
`,
|
|
'/test.md': `
|
|
# Test page
|
|
`,
|
|
},
|
|
};
|
|
|
|
const activeLinkElm = page.locator('.sidebar-nav li[class=active]');
|
|
|
|
await docsifyInit(docsifyInitConfig);
|
|
|
|
await page.click('a[href="#/test%20space"]');
|
|
await expect(activeLinkElm).toHaveText('Test Space');
|
|
expect(page.url()).toMatch(/\/test%20space$/);
|
|
|
|
await page.click('a[href="#/test_foo"]');
|
|
await expect(activeLinkElm).toHaveText('Test _');
|
|
expect(page.url()).toMatch(/\/test_foo$/);
|
|
|
|
await page.click('a[href="#/test-foo"]');
|
|
await expect(activeLinkElm).toHaveText('Test -');
|
|
expect(page.url()).toMatch(/\/test-foo$/);
|
|
|
|
await page.click('a[href="#/test.foo"]');
|
|
expect(page.url()).toMatch(/\/test.foo$/);
|
|
await expect(activeLinkElm).toHaveText('Test .');
|
|
|
|
await page.click('a[href="#/test>foo"]');
|
|
await expect(activeLinkElm).toHaveText('Test >');
|
|
expect(page.url()).toMatch(/\/test%3Efoo$/);
|
|
|
|
await page.click('a[href="#/test"]');
|
|
await expect(activeLinkElm).toHaveText('Test');
|
|
expect(page.url()).toMatch(/\/test$/);
|
|
});
|
|
});
|