unexpected
Advanced tools
Comparing version 5.0.0-beta8 to 5.0.0-beta9
@@ -507,2 +507,21 @@ var utils = require('./utils'); | ||
expect.addAssertion('Error', 'to [exhaustively] satisfy [assertion]', function (expect, subject, value) { | ||
var valueType = expect.findTypeOf(value); | ||
if (valueType.is('Error')) { | ||
expect(subject, 'to equal', value); | ||
} else if (valueType.is('object')) { | ||
var keys = valueType.getKeys(value); | ||
keys.forEach(function (key) { | ||
expect(subject[key], 'to [exhaustively] satisfy', value[key]); | ||
}); | ||
if (this.flags.exhaustively) { | ||
expect(utils.getKeysOfDefinedProperties(subject), 'to have length', keys.filter(function (key) { | ||
return typeof value[key] !== 'undefined'; | ||
}).length); | ||
} | ||
} else { | ||
expect(subject.message, 'to [exhaustively] satisfy', value); | ||
} | ||
}); | ||
expect.addAssertion('[not] to [exhaustively] satisfy [assertion]', function (expect, subject, value) { | ||
@@ -532,7 +551,8 @@ if (this.flags.not) { | ||
expect(subject, 'to be an object'); | ||
type.getKeys(value).forEach(function (key) { | ||
var keys = type.getKeys(value); | ||
keys.forEach(function (key) { | ||
expect(subject[key], 'to [exhaustively] satisfy', value[key]); | ||
}); | ||
if (this.flags.exhaustively) { | ||
expect(subject, 'to only have keys', Object.keys(value)); | ||
expect(subject, 'to only have keys', keys); | ||
} | ||
@@ -539,0 +559,0 @@ } catch (e) { |
{ | ||
"name": "unexpected", | ||
"version": "5.0.0-beta8", | ||
"version": "5.0.0-beta9", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1143897
10614