Skip to content

Commit 8362ed0

Browse files
committed
Remove unnecessary globals
1 parent b6d5407 commit 8362ed0

File tree

9 files changed

+21
-50
lines changed

9 files changed

+21
-50
lines changed

jest.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
const path = require('path');
21
const { globals: serverGlobals } = require('./test/config/server.js');
32

43
const sharedConfig = {
54
errorOnDeprecated: true,
65
globals: {
7-
...serverGlobals, // BLANK_URL, DOCS_URL, LIB_URL, NODE_MODULES_URL, TEST_HOST
8-
DOCS_PATH: path.resolve(__dirname, 'docs'),
9-
LIB_PATH: path.resolve(__dirname, 'lib'),
10-
SRC_PATH: path.resolve(__dirname, 'src'),
6+
...serverGlobals, // BLANK_URL, TEST_HOST
117
},
128
globalSetup: './test/config/jest.setup.js',
139
globalTeardown: './test/config/jest.teardown.js',

test/README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,7 @@
1414

1515
## Global Variables
1616

17-
### File paths
18-
19-
- `DOCS_PATH`: File path to `/docs` directory
20-
- `LIB_PATH`: File path to `/lib` directory
21-
- `SRC_PATH`: File path to `/src` directory
22-
23-
### URLs
24-
2517
- `BLANK_URL`: Test server route to virtual `_blank.html` file
26-
- `DOCS_URL`: Test server route to `/docs` directory
27-
- `LIB_URL`: Test server route to `/lib` directory
28-
- `NODE_MODULES_URL`: Test server route to `/node_modules` directory
2918
- `TEST_HOST`: Test server ip:port
3019

3120
## CLI commands

test/config/server.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,6 @@ module.exports = {
108108
get BLANK_URL() {
109109
return `${this.TEST_HOST}/_blank.html`;
110110
},
111-
get DOCS_URL() {
112-
return `${this.TEST_HOST}/docs`;
113-
},
114-
get LIB_URL() {
115-
return `${this.TEST_HOST}/lib`;
116-
},
117-
get NODE_MODULES_URL() {
118-
return `${this.TEST_HOST}/node_modules`;
119-
},
120111
TEST_HOST: `http://${serverConfig.host}:${serverConfig.port}`,
121112
},
122113
start: startServer,

test/e2e/example.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ describe(`Example Tests`, function() {
112112

113113
// Inject docsify theme (vue.css)
114114
// https://playwright.dev/#path=docs%2Fapi.md&q=pageaddstyletagoptions
115-
await page.addStyleTag({ url: `${LIB_URL}/themes/vue.css` });
115+
await page.addStyleTag({ url: '/lib/themes/vue.css' });
116116

117117
// Inject docsify.js
118118
// https://playwright.dev/#path=docs%2Fapi.md&q=pageaddscripttagoptions
119-
await page.addScriptTag({ url: `${LIB_URL}/docsify.js` });
119+
await page.addScriptTag({ url: '/lib/docsify.js' });
120120

121121
// Wait for docsify to initialize
122122
// https://playwright.dev/#path=docs%2Fapi.md&q=pagewaitforselectorselector-options

test/e2e/vue.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const stripIndent = require('common-tags/lib/stripIndent');
22
const docsifyInit = require('../helpers/docsify-init');
33

44
const vueURLs = [
5-
`${NODE_MODULES_URL}/vue2/dist/vue.js`,
6-
`${NODE_MODULES_URL}/vue3/dist/vue.global.js`,
5+
'/node_modules/vue2/dist/vue.js',
6+
'/node_modules/vue3/dist/vue.global.js',
77
];
88

99
describe('Vue.js Compatibility', function() {

test/helpers/docsify-init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const axios = require('axios');
66
const prettier = require('prettier');
77
const stripIndent = require('common-tags/lib/stripIndent');
88

9-
const docsifyPATH = `${LIB_PATH}/docsify.js`; // JSDOM
10-
const docsifyURL = `${LIB_URL}/docsify.js`; // Playwright
9+
const docsifyPATH = '../../lib/docsify.js'; // JSDOM
10+
const docsifyURL = '/lib/docsify.js'; // Playwright
1111
const isJSDOM = 'window' in global;
1212
const isPlaywright = 'page' in global;
1313

test/integration/docs.test.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const fs = require('fs').promises;
2-
const path = require('path');
31
const docsifyInit = require('../helpers/docsify-init');
42

53
// Suite
@@ -13,14 +11,13 @@ describe('Docs Site', function() {
1311
const mathSpy = jest.spyOn(Math, 'random').mockReturnValue(0.5);
1412

1513
await docsifyInit({
14+
config: {
15+
coverpage: 'docs/_coverpage.md',
16+
},
1617
markdown: {
1718
homepage: '# Hello World',
18-
coverpage: await fs.readFile(
19-
path.resolve(DOCS_PATH, '_coverpage.md'),
20-
'utf8'
21-
),
2219
},
23-
// _logHTML: true,
20+
waitForSelector: '.cover.show',
2421
});
2522

2623
const coverpageElm = document.querySelector('section.cover');
@@ -33,14 +30,13 @@ describe('Docs Site', function() {
3330

3431
test('sidebar renders and is unchanged', async () => {
3532
await docsifyInit({
33+
config: {
34+
loadSidebar: 'docs/_sidebar.md',
35+
},
3636
markdown: {
3737
homepage: '# Hello World',
38-
sidebar: await fs.readFile(
39-
path.resolve(DOCS_PATH, '_sidebar.md'),
40-
'utf8'
41-
),
4238
},
43-
// _logHTML: true,
39+
waitForSelector: '.sidebar-nav > ul',
4440
});
4541

4642
const sidebarElm = document.querySelector('.sidebar');
@@ -52,14 +48,13 @@ describe('Docs Site', function() {
5248

5349
test('navbar renders and is unchanged', async () => {
5450
await docsifyInit({
51+
config: {
52+
loadNavbar: 'docs/_navbar.md',
53+
},
5554
markdown: {
5655
homepage: '# Hello World',
57-
navbar: await fs.readFile(
58-
path.resolve(DOCS_PATH, '_navbar.md'),
59-
'utf8'
60-
),
6156
},
62-
// _logHTML: true,
57+
waitForSelector: '.app-nav > ul',
6358
});
6459

6560
const navbarElm = document.querySelector('nav.app-nav');

test/unit/router-history-base.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { History } = require(`${SRC_PATH}/core/router/history/base`);
1+
const { History } = require('../../src/core/router/history/base');
22

33
class MockHistory extends History {
44
parse(path) {

test/unit/router-util.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { resolvePath } = require(`${SRC_PATH}/core/util`);
1+
const { resolvePath } = require('../../src/core/util');
22

33
// Suite
44
// -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)