1
1
import test from "ava" ;
2
2
import sinon from "sinon" ;
3
+ import path from "node:path" ;
3
4
import versions from "../../../../lib/cli/commands/versions.js" ;
5
+ const __dirname = path . join ( import . meta. dirname , ".." ) ;
4
6
5
7
test . afterEach . always ( ( t ) => {
6
8
sinon . restore ( ) ;
@@ -20,6 +22,31 @@ test.serial("Retrieves version from package.json", (t) => {
20
22
t . is ( loggerVersion , "0.2.2" , "retrieved correct version for logger" ) ;
21
23
} ) ;
22
24
25
+ test . serial ( "Retrieves version and package path in verbose mode" , async ( t ) => {
26
+ const { setLogLevel} = await import ( "@ui5/logger" ) ;
27
+ setLogLevel ( "verbose" ) ;
28
+ const builderPath = "../../../test/fixtures/@ui5/builder" ;
29
+ const builderVersion = versions . getVersion ( builderPath ) ;
30
+ const serverPath = "../../../test/fixtures/@ui5/server" ;
31
+ const serverVersion = versions . getVersion ( serverPath ) ;
32
+ const fsPath = "../../../test/fixtures/@ui5/fs" ;
33
+ const fsVersion = versions . getVersion ( fsPath ) ;
34
+ const projectPath = "../../../test/fixtures/@ui5/project" ;
35
+ const projectVersion = versions . getVersion ( projectPath ) ;
36
+ const loggerPath = "../../../test/fixtures/@ui5/logger" ;
37
+ const loggerVersion = versions . getVersion ( loggerPath ) ;
38
+ t . is ( builderVersion , `0.2.6 (from ${ path . resolve ( __dirname , builderPath ) } )` ,
39
+ "retrieved correct version and path for builder" ) ;
40
+ t . is ( serverVersion , `0.2.2 (from ${ path . resolve ( __dirname , serverPath ) } )` ,
41
+ "retrieved correct version and path for server" ) ;
42
+ t . is ( fsVersion , `0.2.0 (from ${ path . resolve ( __dirname , fsPath ) } )` ,
43
+ "retrieved correct version and path for fs" ) ;
44
+ t . is ( projectVersion , `0.2.3 (from ${ path . resolve ( __dirname , projectPath ) } )` ,
45
+ "retrieved correct version and path for project" ) ;
46
+ t . is ( loggerVersion , `0.2.2 (from ${ path . resolve ( __dirname , loggerPath ) } )` ,
47
+ "retrieved correct version and path for logger" ) ;
48
+ } ) ;
49
+
23
50
test . serial ( "Error: returns not installed if version was not found" , ( t ) => {
24
51
t . is ( versions . getVersion ( "not/existing/path" ) , "===(not installed)" , "No version found" ) ;
25
52
} ) ;
0 commit comments