From 92c6810b22abd6f0f9bf2005fc92ddf2aaf9b8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Fri, 18 Dec 2020 09:39:09 +0800 Subject: [PATCH] Create sidebar.test.js --- test/e2e/sidebar.test.js | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 test/e2e/sidebar.test.js diff --git a/test/e2e/sidebar.test.js b/test/e2e/sidebar.test.js new file mode 100644 index 000000000..d289d1cbc --- /dev/null +++ b/test/e2e/sidebar.test.js @@ -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$/); + }); +});