File tree Expand file tree Collapse file tree 1 file changed +18
-11
lines changed
Expand file tree Collapse file tree 1 file changed +18
-11
lines changed Original file line number Diff line number Diff line change 1- import { readFile , checkIfDirectory } from "../src/fileUtils" ;
1+ import { checkIfDirectory , readFile } from "../src/fileUtils" ;
22
33describe ( "File Utility" , ( ) => {
4-
5- test ( "Read File" , ( ) => {
6-
7- readFile ( "./examples/test.txt" ) . then ( ( data ) => {
8- expect ( data ) . toBe ( "Hello World" ) ;
9- } ) ;
10-
4+ test ( "Read File" , ( ) => {
5+ readFile ( "./examples/test.txt" ) . then ( ( data ) => {
6+ expect ( data ) . toBe ( "Hello World" ) ;
117 } ) ;
8+ } ) ;
129
13- test ( 'should return true if the path is a directory' , async ( ) => {
14- const result = await checkIfDirectory ( ' ./examples' ) ;
15- expect ( result ) . toBe ( true ) ;
10+ test ( "Read File Error, return null" , ( ) => {
11+ readFile ( " ./examples/does-not-exist.txt" ) . then ( ( data ) => {
12+ expect ( data ) . toBe ( null ) ;
1613 } ) ;
14+ } ) ;
15+
16+ test ( "should return true if the path is a directory" , async ( ) => {
17+ const result = await checkIfDirectory ( "./examples" ) ;
18+ expect ( result ) . toBe ( true ) ;
19+ } ) ;
1720
21+ test ( "should return false if the path is not a directory" , async ( ) => {
22+ const result = await checkIfDirectory ( "./examples/dummy-file.txt" ) ;
23+ expect ( result ) . toBe ( false ) ;
24+ } ) ;
1825} ) ;
You can’t perform that action at this time.
0 commit comments