mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-17 04:31:18 +08:00
Remove unnecessary globals
This commit is contained in:
+1
-5
@@ -1,13 +1,9 @@
|
||||
const path = require('path');
|
||||
const { globals: serverGlobals } = require('./test/config/server.js');
|
||||
|
||||
const sharedConfig = {
|
||||
errorOnDeprecated: true,
|
||||
globals: {
|
||||
...serverGlobals, // BLANK_URL, DOCS_URL, LIB_URL, NODE_MODULES_URL, TEST_HOST
|
||||
DOCS_PATH: path.resolve(__dirname, 'docs'),
|
||||
LIB_PATH: path.resolve(__dirname, 'lib'),
|
||||
SRC_PATH: path.resolve(__dirname, 'src'),
|
||||
...serverGlobals, // BLANK_URL, TEST_HOST
|
||||
},
|
||||
globalSetup: './test/config/jest.setup.js',
|
||||
globalTeardown: './test/config/jest.teardown.js',
|
||||
|
||||
@@ -14,18 +14,7 @@
|
||||
|
||||
## Global Variables
|
||||
|
||||
### File paths
|
||||
|
||||
- `DOCS_PATH`: File path to `/docs` directory
|
||||
- `LIB_PATH`: File path to `/lib` directory
|
||||
- `SRC_PATH`: File path to `/src` directory
|
||||
|
||||
### URLs
|
||||
|
||||
- `BLANK_URL`: Test server route to virtual `_blank.html` file
|
||||
- `DOCS_URL`: Test server route to `/docs` directory
|
||||
- `LIB_URL`: Test server route to `/lib` directory
|
||||
- `NODE_MODULES_URL`: Test server route to `/node_modules` directory
|
||||
- `TEST_HOST`: Test server ip:port
|
||||
|
||||
## CLI commands
|
||||
|
||||
@@ -108,15 +108,6 @@ module.exports = {
|
||||
get BLANK_URL() {
|
||||
return `${this.TEST_HOST}/_blank.html`;
|
||||
},
|
||||
get DOCS_URL() {
|
||||
return `${this.TEST_HOST}/docs`;
|
||||
},
|
||||
get LIB_URL() {
|
||||
return `${this.TEST_HOST}/lib`;
|
||||
},
|
||||
get NODE_MODULES_URL() {
|
||||
return `${this.TEST_HOST}/node_modules`;
|
||||
},
|
||||
TEST_HOST: `http://${serverConfig.host}:${serverConfig.port}`,
|
||||
},
|
||||
start: startServer,
|
||||
|
||||
@@ -112,11 +112,11 @@ describe(`Example Tests`, function() {
|
||||
|
||||
// Inject docsify theme (vue.css)
|
||||
// https://playwright.dev/#path=docs%2Fapi.md&q=pageaddstyletagoptions
|
||||
await page.addStyleTag({ url: `${LIB_URL}/themes/vue.css` });
|
||||
await page.addStyleTag({ url: '/lib/themes/vue.css' });
|
||||
|
||||
// Inject docsify.js
|
||||
// https://playwright.dev/#path=docs%2Fapi.md&q=pageaddscripttagoptions
|
||||
await page.addScriptTag({ url: `${LIB_URL}/docsify.js` });
|
||||
await page.addScriptTag({ url: '/lib/docsify.js' });
|
||||
|
||||
// Wait for docsify to initialize
|
||||
// https://playwright.dev/#path=docs%2Fapi.md&q=pagewaitforselectorselector-options
|
||||
|
||||
@@ -2,8 +2,8 @@ const stripIndent = require('common-tags/lib/stripIndent');
|
||||
const docsifyInit = require('../helpers/docsify-init');
|
||||
|
||||
const vueURLs = [
|
||||
`${NODE_MODULES_URL}/vue2/dist/vue.js`,
|
||||
`${NODE_MODULES_URL}/vue3/dist/vue.global.js`,
|
||||
'/node_modules/vue2/dist/vue.js',
|
||||
'/node_modules/vue3/dist/vue.global.js',
|
||||
];
|
||||
|
||||
describe('Vue.js Compatibility', function() {
|
||||
|
||||
@@ -6,8 +6,8 @@ const axios = require('axios');
|
||||
const prettier = require('prettier');
|
||||
const stripIndent = require('common-tags/lib/stripIndent');
|
||||
|
||||
const docsifyPATH = `${LIB_PATH}/docsify.js`; // JSDOM
|
||||
const docsifyURL = `${LIB_URL}/docsify.js`; // Playwright
|
||||
const docsifyPATH = '../../lib/docsify.js'; // JSDOM
|
||||
const docsifyURL = '/lib/docsify.js'; // Playwright
|
||||
const isJSDOM = 'window' in global;
|
||||
const isPlaywright = 'page' in global;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
const docsifyInit = require('../helpers/docsify-init');
|
||||
|
||||
// Suite
|
||||
@@ -13,14 +11,13 @@ describe('Docs Site', function() {
|
||||
const mathSpy = jest.spyOn(Math, 'random').mockReturnValue(0.5);
|
||||
|
||||
await docsifyInit({
|
||||
config: {
|
||||
coverpage: 'docs/_coverpage.md',
|
||||
},
|
||||
markdown: {
|
||||
homepage: '# Hello World',
|
||||
coverpage: await fs.readFile(
|
||||
path.resolve(DOCS_PATH, '_coverpage.md'),
|
||||
'utf8'
|
||||
),
|
||||
},
|
||||
// _logHTML: true,
|
||||
waitForSelector: '.cover.show',
|
||||
});
|
||||
|
||||
const coverpageElm = document.querySelector('section.cover');
|
||||
@@ -33,14 +30,13 @@ describe('Docs Site', function() {
|
||||
|
||||
test('sidebar renders and is unchanged', async () => {
|
||||
await docsifyInit({
|
||||
config: {
|
||||
loadSidebar: 'docs/_sidebar.md',
|
||||
},
|
||||
markdown: {
|
||||
homepage: '# Hello World',
|
||||
sidebar: await fs.readFile(
|
||||
path.resolve(DOCS_PATH, '_sidebar.md'),
|
||||
'utf8'
|
||||
),
|
||||
},
|
||||
// _logHTML: true,
|
||||
waitForSelector: '.sidebar-nav > ul',
|
||||
});
|
||||
|
||||
const sidebarElm = document.querySelector('.sidebar');
|
||||
@@ -52,14 +48,13 @@ describe('Docs Site', function() {
|
||||
|
||||
test('navbar renders and is unchanged', async () => {
|
||||
await docsifyInit({
|
||||
config: {
|
||||
loadNavbar: 'docs/_navbar.md',
|
||||
},
|
||||
markdown: {
|
||||
homepage: '# Hello World',
|
||||
navbar: await fs.readFile(
|
||||
path.resolve(DOCS_PATH, '_navbar.md'),
|
||||
'utf8'
|
||||
),
|
||||
},
|
||||
// _logHTML: true,
|
||||
waitForSelector: '.app-nav > ul',
|
||||
});
|
||||
|
||||
const navbarElm = document.querySelector('nav.app-nav');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { History } = require(`${SRC_PATH}/core/router/history/base`);
|
||||
const { History } = require('../../src/core/router/history/base');
|
||||
|
||||
class MockHistory extends History {
|
||||
parse(path) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { resolvePath } = require(`${SRC_PATH}/core/util`);
|
||||
const { resolvePath } = require('../../src/core/util');
|
||||
|
||||
// Suite
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user