@@ -27,18 +27,31 @@ test.serial("ui5 tree --full (generates project tree before output)", async (t)
2727
2828test . serial ( "ui5 tree --json (output tree in json)" , async ( t ) => {
2929 const jsonStringifySpy = sinon . spy ( JSON , "stringify" ) ;
30+ const consoleStub = sinon . stub ( console , "log" ) ;
31+
3032 normalizer . generateDependencyTree . resolves ( { name : "sample" } ) ;
3133 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" ) ;
3443} ) ;
3544
3645test . 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" ) ;
3848 normalizer . generateDependencyTree . resolves ( { name : "sample" } ) ;
3949 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" ) ;
4255} ) ;
4356
4457test . serial ( "ui5 tree --dedupe=false (default)" , async ( t ) => {
0 commit comments