Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions test/parallel/test-fs-open-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,27 @@ assert.strictEqual(stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL);
('+ +a +r +w rw wa war raw r++ a++ w++ x +x x+ rx rx+ wxx wax xwx xxx')
.split(' ')
.forEach(function(flags) {
assert.throws(function() { stringToFlags(flags); });
assert.throws(
() => stringToFlags(flags),
new RegExp(`^Error: Unknown file open flag: ${escapeRegExp(flags)}`)
);
});

assert.throws(
() => stringToFlags({}),
/Unknown file open flag: \[object Object\]/
/^Error: Unknown file open flag: \[object Object\]$/
);

assert.throws(
() => stringToFlags(true),
/Unknown file open flag: true/
/^Error: Unknown file open flag: true$/
);

assert.throws(
() => stringToFlags(null),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

/Unknown file open flag: null/
/^Error: Unknown file open flag: null$/
);

function escapeRegExp(string) {
return string.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
}