@@ -27,18 +27,31 @@ test.serial("ui5 tree --full (generates project tree before output)", async (t)
27
27
28
28
test . serial ( "ui5 tree --json (output tree in json)" , async ( t ) => {
29
29
const jsonStringifySpy = sinon . spy ( JSON , "stringify" ) ;
30
+ const consoleStub = sinon . stub ( console , "log" ) ;
31
+
30
32
normalizer . generateDependencyTree . resolves ( { name : "sample" } ) ;
31
33
await tree . handler ( { json : true } ) ;
32
- t . is ( JSON . stringify . called , true , "retrieves dependency tree as json" ) ;
33
- jsonStringifySpy . restore ( ) ;
34
+
35
+ // Note: Some versions of Node.js seem to call stringify internally during this test
36
+ t . deepEqual ( jsonStringifySpy . called , true , "Stringify got called at least once" ) ;
37
+ t . deepEqual ( jsonStringifySpy . getCall ( jsonStringifySpy . callCount - 1 ) . args [ 0 ] , { name : "sample" } ,
38
+ "JSON.stringify called with correct argument" ) ;
39
+ t . deepEqual ( consoleStub . callCount , 1 , "console.log was called once" ) ;
40
+ t . deepEqual ( consoleStub . getCall ( 0 ) . args [ 0 ] , `{
41
+ "name": "sample"
42
+ }` , "console.log was called with correct argument" ) ;
34
43
} ) ;
35
44
36
45
test . serial ( "ui5 tree (output tree)" , async ( t ) => {
37
- const treeifySpy = sinon . spy ( treeify , "asTree" ) ;
46
+ const treeifySpy = sinon . stub ( treeify , "asTree" ) . returns ( "🌲" ) ;
47
+ const consoleStub = sinon . stub ( console , "log" ) ;
38
48
normalizer . generateDependencyTree . resolves ( { name : "sample" } ) ;
39
49
await tree . handler ( { } ) ;
40
- t . is ( treeify . asTree . called , true , "retrieves dependency tree using treeify" ) ;
41
- treeifySpy . restore ( ) ;
50
+
51
+ t . deepEqual ( treeifySpy . callCount , 1 , "Treeify called once" ) ;
52
+ t . deepEqual ( treeifySpy . getCall ( 0 ) . args [ 0 ] , { name : "sample" } , "Treeify called with correct argument" ) ;
53
+ t . deepEqual ( consoleStub . callCount , 1 , "console.log was called once" ) ;
54
+ t . deepEqual ( consoleStub . getCall ( 0 ) . args [ 0 ] , "🌲" , "console.log was called with correct argument" ) ;
42
55
} ) ;
43
56
44
57
test . serial ( "ui5 tree --dedupe=false (default)" , async ( t ) => {
0 commit comments