-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(objects): add toHaveUndefined matcher
closes #37
- Loading branch information
1 parent
8a685b5
commit 3440f86
Showing
6 changed files
with
52 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
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,8 @@ | ||
// modules | ||
var toBeObject = require('./toBeObject'); | ||
var toHaveMember = require('./toHaveMember'); | ||
|
||
// public | ||
module.exports = function toHaveUndefined(key, actual) { | ||
return toBeObject(actual) && toHaveMember(key, actual) && typeof actual[key] === 'undefined'; | ||
}; |
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,25 @@ | ||
// modules | ||
var describeToHaveX = require('./lib/describeToHaveX'); | ||
|
||
// spec | ||
describe('toHaveUndefined', function () { | ||
describeToHaveX('toHaveUndefined', function () { | ||
describe('when subject IS undefined', function () { | ||
it('should confirm', function () { | ||
expect({ | ||
memberName: undefined | ||
}).toHaveUndefined('memberName'); | ||
}); | ||
}); | ||
describe('when subject is NOT undefined', function () { | ||
it('should deny', function () { | ||
expect({ | ||
memberName: null | ||
}).not.toHaveUndefined('memberName'); | ||
expect({ | ||
memberName: 'undefined' | ||
}).not.toHaveUndefined('memberName'); | ||
}); | ||
}); | ||
}); | ||
}); |