unexpected-sinon
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -33,74 +33,77 @@ // Copyright (c) 2013 Sune Simonsen <sune@we-knowhow.dk> | ||
}(this, function (sinon) { | ||
return function (expect) { | ||
expect.addAssertion('was [not] called', function (expect, subject) { | ||
if (this.flags.not) { | ||
sinon.assert.notCalled(subject); | ||
} else { | ||
sinon.assert.called(subject); | ||
} | ||
}); | ||
return { | ||
name: 'unexpected-sinon', | ||
installInto: function (expect) { | ||
expect.addAssertion('was [not] called', function (expect, subject) { | ||
if (this.flags.not) { | ||
sinon.assert.notCalled(subject); | ||
} else { | ||
sinon.assert.called(subject); | ||
} | ||
}); | ||
expect.addAssertion('was called once', function (expect, subject) { | ||
sinon.assert.calledOnce(subject); | ||
}); | ||
expect.addAssertion('was called once', function (expect, subject) { | ||
sinon.assert.calledOnce(subject); | ||
}); | ||
expect.addAssertion('was called twice', function (expect, subject) { | ||
sinon.assert.calledTwice(subject); | ||
}); | ||
expect.addAssertion('was called twice', function (expect, subject) { | ||
sinon.assert.calledTwice(subject); | ||
}); | ||
expect.addAssertion('was called thrice', function (expect, subject) { | ||
sinon.assert.calledThrice(subject); | ||
}); | ||
expect.addAssertion('was called thrice', function (expect, subject) { | ||
sinon.assert.calledThrice(subject); | ||
}); | ||
expect.addAssertion('was called times', function (expect, subject, times) { | ||
sinon.assert.callCount(subject, times); | ||
}); | ||
expect.addAssertion('was called times', function (expect, subject, times) { | ||
sinon.assert.callCount(subject, times); | ||
}); | ||
expect.addAssertion('given call order', function (expect, subject) { | ||
sinon.assert.callOrder.apply(null, subject); | ||
}); | ||
expect.addAssertion('given call order', function (expect, subject) { | ||
sinon.assert.callOrder.apply(null, subject); | ||
}); | ||
expect.addAssertion('was [always] called on', function (expect, subject, target) { | ||
if (this.flags.always) { | ||
sinon.assert.alwaysCalledOn(subject, target); | ||
} else { | ||
sinon.assert.calledOn(subject, target); | ||
} | ||
}); | ||
expect.addAssertion('was [always] called on', function (expect, subject, target) { | ||
if (this.flags.always) { | ||
sinon.assert.alwaysCalledOn(subject, target); | ||
} else { | ||
sinon.assert.calledOn(subject, target); | ||
} | ||
}); | ||
expect.addAssertion('was [always] called with [exactly]', function (expect, subject) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
if (this.flags.always && this.flags.exactly) { | ||
sinon.assert.alwaysCalledWithExactly.apply(null, args); | ||
} else if (this.flags.always) { | ||
sinon.assert.alwaysCalledWith.apply(null, args); | ||
} else if (this.flags.exactly) { | ||
sinon.assert.calledWithExactly.apply(null, args); | ||
} else { | ||
sinon.assert.calledWith.apply(null, args); | ||
} | ||
}); | ||
expect.addAssertion('was [always] called with [exactly]', function (expect, subject) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
if (this.flags.always && this.flags.exactly) { | ||
sinon.assert.alwaysCalledWithExactly.apply(null, args); | ||
} else if (this.flags.always) { | ||
sinon.assert.alwaysCalledWith.apply(null, args); | ||
} else if (this.flags.exactly) { | ||
sinon.assert.calledWithExactly.apply(null, args); | ||
} else { | ||
sinon.assert.calledWith.apply(null, args); | ||
} | ||
}); | ||
expect.addAssertion('was never called with', function (expect, subject) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
sinon.assert.neverCalledWith.apply(null, args); | ||
}); | ||
expect.addAssertion('was never called with', function (expect, subject) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
sinon.assert.neverCalledWith.apply(null, args); | ||
}); | ||
expect.addAssertion('[always] threw', function (expect, subject, value) { | ||
if (this.flags.always) { | ||
sinon.assert.alwaysThrew(subject, value); | ||
} else { | ||
sinon.assert.threw(subject, value); | ||
} | ||
}); | ||
expect.addAssertion('[always] threw', function (expect, subject, value) { | ||
if (this.flags.always) { | ||
sinon.assert.alwaysThrew(subject, value); | ||
} else { | ||
sinon.assert.threw(subject, value); | ||
} | ||
}); | ||
expect.addAssertion('was [always] called with match', function (expect, subject) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
if (this.flags.always) { | ||
sinon.assert.alwaysCalledWithMatch.apply(null, args); | ||
} else { | ||
sinon.assert.calledWithMatch.apply(null, args); | ||
} | ||
}); | ||
expect.addAssertion('was [always] called with match', function (expect, subject) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
if (this.flags.always) { | ||
sinon.assert.alwaysCalledWithMatch.apply(null, args); | ||
} else { | ||
sinon.assert.calledWithMatch.apply(null, args); | ||
} | ||
}); | ||
} | ||
}; | ||
})); |
{ | ||
"name": "unexpected-sinon", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -24,7 +24,8 @@ "keywords": [ | ||
"peerDependencies": { | ||
"sinon": "*" | ||
"sinon": "*", | ||
"unexpected": "^5.0.0-beta35" | ||
}, | ||
"devDependencies": { | ||
"sinon": "=1.9.1", | ||
"unexpected": ">=3.0.0", | ||
"unexpected": "5.0.0-beta35", | ||
"mocha": "~1.9.0", | ||
@@ -31,0 +32,0 @@ "mocha-slow-reporter": "*", |
Sorry, the diff of this file is not supported yet
142070
5022
2