mirror of
https://github.com/chaijs/chai
synced 2024-11-14 15:57:10 +00:00
Add delta message to closeTo() error
This commit is contained in:
parent
1cededa167
commit
8d6330cc04
3 changed files with 12 additions and 2 deletions
3
chai.js
3
chai.js
|
@ -3311,8 +3311,9 @@ module.exports = function (chai, _) {
|
|||
new Assertion(obj, flagMsg, ssfi, true).is.a('number');
|
||||
if (typeof expected !== 'number' || typeof delta !== 'number') {
|
||||
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
||||
var deltaMessage = delta === undefined ? ", and a delta is required" : "";
|
||||
throw new AssertionError(
|
||||
flagMsg + 'the arguments to closeTo or approximately must be numbers',
|
||||
flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage,
|
||||
undefined,
|
||||
ssfi
|
||||
);
|
||||
|
|
|
@ -2950,8 +2950,9 @@ module.exports = function (chai, _) {
|
|||
new Assertion(obj, flagMsg, ssfi, true).is.a('number');
|
||||
if (typeof expected !== 'number' || typeof delta !== 'number') {
|
||||
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
||||
var deltaMessage = delta === undefined ? ", and a delta is required" : "";
|
||||
throw new AssertionError(
|
||||
flagMsg + 'the arguments to closeTo or approximately must be numbers',
|
||||
flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage,
|
||||
undefined,
|
||||
ssfi
|
||||
);
|
||||
|
|
|
@ -1848,6 +1848,10 @@ describe('assert', function () {
|
|||
err(function() {
|
||||
assert.closeTo(1.5, 1.0, true, 'blah');
|
||||
}, "blah: the arguments to closeTo or approximately must be numbers");
|
||||
|
||||
err(function() {
|
||||
assert.closeTo(1.5, 1.0, undefined, 'blah');
|
||||
}, "blah: the arguments to closeTo or approximately must be numbers, and a delta is required");
|
||||
});
|
||||
|
||||
it('approximately', function(){
|
||||
|
@ -1874,6 +1878,10 @@ describe('assert', function () {
|
|||
err(function() {
|
||||
assert.approximately(1.5, 1.0, true, 'blah');
|
||||
}, "blah: the arguments to closeTo or approximately must be numbers");
|
||||
|
||||
err(function() {
|
||||
assert.approximately(1.5, 1.0, undefined, 'blah');
|
||||
}, "blah: the arguments to closeTo or approximately must be numbers, and a delta is required");
|
||||
});
|
||||
|
||||
it('sameMembers', function() {
|
||||
|
|
Loading…
Reference in a new issue