Skip to content

Commit aaa4edd

Browse files
committed
fs: add tests for writeFileSync with no flag
1 parent c323642 commit aaa4edd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎test/parallel/test-fs-write-file-sync.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@ tmpdir.refresh();
101101
assert.strictEqual(content,'hello world!');
102102
}
103103

104+
// Test writeFileSync with no flags
105+
{
106+
constutf8Data='hello world!';
107+
for(consttestof[
108+
{data: utf8Data},
109+
{data: utf8Data,options: {encoding: 'utf8'}},
110+
{data: Buffer.from(utf8Data,'utf8').toString('hex'),options: {encoding: 'hex'}},
111+
]){
112+
constfile=tmpdir.resolve(`testWriteFileSyncNewFile_${Math.random()}.txt`);
113+
fs.writeFileSync(file,test.data,test.options);
114+
115+
constcontent=fs.readFileSync(file,{encoding: 'utf-8'});
116+
assert.strictEqual(content,utf8Data);
117+
}
118+
}
119+
104120
// Test writeFileSync with an invalid input
105121
{
106122
constfile=tmpdir.resolve('testWriteFileSyncInvalid.txt');

0 commit comments

Comments
(0)