@@ -141,6 +141,34 @@ describe('Tree Containers', () => {
141141 env . stub ( fs , 'existsSync' ) . returns ( true ) ;
142142 expect ( tree . stream ( path ) ) . to . deep . equal ( readable ) ;
143143 } ) ;
144+
145+ describe ( 'with projectPath/cwd' , ( ) => {
146+ let projectPath : string ;
147+ // mocking fs will defeat the goal of these tests, so we'll use the real one and clean it up
148+ before ( async ( ) => {
149+ projectPath = join ( 'path' , 'to' , 'project' ) ;
150+ await fs . promises . mkdir ( projectPath , { recursive : true } ) ;
151+ await fs . promises . writeFile ( join ( projectPath , 'test.txt' ) , 'test' ) ;
152+ } ) ;
153+
154+ after ( async ( ) => {
155+ await fs . promises . rm ( projectPath , { recursive : true } ) ;
156+ } ) ;
157+
158+ it ( 'should return the path as is if it is already relative to the project path' , ( ) => {
159+ const tree = new NodeFSTreeContainer ( projectPath ) ;
160+ const path = join ( projectPath , 'test.txt' ) ;
161+ expect ( tree . exists ( path ) ) . to . be . true ;
162+ expect ( tree . readDirectory ( projectPath ) ) . to . deep . equal ( [ 'test.txt' ] ) ;
163+ } ) ;
164+
165+ it ( 'should add the project path to the path if it is not already relative to the project path' , ( ) => {
166+ const tree = new NodeFSTreeContainer ( projectPath ) ;
167+ const path = 'test.txt' ;
168+ expect ( tree . exists ( path ) ) . to . be . true ;
169+ expect ( tree . readDirectory ( projectPath ) ) . to . deep . equal ( [ 'test.txt' ] ) ;
170+ } ) ;
171+ } ) ;
144172 } ) ;
145173
146174 describe ( 'ZipTreeContainer' , ( ) => {
0 commit comments