mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-17 04:31:18 +08:00
fix: sidebar active class and expand don't work as expect when use "space" in markdown filename (#1454)
* fix: decode href in sidebar (#1032) * Create sidebar.test.js Co-authored-by: 沈唁 <52o@qq52o.cn>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
const docsifyInit = require('../helpers/docsify-init');
|
||||
|
||||
// Suite
|
||||
// -----------------------------------------------------------------------------
|
||||
describe('Sidebar Tests', function() {
|
||||
// Tests
|
||||
// ---------------------------------------------------------------------------
|
||||
test('Active Test', async () => {
|
||||
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
|
||||
`,
|
||||
},
|
||||
};
|
||||
|
||||
await docsifyInit(docsifyInitConfig);
|
||||
await page.click('a[href="#/test%20space"]');
|
||||
await expect(page).toEqualText(
|
||||
'.sidebar-nav li[class=active]',
|
||||
'Test Space'
|
||||
);
|
||||
expect(page.url()).toMatch(/\/test%20space$/);
|
||||
|
||||
await page.click('a[href="#/test_foo"]');
|
||||
await expect(page).toEqualText('.sidebar-nav li[class=active]', 'Test _');
|
||||
expect(page.url()).toMatch(/\/test_foo$/);
|
||||
|
||||
await page.click('a[href="#/test-foo"]');
|
||||
await expect(page).toEqualText('.sidebar-nav li[class=active]', 'Test -');
|
||||
expect(page.url()).toMatch(/\/test-foo$/);
|
||||
|
||||
await page.click('a[href="#/test.foo"]');
|
||||
await expect(page).toEqualText('.sidebar-nav li[class=active]', 'Test .');
|
||||
expect(page.url()).toMatch(/\/test.foo$/);
|
||||
|
||||
await page.click('a[href="#/test>foo"]');
|
||||
await expect(page).toEqualText('.sidebar-nav li[class=active]', 'Test >');
|
||||
expect(page.url()).toMatch(/\/test%3Efoo$/);
|
||||
|
||||
await page.click('a[href="#/test"]');
|
||||
await expect(page).toEqualText('.sidebar-nav li[class=active]', 'Test');
|
||||
expect(page.url()).toMatch(/\/test$/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user