File tree 3 files changed +34
-7
lines changed
packages/docsify-server-renderer
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 {
197
197
}
198
198
}
199
199
200
+ export { Renderer } ;
201
+
200
202
Renderer . version = '__VERSION__' ;
Original file line number Diff line number Diff line change @@ -19,6 +19,19 @@ function ready(callback) {
19
19
document . addEventListener ( 'DOMContentLoaded' , callback ) ;
20
20
}
21
21
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
+
22
35
module . exports . init = function (
23
36
fixture = 'default' ,
24
37
config = { } ,
@@ -39,15 +52,9 @@ module.exports.init = function(
39
52
40
53
const rootPath = path . join ( __dirname , 'fixtures' , fixture ) ;
41
54
42
- const dom = new JSDOM ( markup ) ;
55
+ const dom = initJSDOM ( markup ) ;
43
56
dom . reconfigure ( { url : 'file:///' + rootPath } ) ;
44
57
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
-
51
58
// Mimic src/core/index.js but for Node.js
52
59
function Docsify ( ) {
53
60
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