File tree Expand file tree Collapse file tree 3 files changed +34
-7
lines changed
packages/docsify-server-renderer Expand file tree Collapse file tree 3 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -197,4 +197,6 @@ export default class Renderer {
197197 }
198198}
199199
200+ export { Renderer } ;
201+
200202Renderer . version = '__VERSION__' ;
Original file line number Diff line number Diff line change @@ -19,6 +19,19 @@ function ready(callback) {
1919 document . addEventListener ( 'DOMContentLoaded' , callback ) ;
2020}
2121
22+ module . exports . initJSDOM = initJSDOM ;
23+ function initJSDOM ( markup = '' ) {
24+ const dom = new JSDOM ( markup ) ;
25+
26+ global . window = dom . window ;
27+ global . document = dom . window . document ;
28+ global . navigator = dom . window . navigator ;
29+ global . location = dom . window . location ;
30+ global . XMLHttpRequest = dom . window . XMLHttpRequest ;
31+
32+ return dom ;
33+ }
34+
2235module . exports . init = function (
2336 fixture = 'default' ,
2437 config = { } ,
@@ -39,15 +52,9 @@ module.exports.init = function(
3952
4053 const rootPath = path . join ( __dirname , 'fixtures' , fixture ) ;
4154
42- const dom = new JSDOM ( markup ) ;
55+ const dom = initJSDOM ( markup ) ;
4356 dom . reconfigure ( { url : 'file:///' + rootPath } ) ;
4457
45- global . window = dom . window ;
46- global . document = dom . window . document ;
47- global . navigator = dom . window . navigator ;
48- global . location = dom . window . location ;
49- global . XMLHttpRequest = dom . window . XMLHttpRequest ;
50-
5158 // Mimic src/core/index.js but for Node.js
5259 function Docsify ( ) {
5360 this . _init ( ) ;
Original file line number Diff line number Diff line change 1+ // @ts -check
2+ /* eslint-disable no-global-assign */
3+ require = require ( 'esm' ) (
4+ module /* , options */
5+ ) ; /* eslint-disable-line no-global-assign */
6+ const { expect } = require ( 'chai' ) ;
7+ const { initJSDOM } = require ( '../_helper' ) ;
8+
9+ initJSDOM ( ) ;
10+
11+ const { Renderer } = require ( '../../packages/docsify-server-renderer/index' ) ;
12+
13+ describe ( 'pacakges/docsify-server-render' , function ( ) {
14+ it ( 'toURL' , function ( ) {
15+ expect ( Renderer ) . to . be . an . instanceof ( Function ) ;
16+ expect ( 'foo' ) . equal ( 'foo' ) ;
17+ } ) ;
18+ } ) ;
You can’t perform that action at this time.
0 commit comments