unexpected-sinon
Advanced tools
Comparing version 10.3.0 to 10.4.0
@@ -159,2 +159,13 @@ /*global location*/ | ||
expect.addType({ | ||
name: 'sinonSandbox', | ||
base: 'object', | ||
identify: function (obj) { | ||
return obj && typeof obj === 'object' && typeof obj.useFakeTimers === 'function' && typeof obj.restore === 'function'; | ||
}, | ||
inspect: function (value, depth, output, inspect) { | ||
output.jsFunctionName('sinon sandbox'); | ||
} | ||
}); | ||
expect.addType({ | ||
name: 'spyCall', | ||
@@ -413,7 +424,12 @@ base: 'object', | ||
expect.addAssertion('<spy|array> to have calls [exhaustively] satisfying <function>', function (expect, subject, value) { | ||
var spies = subject; | ||
if (!Array.isArray(spies)) { | ||
spies = [ spies ]; | ||
function extractSpies(spyOrArrayOrSinonSandbox) { | ||
if (expect.findTypeOf(spyOrArrayOrSinonSandbox).is('sinonSandbox')) { | ||
return spyOrArrayOrSinonSandbox.fakes || []; | ||
} else { | ||
return Array.isArray(spyOrArrayOrSinonSandbox) ? spyOrArrayOrSinonSandbox : [ spyOrArrayOrSinonSandbox ]; | ||
} | ||
} | ||
expect.addAssertion('<spy|array|sinonSandbox> to have calls [exhaustively] satisfying <function>', function (expect, subject, value) { | ||
var spies = extractSpies(subject); | ||
var expectedSpyCallSpecs = recordSpyCalls(spies, value); | ||
@@ -432,7 +448,4 @@ var expectedSpyCalls = []; | ||
expect.addAssertion('<spy|array> to have calls [exhaustively] satisfying <array|object>', function (expect, subject, value) { | ||
var spies = subject; | ||
if (!Array.isArray(spies)) { | ||
spies = [ spies ]; | ||
} | ||
expect.addAssertion('<spy|array|sinonSandbox> to have calls [exhaustively] satisfying <array|object>', function (expect, subject, value) { | ||
var spies = extractSpies(subject); | ||
var spyCalls = []; | ||
@@ -549,3 +562,3 @@ var isSeenBySpyId = {}; | ||
expect.addAssertion('<spy> to have a call [exhaustively] satisfying <object>', function (expect, subject, value) { | ||
expect.addAssertion('<spy|array|sinonSandbox> to have a call [exhaustively] satisfying <object>', function (expect, subject, value) { | ||
var keys = Object.keys(value); | ||
@@ -562,3 +575,5 @@ if ( | ||
expect.errorMode = 'defaultOrNested'; | ||
var calls = getCalls(subject); | ||
// Get a flattened array of all calls to all the specified spies: | ||
var calls = Array.prototype.concat.apply([], extractSpies(subject).map(getCalls)); | ||
var promises = calls.map(function (call) { | ||
@@ -580,8 +595,8 @@ return expect.promise(function () { | ||
expect.addAssertion('<spy> to have a call [exhaustively] satisfying <array>', function (expect, subject, value) { | ||
expect.addAssertion('<spy|array|sinonSandbox> to have a call [exhaustively] satisfying <array>', function (expect, subject, value) { | ||
return expect(subject, 'to have a call [exhaustively] satisfying', { args: value }); | ||
}); | ||
expect.addAssertion('<spy> to have a call satisfying <function>', function (expect, subject, value) { | ||
var expectedSpyCallSpecs = recordSpyCalls([subject], value); | ||
expect.addAssertion('<spy|array|sinonSandbox> to have a call satisfying <function>', function (expect, subject, value) { | ||
var expectedSpyCallSpecs = recordSpyCalls(extractSpies(subject), value); | ||
var expectedSpyCalls = []; | ||
@@ -588,0 +603,0 @@ expectedSpyCallSpecs.forEach(function (expectedSpyCallSpec) { |
{ | ||
"name": "unexpected-sinon", | ||
"version": "10.3.0", | ||
"version": "10.4.0", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
376226
6689