Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce isUndefined, deprecate defined (#93)
* feat(isUndefined): add new assetion isUndefined check if an actual value is undefined See: #89 #87 * chore: update commons package to use deprecated wrapper * deprecate(defined): add warning wrapper
- Loading branch information
Showing
8 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
var actualAndTypeOfMessageValues = require("../actual-and-type-of-message-values"); | ||
|
||
module.exports = function(referee) { | ||
referee.add("isUndefined", { | ||
assert: function(actual) { | ||
return typeof actual === "undefined"; | ||
}, | ||
assertMessage: | ||
"${customMessage}Expected ${actual} (${actualType}) to be undefined", | ||
refuteMessage: | ||
"${customMessage}Expected ${actual} (${actualType}) not to be undefined", | ||
expectation: "toBeUndefined", | ||
values: actualAndTypeOfMessageValues | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use strict"; | ||
|
||
var testHelper = require("../test-helper"); | ||
|
||
testHelper.assertionTests("assert", "isUndefined", function( | ||
pass, | ||
fail, | ||
msg, | ||
error | ||
) { | ||
fail("for array", {}); | ||
fail("for boolean", true); | ||
fail("for function", function() {}); | ||
fail("for null", null); | ||
fail("for number", 42); | ||
fail("for object", {}); | ||
fail("for string", "Test"); | ||
pass("for undefined", undefined); | ||
msg( | ||
"fail with descriptive message", | ||
"[assert.isUndefined] Expected null (object) to be undefined", | ||
null | ||
); | ||
msg( | ||
"fail with custom message", | ||
"[assert.isUndefined] fails: Expected null (object) to be undefined", | ||
null, | ||
"fails" | ||
); | ||
error( | ||
"for null", | ||
{ | ||
code: "ERR_ASSERTION", | ||
operator: "assert.isUndefined" | ||
}, | ||
null | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters