File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -140,8 +140,8 @@ exports.isCypressProjDirValid = (cypressDir, cypressProjDir) => {
140
140
// Getting absolute path
141
141
cypressDir = path . resolve ( cypressDir ) ;
142
142
cypressProjDir = path . resolve ( cypressProjDir ) ;
143
-
144
143
if ( cypressProjDir === cypressDir ) return true ;
145
- let parentTokens = cypressDir . split ( '/' ) . filter ( i => i . length )
146
- return parentTokens . every ( ( t , i ) => cypressProjDir . split ( '/' ) [ i ] === t )
144
+ let parentTokens = cypressDir . split ( '/' ) . filter ( i => i . length ) ;
145
+ let childTokens = cypressProjDir . split ( '/' ) . filter ( i => i . length ) ;
146
+ return parentTokens . every ( ( t , i ) => childTokens [ i ] === t ) ;
147
147
}
Original file line number Diff line number Diff line change @@ -236,4 +236,18 @@ describe("utils", () => {
236
236
sinon . assert . calledOnce ( sendUsageReportStub ) ;
237
237
} ) ;
238
238
} ) ;
239
+
240
+ describe ( "isCypressProjDirValid" , ( ) => {
241
+ it ( "should return true when cypressDir and cypressProjDir is same" , ( ) => {
242
+ expect ( utils . isCypressProjDirValid ( "/absolute/path" , "/absolute/path" ) ) . to . be . true ;
243
+ } ) ;
244
+
245
+ it ( "should return true when cypressProjDir is child directory of cypressDir" , ( ) => {
246
+ expect ( utils . isCypressProjDirValid ( "/absolute/path" , "/absolute/path/childpath" ) ) . to . be . true ;
247
+ } ) ;
248
+
249
+ it ( "should return false when cypressProjDir is not child directory of cypressDir" , ( ) => {
250
+ expect ( utils . isCypressProjDirValid ( "/absolute/path" , "/absolute" ) ) . to . be . false ;
251
+ } ) ;
252
+ } ) ;
239
253
} ) ;
You can’t perform that action at this time.
0 commit comments