-
-
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
6f0e7d5
commit 443dc76
Showing
6 changed files
with
60 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,33 @@ | ||
// modules | ||
var describeToHaveX = require('./lib/describeToHaveX'); | ||
|
||
// spec | ||
describe('toHaveUndefined', function () { | ||
describeToHaveX('toHaveUndefined', function () { | ||
describe('when subject does NOT have a member at the given key', () => { | ||
it('should deny', function () { | ||
expect({}).not.toHaveUndefined('memberName'); | ||
expect(null).not.toHaveUndefined('memberName'); | ||
}); | ||
}); | ||
describe('when subject DOES have a member at the given key', () => { | ||
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'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |