Skip to content

Commit

Permalink
Create sidebar.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored Dec 18, 2020
1 parent 12f9d03 commit 92c6810
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions test/e2e/sidebar.test.js
Original file line number Diff line number Diff line change
@@ -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$/);
});
});

0 comments on commit 92c6810

Please sign in to comment.