@@ -457,17 +457,40 @@ describe("isFile", () => {
457
457
afterEach ( async ( ) => {
458
458
await fs . rm ( testDir , { recursive : true , force : true } )
459
459
} )
460
- it ( "should return false if the path doesn't exist " , async ( ) => {
460
+ it ( "should return false if is directory " , async ( ) => {
461
461
expect ( await util . isFile ( testDir ) ) . toBe ( false )
462
462
} )
463
463
it ( "should return true if is file" , async ( ) => {
464
464
expect ( await util . isFile ( pathToFile ) ) . toBe ( true )
465
465
} )
466
- it ( "should return false if error " , async ( ) => {
466
+ it ( "should return false if the path doesn't exist " , async ( ) => {
467
467
expect ( await util . isFile ( "fakefile.txt" ) ) . toBe ( false )
468
468
} )
469
469
} )
470
470
471
+ describe ( "isDirectory" , ( ) => {
472
+ const testDir = path . join ( tmpdir , "tests" , "isDirectory" )
473
+ let pathToFile = ""
474
+
475
+ beforeEach ( async ( ) => {
476
+ pathToFile = path . join ( testDir , "foo.txt" )
477
+ await fs . mkdir ( testDir , { recursive : true } )
478
+ await fs . writeFile ( pathToFile , "hello" )
479
+ } )
480
+ afterEach ( async ( ) => {
481
+ await fs . rm ( testDir , { recursive : true , force : true } )
482
+ } )
483
+ it ( "should return false if is a file" , async ( ) => {
484
+ expect ( await util . isDirectory ( pathToFile ) ) . toBe ( false )
485
+ } )
486
+ it ( "should return true if is directory" , async ( ) => {
487
+ expect ( await util . isDirectory ( testDir ) ) . toBe ( true )
488
+ } )
489
+ it ( "should return false if the path doesn't exist" , async ( ) => {
490
+ expect ( await util . isDirectory ( "fakefile.txt" ) ) . toBe ( false )
491
+ } )
492
+ } )
493
+
471
494
describe ( "humanPath" , ( ) => {
472
495
it ( "should return an empty string if no path provided" , ( ) => {
473
496
const mockHomedir = "/home/coder"
0 commit comments