Skip to content

Commit

Permalink
test: add flag scenario in test-fs-write-file-sync
Browse files Browse the repository at this point in the history
fs.writeFileSync takes flag param to define the file opening
semantics. Add a scenario that covers flags as well.
  • Loading branch information
gireeshpunathil committed Dec 1, 2018
1 parent f34ca9f commit b4ac19e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/parallel/test-fs-write-file-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,12 @@ function closeSync() {
openCount--;
return fs._closeSync.apply(fs, arguments);
}

// Test writeFileSync with flags
const file4 = path.join(tmpdir.path, 'testWriteFileSyncFlags.txt');

fs.writeFileSync(file4, 'hello ', { encoding: 'utf8', flag: 'a' });
fs.writeFileSync(file4, 'world!', { encoding: 'utf8', flag: 'a' });

content = fs.readFileSync(file4, { encoding: 'utf8' });
assert.strictEqual(content, 'hello world!');

0 comments on commit b4ac19e

Please sign in to comment.