11import { expect } from "chai" ;
22import { join } from "path" ;
3+ import { homedir } from "os" ;
34import {
45 findAppRoot ,
56 getLocalAnnotationsForService ,
@@ -31,8 +32,8 @@ describe("project", () => {
3132 testFramework = new TestFramework ( useConfig ) ;
3233 } ) ;
3334 context ( "getProjectRoot" , ( ) => {
34- it ( "throws exception and return undefined " , async ( ) => {
35- const result = await getProjectRoot ( __dirname ) ;
35+ it ( "return undefined when no package.json is found " , async ( ) => {
36+ const result = await getProjectRoot ( homedir ( ) ) ;
3637 expect ( result ) . to . be . undefined ;
3738 } ) ;
3839 it ( "return project root " , async ( ) => {
@@ -42,6 +43,19 @@ describe("project", () => {
4243 const result = await getProjectRoot ( docPath ) ;
4344 expect ( result ) . to . equal ( projectRoot ) ;
4445 } ) ;
46+ it ( "free style project" , async ( ) => {
47+ const framework = new TestFramework ( {
48+ projectInfo : {
49+ name : ProjectName . tsFreeStyle ,
50+ type : ProjectType . UI5 ,
51+ npmInstall : false ,
52+ } ,
53+ } ) ;
54+ const projectRoot = framework . getProjectRoot ( ) ;
55+ const documentPath = join ( projectRoot , "src" , "view" , "Main.view.xml" ) ;
56+ const result = await getProjectRoot ( documentPath ) ;
57+ expect ( result ) . to . equal ( projectRoot ) ;
58+ } ) ;
4559 } ) ;
4660 context ( "getProjectInfo" , ( ) => {
4761 it ( "undefined" , async ( ) => {
0 commit comments