@@ -6,37 +6,39 @@ const path = require('path')
6
6
const fs = require ( 'fs-then-native' )
7
7
const a = require ( 'assert' )
8
8
9
- const runner = new TestRunner ( )
9
+ /* needs to be sequence as `jsdoc.cache` is shared between tests */
10
+ const runner = new TestRunner ( { sequential : true } )
10
11
11
- runner . test ( '.explainSync({ files, cache: true })' , function ( ) {
12
+ runner . test ( 'caching: .explainSync({ files, cache: true })' , function ( ) {
12
13
const f = new Fixture ( 'class-all' )
13
14
jsdoc . cache . dir = 'tmp/cache-sync'
14
- jsdoc . cache . clear ( ) . catch ( err => { /* ignore */ } )
15
- const output = jsdoc . explainSync ( { files : f . sourcePath , cache : true } )
16
- const expectedOutput = f . getExpectedOutput ( output )
15
+ return jsdoc . cache . clear ( )
16
+ . then ( ( ) => {
17
+ const output = jsdoc . explainSync ( { files : f . sourcePath , cache : true } )
18
+ const expectedOutput = f . getExpectedOutput ( output )
17
19
18
- a . ok ( typeof output === 'object' )
19
- a . deepEqual ( output , expectedOutput )
20
+ a . ok ( typeof output === 'object' )
21
+ a . deepEqual ( output , expectedOutput )
22
+ } )
20
23
} )
21
24
22
- runner . test ( '.explain({ files, cache: true })' , function ( ) {
25
+ runner . test ( 'caching: .explain({ files, cache: true })' , function ( ) {
23
26
const f = new Fixture ( 'class-all' )
24
27
jsdoc . cache . dir = 'tmp/cache'
25
- jsdoc . cache . clear ( ) . catch ( err => { /* ignore */ } )
26
- return jsdoc . explain ( { files : f . sourcePath , cache : true } )
27
- . then ( function ( output ) {
28
- const cachedFiles = fs . readdirSync ( jsdoc . cache . dir )
29
- . map ( function ( file ) {
30
- return path . resolve ( jsdoc . cache . dir , file )
28
+ return jsdoc . cache . clear ( )
29
+ . then ( ( ) => {
30
+ return jsdoc . explain ( { files : f . sourcePath , cache : true } )
31
+ . then ( output => {
32
+ const cachedFiles = fs . readdirSync ( jsdoc . cache . dir )
33
+ . map ( file => path . resolve ( jsdoc . cache . dir , file ) )
34
+ a . strictEqual ( cachedFiles . length , 1 )
35
+ a . deepEqual ( output , f . getExpectedOutput ( output ) )
36
+ const cachedData = JSON . parse ( fs . readFileSync ( cachedFiles [ 0 ] , 'utf8' ) )
37
+ Fixture . removeFileSpecificData ( cachedData )
38
+ a . deepEqual (
39
+ cachedData ,
40
+ f . getExpectedOutput ( output )
41
+ )
31
42
} )
32
- a . strictEqual ( cachedFiles . length , 1 )
33
- a . deepEqual ( output , f . getExpectedOutput ( output ) )
34
- const cachedData = JSON . parse ( fs . readFileSync ( cachedFiles [ 0 ] , 'utf8' ) )
35
- Fixture . removeFileSpecificData ( cachedData )
36
- a . deepEqual (
37
- cachedData ,
38
- f . getExpectedOutput ( output )
39
- )
40
43
} )
41
- . catch ( function ( err ) { console . error ( err . stack ) } )
42
44
} )
0 commit comments