@@ -84,6 +84,12 @@ describe("readfile", () => {
84
84
expect ( base64Text ) . toEqual ( "aGVsbG8gd29ybGQh" ) ;
85
85
expect ( hexText ) . toEqual ( "68656c6c6f20776f726c6421" ) ;
86
86
} ) ;
87
+ it ( "should read a file as a string" , async ( ) => {
88
+ const text = await fs . readFile ( "fixtures/hello.txt" , { encoding : "utf-8" } ) ;
89
+
90
+ expect ( typeof text ) . toEqual ( "string" ) ;
91
+ expect ( text ) . toEqual ( "hello world!" ) ;
92
+ } ) ;
87
93
} ) ;
88
94
89
95
describe ( "mkdtemp" , ( ) => {
@@ -106,7 +112,7 @@ describe("mkdtemp", () => {
106
112
// Clean up the temporary directory
107
113
await fs . rmdir ( dirPath ) ;
108
114
} ) ;
109
- } )
115
+ } ) ;
110
116
111
117
describe ( "mkdtempSync" , ( ) => {
112
118
it ( "should create a temporary directory with a given prefix synchronously" , async ( ) => {
@@ -119,11 +125,11 @@ describe("mkdtempSync", () => {
119
125
. stat ( dirPath )
120
126
. then ( ( ) => true )
121
127
. catch ( ( ) => false ) ;
122
- expect ( dirExists ) . toBeTruthy ( )
128
+ expect ( dirExists ) . toBeTruthy ( ) ;
123
129
124
130
// Check that the directory has the correct prefix
125
131
const dirPrefix = path . basename ( dirPath ) . slice ( 0 , prefix . length ) ;
126
- expect ( dirPrefix ) . toStrictEqual ( prefix )
132
+ expect ( dirPrefix ) . toStrictEqual ( prefix ) ;
127
133
128
134
// Clean up the temporary directory
129
135
await fs . rmdir ( dirPath ) ;
@@ -155,7 +161,9 @@ describe("mkdir", () => {
155
161
156
162
describe ( "mkdirSync" , ( ) => {
157
163
it ( "should create a directory with the given path synchronously" , async ( ) => {
158
- const dirPath = defaultFsImport . mkdtempSync ( path . join ( os . tmpdir ( ) , "test/test-" ) ) ;
164
+ const dirPath = defaultFsImport . mkdtempSync (
165
+ path . join ( os . tmpdir ( ) , "test/test-" )
166
+ ) ;
159
167
160
168
//non recursive should reject
161
169
expect ( ( ) => defaultFsImport . mkdirSync ( dirPath ) ) . toThrow ( / [ f F ] i l e .* e x i s t s / ) ;
0 commit comments