Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
test: validate common property usage
`common` contains multiple 'check'(boolean) properties that will be
false if mistyped and may lead to errors.
This makes sure that the used property exists in the `common`.
  • Loading branch information
lundibundi committed Feb 24, 2020
commit 1badb1582e1586fc071f68a315cc03d0bb6cee92
11 changes: 10 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ function invalidArgTypeHelper(input) {
return ` Received type ${typeof input} (${inspected})`;
}

module.exports = {
const common = {
allowGlobals,
buildType,
canCreateSymLink,
Expand Down Expand Up @@ -815,3 +815,12 @@ module.exports = {
}

};

const validProperties = new Set(Object.keys(common));
module.exports = new Proxy(common, {
get(obj, prop) {
if (!validProperties.has(prop))
throw new Error(`Using invalid common property: '${prop}'`);
return obj[prop];
}
});