Skip to content

Commit

Permalink
Fix regression in .toImplement when dealing with falsy values.
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Feb 4, 2016
1 parent 0fe7909 commit 8f5c98b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions dist/jasmine-matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1707,8 +1707,8 @@
81: [function(require, module, exports) {
'use strict';

var is = require('./lib/is');
var toBeObject = require('./toBeObject');
var toHaveMember = require('./toHaveMember');

module.exports = toImplement;

Expand All @@ -1720,16 +1720,16 @@

function featuresAll(api, actual) {
for (var key in api) {
if (!actual[key] || actual[key].constructor !== api[key]) {
if (!toHaveMember(key, actual) || actual[key].constructor !== api[key]) {
return false;
}
}
return true;
}

}, {
'./lib/is': 8,
'./toBeObject': 36
'./toBeObject': 36,
'./toHaveMember': 65
}],
82: [function(require, module, exports) {
'use strict';
Expand Down
4 changes: 2 additions & 2 deletions src/toImplement.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var is = require('./lib/is');
var toBeObject = require('./toBeObject');
var toHaveMember = require('./toHaveMember');

module.exports = toImplement;

Expand All @@ -13,7 +13,7 @@ function toImplement(api, actual) {

function featuresAll(api, actual) {
for (var key in api) {
if (!actual[key] || actual[key].constructor !== api[key]) {
if (!toHaveMember(key, actual) || actual[key].constructor !== api[key]) {
return false;
}
}
Expand Down
9 changes: 6 additions & 3 deletions test/toImplement.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ describe('toImplement', function() {
it('should confirm', function() {
expect({
a: 1,
b: 2
b: 0,
c: false
}).toImplement({
a: Number,
b: Number
b: Number,
c: Boolean
});
expect({
a: 1,
b: 2
b: 0,
c: false
}).toImplement({
a: Number
});
Expand Down

0 comments on commit 8f5c98b

Please sign in to comment.