mirror of
https://github.com/chaijs/chai
synced 2024-11-13 23:37:07 +00:00
parent
ab41ed86cc
commit
c8a4e00c51
9 changed files with 5412 additions and 593 deletions
|
@ -1580,7 +1580,7 @@ module.exports = function (chai, _) {
|
|||
, errorMessage
|
||||
, shouldThrow = true
|
||||
, range = (startType === 'date' && finishType === 'date')
|
||||
? start.toUTCString() + '..' + finish.toUTCString()
|
||||
? start.toISOString() + '..' + finish.toISOString()
|
||||
: start + '..' + finish;
|
||||
|
||||
if (doLength && objType !== 'map' && objType !== 'set') {
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
|
||||
|
||||
var getName = require('get-func-name');
|
||||
var getProperties = require('./getProperties');
|
||||
var getEnumerableProperties = require('./getEnumerableProperties');
|
||||
var loupe = require('loupe');
|
||||
var config = require('../config');
|
||||
|
||||
module.exports = inspect;
|
||||
|
@ -24,356 +23,11 @@ module.exports = inspect;
|
|||
* @name inspect
|
||||
*/
|
||||
function inspect(obj, showHidden, depth, colors) {
|
||||
var ctx = {
|
||||
var options = {
|
||||
colors: colors,
|
||||
depth: (typeof depth === 'undefined' ? 2 : depth),
|
||||
showHidden: showHidden,
|
||||
seen: [],
|
||||
stylize: function (str) { return str; }
|
||||
truncate: config.truncateThreshold ? config.truncateThreshold : Infinity,
|
||||
};
|
||||
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
|
||||
}
|
||||
|
||||
// Returns true if object is a DOM element.
|
||||
var isDOMElement = function (object) {
|
||||
if (typeof HTMLElement === 'object') {
|
||||
return object instanceof HTMLElement;
|
||||
} else {
|
||||
return object &&
|
||||
typeof object === 'object' &&
|
||||
'nodeType' in object &&
|
||||
object.nodeType === 1 &&
|
||||
typeof object.nodeName === 'string';
|
||||
}
|
||||
};
|
||||
|
||||
function formatValue(ctx, value, recurseTimes) {
|
||||
// Provide a hook for user-specified inspect functions.
|
||||
// Check that value is an object with an inspect function on it
|
||||
if (value && typeof value.inspect === 'function' &&
|
||||
// Filter out the util module, it's inspect function is special
|
||||
value.inspect !== exports.inspect &&
|
||||
// Also filter out any prototype objects using the circular check.
|
||||
!(value.constructor && value.constructor.prototype === value)) {
|
||||
var ret = value.inspect(recurseTimes, ctx);
|
||||
if (typeof ret !== 'string') {
|
||||
ret = formatValue(ctx, ret, recurseTimes);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Primitive types cannot have properties
|
||||
var primitive = formatPrimitive(ctx, value);
|
||||
if (primitive) {
|
||||
return primitive;
|
||||
}
|
||||
|
||||
// If this is a DOM element, try to get the outer HTML.
|
||||
if (isDOMElement(value)) {
|
||||
if ('outerHTML' in value) {
|
||||
return value.outerHTML;
|
||||
// This value does not have an outerHTML attribute,
|
||||
// it could still be an XML element
|
||||
} else {
|
||||
// Attempt to serialize it
|
||||
try {
|
||||
if (document.xmlVersion) {
|
||||
var xmlSerializer = new XMLSerializer();
|
||||
return xmlSerializer.serializeToString(value);
|
||||
} else {
|
||||
// Firefox 11- do not support outerHTML
|
||||
// It does, however, support innerHTML
|
||||
// Use the following to render the element
|
||||
var ns = "http://www.w3.org/1999/xhtml";
|
||||
var container = document.createElementNS(ns, '_');
|
||||
|
||||
container.appendChild(value.cloneNode(false));
|
||||
var html = container.innerHTML
|
||||
.replace('><', '>' + value.innerHTML + '<');
|
||||
container.innerHTML = '';
|
||||
return html;
|
||||
}
|
||||
} catch (err) {
|
||||
// This could be a non-native DOM implementation,
|
||||
// continue with the normal flow:
|
||||
// printing the element as if it is an object.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Look up the keys of the object.
|
||||
var visibleKeys = getEnumerableProperties(value);
|
||||
var keys = ctx.showHidden ? getProperties(value) : visibleKeys;
|
||||
|
||||
var name, nameSuffix;
|
||||
|
||||
// Some type of object without properties can be shortcut.
|
||||
// In IE, errors have a single `stack` property, or if they are vanilla `Error`,
|
||||
// a `stack` plus `description` property; ignore those for consistency.
|
||||
if (keys.length === 0 || (isError(value) && (
|
||||
(keys.length === 1 && keys[0] === 'stack') ||
|
||||
(keys.length === 2 && keys[0] === 'description' && keys[1] === 'stack')
|
||||
))) {
|
||||
if (typeof value === 'function') {
|
||||
name = getName(value);
|
||||
nameSuffix = name ? ': ' + name : '';
|
||||
return ctx.stylize('[Function' + nameSuffix + ']', 'special');
|
||||
}
|
||||
if (isRegExp(value)) {
|
||||
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
||||
}
|
||||
if (isDate(value)) {
|
||||
return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
|
||||
}
|
||||
if (isError(value)) {
|
||||
return formatError(value);
|
||||
}
|
||||
}
|
||||
|
||||
var base = ''
|
||||
, array = false
|
||||
, typedArray = false
|
||||
, braces = ['{', '}'];
|
||||
|
||||
if (isTypedArray(value)) {
|
||||
typedArray = true;
|
||||
braces = ['[', ']'];
|
||||
}
|
||||
|
||||
// Make Array say that they are Array
|
||||
if (isArray(value)) {
|
||||
array = true;
|
||||
braces = ['[', ']'];
|
||||
}
|
||||
|
||||
// Make functions say that they are functions
|
||||
if (typeof value === 'function') {
|
||||
name = getName(value);
|
||||
nameSuffix = name ? ': ' + name : '';
|
||||
base = ' [Function' + nameSuffix + ']';
|
||||
}
|
||||
|
||||
// Make RegExps say that they are RegExps
|
||||
if (isRegExp(value)) {
|
||||
base = ' ' + RegExp.prototype.toString.call(value);
|
||||
}
|
||||
|
||||
// Make dates with properties first say the date
|
||||
if (isDate(value)) {
|
||||
base = ' ' + Date.prototype.toUTCString.call(value);
|
||||
}
|
||||
|
||||
// Make error with message first say the error
|
||||
if (isError(value)) {
|
||||
return formatError(value);
|
||||
}
|
||||
|
||||
if (keys.length === 0 && (!array || value.length == 0)) {
|
||||
return braces[0] + base + braces[1];
|
||||
}
|
||||
|
||||
if (recurseTimes < 0) {
|
||||
if (isRegExp(value)) {
|
||||
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
||||
} else {
|
||||
return ctx.stylize('[Object]', 'special');
|
||||
}
|
||||
}
|
||||
|
||||
ctx.seen.push(value);
|
||||
|
||||
var output;
|
||||
if (array) {
|
||||
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
||||
} else if (typedArray) {
|
||||
return formatTypedArray(value);
|
||||
} else {
|
||||
output = keys.map(function(key) {
|
||||
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
||||
});
|
||||
}
|
||||
|
||||
ctx.seen.pop();
|
||||
|
||||
return reduceToSingleString(output, base, braces);
|
||||
}
|
||||
|
||||
function formatPrimitive(ctx, value) {
|
||||
switch (typeof value) {
|
||||
case 'undefined':
|
||||
return ctx.stylize('undefined', 'undefined');
|
||||
|
||||
case 'string':
|
||||
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
||||
.replace(/'/g, "\\'")
|
||||
.replace(/\\"/g, '"') + '\'';
|
||||
return ctx.stylize(simple, 'string');
|
||||
|
||||
case 'number':
|
||||
if (value === 0 && (1/value) === -Infinity) {
|
||||
return ctx.stylize('-0', 'number');
|
||||
}
|
||||
return ctx.stylize('' + value, 'number');
|
||||
|
||||
case 'boolean':
|
||||
return ctx.stylize('' + value, 'boolean');
|
||||
|
||||
case 'symbol':
|
||||
return ctx.stylize(value.toString(), 'symbol');
|
||||
|
||||
case 'bigint':
|
||||
return ctx.stylize(value.toString() + 'n', 'bigint');
|
||||
}
|
||||
// For some reason typeof null is "object", so special case here.
|
||||
if (value === null) {
|
||||
return ctx.stylize('null', 'null');
|
||||
}
|
||||
}
|
||||
|
||||
function formatError(value) {
|
||||
return '[' + Error.prototype.toString.call(value) + ']';
|
||||
}
|
||||
|
||||
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
||||
var output = [];
|
||||
for (var i = 0, l = value.length; i < l; ++i) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, String(i))) {
|
||||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||||
String(i), true));
|
||||
} else {
|
||||
output.push('');
|
||||
}
|
||||
}
|
||||
|
||||
keys.forEach(function(key) {
|
||||
if (!key.match(/^\d+$/)) {
|
||||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||||
key, true));
|
||||
}
|
||||
});
|
||||
return output;
|
||||
}
|
||||
|
||||
function formatTypedArray(value) {
|
||||
var str = '[ ';
|
||||
|
||||
for (var i = 0; i < value.length; ++i) {
|
||||
if (str.length >= config.truncateThreshold - 7) {
|
||||
str += '...';
|
||||
break;
|
||||
}
|
||||
str += value[i] + ', ';
|
||||
}
|
||||
str += ' ]';
|
||||
|
||||
// Removing trailing `, ` if the array was not truncated
|
||||
if (str.indexOf(', ]') !== -1) {
|
||||
str = str.replace(', ]', ' ]');
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
||||
var name;
|
||||
var propDescriptor = Object.getOwnPropertyDescriptor(value, key);
|
||||
var str;
|
||||
|
||||
if (propDescriptor) {
|
||||
if (propDescriptor.get) {
|
||||
if (propDescriptor.set) {
|
||||
str = ctx.stylize('[Getter/Setter]', 'special');
|
||||
} else {
|
||||
str = ctx.stylize('[Getter]', 'special');
|
||||
}
|
||||
} else {
|
||||
if (propDescriptor.set) {
|
||||
str = ctx.stylize('[Setter]', 'special');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (visibleKeys.indexOf(key) < 0) {
|
||||
name = '[' + key + ']';
|
||||
}
|
||||
if (!str) {
|
||||
if (ctx.seen.indexOf(value[key]) < 0) {
|
||||
if (recurseTimes === null) {
|
||||
str = formatValue(ctx, value[key], null);
|
||||
} else {
|
||||
str = formatValue(ctx, value[key], recurseTimes - 1);
|
||||
}
|
||||
if (str.indexOf('\n') > -1) {
|
||||
if (array) {
|
||||
str = str.split('\n').map(function(line) {
|
||||
return ' ' + line;
|
||||
}).join('\n').substr(2);
|
||||
} else {
|
||||
str = '\n' + str.split('\n').map(function(line) {
|
||||
return ' ' + line;
|
||||
}).join('\n');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
str = ctx.stylize('[Circular]', 'special');
|
||||
}
|
||||
}
|
||||
if (typeof name === 'undefined') {
|
||||
if (array && key.match(/^\d+$/)) {
|
||||
return str;
|
||||
}
|
||||
name = JSON.stringify('' + key);
|
||||
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
||||
name = name.substr(1, name.length - 2);
|
||||
name = ctx.stylize(name, 'name');
|
||||
} else {
|
||||
name = name.replace(/'/g, "\\'")
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/(^"|"$)/g, "'");
|
||||
name = ctx.stylize(name, 'string');
|
||||
}
|
||||
}
|
||||
|
||||
return name + ': ' + str;
|
||||
}
|
||||
|
||||
function reduceToSingleString(output, base, braces) {
|
||||
var length = output.reduce(function(prev, cur) {
|
||||
return prev + cur.length + 1;
|
||||
}, 0);
|
||||
|
||||
if (length > 60) {
|
||||
return braces[0] +
|
||||
(base === '' ? '' : base + '\n ') +
|
||||
' ' +
|
||||
output.join(',\n ') +
|
||||
' ' +
|
||||
braces[1];
|
||||
}
|
||||
|
||||
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
||||
}
|
||||
|
||||
function isTypedArray(ar) {
|
||||
// Unfortunately there's no way to check if an object is a TypedArray
|
||||
// We have to check if it's one of these types
|
||||
return (typeof ar === 'object' && /\w+Array]$/.test(objectToString(ar)));
|
||||
}
|
||||
|
||||
function isArray(ar) {
|
||||
return Array.isArray(ar) ||
|
||||
(typeof ar === 'object' && objectToString(ar) === '[object Array]');
|
||||
}
|
||||
|
||||
function isRegExp(re) {
|
||||
return typeof re === 'object' && objectToString(re) === '[object RegExp]';
|
||||
}
|
||||
|
||||
function isDate(d) {
|
||||
return typeof d === 'object' && objectToString(d) === '[object Date]';
|
||||
}
|
||||
|
||||
function isError(e) {
|
||||
return typeof e === 'object' && objectToString(e) === '[object Error]';
|
||||
}
|
||||
|
||||
function objectToString(o) {
|
||||
return Object.prototype.toString.call(o);
|
||||
return loupe.inspect(obj, options);
|
||||
}
|
||||
|
|
5212
package-lock.json
generated
5212
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -44,6 +44,7 @@
|
|||
"check-error": "^1.0.2",
|
||||
"deep-eql": "^3.0.1",
|
||||
"get-func-name": "^2.0.0",
|
||||
"loupe": "^2.3.0",
|
||||
"pathval": "^1.1.1",
|
||||
"type-detect": "^4.0.5"
|
||||
},
|
||||
|
|
|
@ -70,7 +70,7 @@ describe('assert', function () {
|
|||
|
||||
err(function () {
|
||||
assert[isOk](0);
|
||||
}, "expected 0 to be truthy");
|
||||
}, "expected +0 to be truthy");
|
||||
|
||||
err(function () {
|
||||
assert[isOk]('');
|
||||
|
@ -107,7 +107,7 @@ describe('assert', function () {
|
|||
|
||||
err(function() {
|
||||
assert.isFalse(0);
|
||||
}, "expected 0 to be false");
|
||||
}, "expected +0 to be false");
|
||||
});
|
||||
|
||||
it('isNotFalse', function () {
|
||||
|
@ -273,7 +273,7 @@ describe('assert', function () {
|
|||
|
||||
err(function () {
|
||||
assert.notInstanceOf(new Foo(), Foo, 'blah');
|
||||
}, "blah: expected {} to not be an instance of Foo");
|
||||
}, "blah: expected Foo{} to not be an instance of Foo");
|
||||
});
|
||||
|
||||
it('isObject', function () {
|
||||
|
@ -287,7 +287,7 @@ describe('assert', function () {
|
|||
|
||||
err(function() {
|
||||
assert.isObject(Foo);
|
||||
}, "expected [Function: Foo] to be an object");
|
||||
}, "expected [Function Foo] to be an object");
|
||||
|
||||
err(function() {
|
||||
assert.isObject('foo');
|
||||
|
@ -353,7 +353,7 @@ describe('assert', function () {
|
|||
|
||||
err(function () {
|
||||
assert.deepEqual({tea: 'chai'}, {tea: 'black'}, 'blah');
|
||||
}, "blah: expected { tea: \'chai\' } to deeply equal { tea: \'black\' }");
|
||||
}, "blah: expected { tea: 'chai' } to deeply equal { tea: 'black' }");
|
||||
|
||||
var obja = Object.create({ tea: 'chai' })
|
||||
, objb = Object.create({ tea: 'chai' });
|
||||
|
@ -365,7 +365,7 @@ describe('assert', function () {
|
|||
|
||||
err(function () {
|
||||
assert.deepEqual(obj1, obj2);
|
||||
}, "expected { tea: \'chai\' } to deeply equal { tea: \'black\' }");
|
||||
}, "expected {} to deeply equal {}");
|
||||
});
|
||||
|
||||
it('deepEqual (ordering)', function() {
|
||||
|
@ -405,7 +405,7 @@ describe('assert', function () {
|
|||
err(function() {
|
||||
secondCircularObject.field2 = secondCircularObject;
|
||||
assert.deepEqual(circularObject, secondCircularObject);
|
||||
}, "expected { field: [Circular] } to deeply equal { Object (field, field2) }");
|
||||
}, "expected { field: [Circular] } to deeply equal { field: [Circular], …(1) }");
|
||||
});
|
||||
|
||||
it('notDeepEqual', function() {
|
||||
|
@ -928,19 +928,19 @@ describe('assert', function () {
|
|||
|
||||
err(function () {
|
||||
assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 2}}, 'blah');
|
||||
}, "blah: expected { a: { b: [ [Object] ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
}, "blah: expected { a: { b: [ { x: 1 } ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
|
||||
err(function () {
|
||||
assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 2}}, 'blah');
|
||||
}, "blah: expected { a: { b: [ [Object] ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
}, "blah: expected { a: { b: [ { x: 1 } ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
|
||||
err(function () {
|
||||
assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.c': {x: 1}});
|
||||
}, "expected { a: { b: [ [Object] ] } } to have deep nested property 'a.c'");
|
||||
}, "expected { a: { b: [ { x: 1 } ] } } to have deep nested property 'a.c'");
|
||||
|
||||
err(function () {
|
||||
assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {x: 1}}, 'blah');
|
||||
}, "blah: expected { a: { b: [ [Object] ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
|
||||
}, "blah: expected { a: { b: [ { x: 1 } ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
|
||||
});
|
||||
|
||||
it('ownInclude and notOwnInclude', function() {
|
||||
|
@ -1424,7 +1424,7 @@ describe('assert', function () {
|
|||
|
||||
err(function(){
|
||||
assert.lengthOf(map, 3, 'blah');
|
||||
}, "blah: expected {} to have a size of 3 but got 2");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2 } to have a size of 3 but got 2");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -1438,7 +1438,7 @@ describe('assert', function () {
|
|||
|
||||
err(function(){
|
||||
assert.lengthOf(set, 3, 'blah');
|
||||
}, "blah: expected {} to have a size of 3 but got 2");
|
||||
}, "blah: expected Set{ 1, 2 } to have a size of 3 but got 2");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2026,7 +2026,7 @@ describe('assert', function () {
|
|||
|
||||
err(function() {
|
||||
assert.includeMembers([5, 6], [5, 6, 0]);
|
||||
}, 'expected [ 5, 6 ] to be a superset of [ 5, 6, 0 ]');
|
||||
}, 'expected [ 5, 6 ] to be a superset of [ 5, 6, +0 ]');
|
||||
});
|
||||
|
||||
it('notIncludeMembers', function() {
|
||||
|
@ -2051,7 +2051,7 @@ describe('assert', function () {
|
|||
|
||||
err(function() {
|
||||
assert.includeDeepMembers([{e:5}, {f:6}], [{e:5}, {f:6}, {z:0}]);
|
||||
}, 'expected [ { e: 5 }, { f: 6 } ] to be a superset of [ { e: 5 }, { f: 6 }, { z: 0 } ]');
|
||||
}, 'expected [ { e: 5 }, { f: 6 } ] to be a superset of [ { e: 5 }, { f: 6 }, { z: +0 } ]');
|
||||
});
|
||||
|
||||
it('notIncludeDeepMembers', function() {
|
||||
|
@ -2155,11 +2155,11 @@ describe('assert', function () {
|
|||
|
||||
err(function() {
|
||||
assert.isAbove(oneSecondAgo, now, 'blah');
|
||||
}, 'blah: expected ' + oneSecondAgo.toUTCString() + ' to be above ' + now.toUTCString());
|
||||
}, 'blah: expected ' + oneSecondAgo.toISOString() + ' to be above ' + now.toISOString());
|
||||
|
||||
err(function() {
|
||||
assert.isAbove(now, now, 'blah');
|
||||
}, 'blah: expected ' + now.toUTCString() + ' to be above ' + now.toUTCString());
|
||||
}, 'blah: expected ' + now.toISOString() + ' to be above ' + now.toISOString());
|
||||
|
||||
err(function() {
|
||||
assert.isAbove(null, now);
|
||||
|
@ -2205,7 +2205,7 @@ describe('assert', function () {
|
|||
|
||||
err(function() {
|
||||
assert.isAtLeast(now, oneSecondAfter, 'blah');
|
||||
}, 'blah: expected ' + now.toUTCString() + ' to be at least ' + oneSecondAfter.toUTCString());
|
||||
}, 'blah: expected ' + now.toISOString() + ' to be at least ' + oneSecondAfter.toISOString());
|
||||
|
||||
err(function() {
|
||||
assert.isAtLeast(null, now, 'blah');
|
||||
|
@ -2251,11 +2251,11 @@ describe('assert', function () {
|
|||
|
||||
err(function() {
|
||||
assert.isBelow(now, oneSecondAgo, 'blah');
|
||||
}, 'blah: expected ' + now.toUTCString() + ' to be below ' + oneSecondAgo.toUTCString());
|
||||
}, 'blah: expected ' + now.toISOString() + ' to be below ' + oneSecondAgo.toISOString());
|
||||
|
||||
err(function() {
|
||||
assert.isBelow(now, now);
|
||||
}, 'expected ' + now.toUTCString() + ' to be below ' + now.toUTCString());
|
||||
}, 'expected ' + now.toISOString() + ' to be below ' + now.toISOString());
|
||||
|
||||
err(function() {
|
||||
assert.isBelow(null, now, 'blah');
|
||||
|
@ -2301,7 +2301,7 @@ describe('assert', function () {
|
|||
|
||||
err(function() {
|
||||
assert.isAtMost(oneSecondAfter, now, 'blah');
|
||||
}, 'blah: expected ' + oneSecondAfter.toUTCString() + ' to be at most ' + now.toUTCString());
|
||||
}, 'blah: expected ' + oneSecondAfter.toISOString() + ' to be at most ' + now.toISOString());
|
||||
|
||||
err(function() {
|
||||
assert.isAtMost(null, now, 'blah');
|
||||
|
@ -2781,7 +2781,7 @@ describe('assert', function () {
|
|||
|
||||
err(function(){
|
||||
assert[isEmpty]({arguments: 0});
|
||||
}, "expected { arguments: 0 } to be empty");
|
||||
}, "expected { arguments: +0 } to be empty");
|
||||
|
||||
err(function(){
|
||||
assert[isEmpty]({foo: 'bar'});
|
||||
|
@ -2801,7 +2801,7 @@ describe('assert', function () {
|
|||
|
||||
err(function(){
|
||||
assert[isEmpty](0);
|
||||
}, ".empty was passed non-string primitive 0");
|
||||
}, ".empty was passed non-string primitive +0");
|
||||
|
||||
err(function(){
|
||||
assert[isEmpty](1);
|
||||
|
@ -2867,7 +2867,7 @@ describe('assert', function () {
|
|||
|
||||
err(function(){
|
||||
assert[isNotEmpty](new Map);
|
||||
}, "expected {} not to be empty");
|
||||
}, "expected Map{} not to be empty");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -2878,7 +2878,7 @@ describe('assert', function () {
|
|||
|
||||
err(function(){
|
||||
assert[isNotEmpty](new Set);
|
||||
}, "expected {} not to be empty");
|
||||
}, "expected Set{} not to be empty");
|
||||
}
|
||||
|
||||
err(function(){
|
||||
|
@ -2891,7 +2891,7 @@ describe('assert', function () {
|
|||
|
||||
err(function(){
|
||||
assert[isNotEmpty](new FakeArgs);
|
||||
}, "expected { length: 0 } not to be empty");
|
||||
}, "expected FakeArgs{} not to be empty");
|
||||
|
||||
err(function(){
|
||||
assert[isNotEmpty]({});
|
||||
|
@ -2911,7 +2911,7 @@ describe('assert', function () {
|
|||
|
||||
err(function(){
|
||||
assert[isNotEmpty](0);
|
||||
}, ".empty was passed non-string primitive 0");
|
||||
}, ".empty was passed non-string primitive +0");
|
||||
|
||||
err(function(){
|
||||
assert[isNotEmpty](1);
|
||||
|
|
180
test/expect.js
180
test/expect.js
|
@ -575,11 +575,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(map).to.have.length.within(5, 7, 'blah');
|
||||
}, "blah: expected {} to have a size within 5..7");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size within 5..7");
|
||||
|
||||
err(function () {
|
||||
expect(map).to.have.lengthOf.within(5, 7, 'blah');
|
||||
}, "blah: expected {} to have a size within 5..7");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size within 5..7");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -596,11 +596,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(set).to.have.length.within(5, 7, 'blah');
|
||||
}, "blah: expected {} to have a size within 5..7");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size within 5..7");
|
||||
|
||||
err(function () {
|
||||
expect(set).to.have.lengthOf.within(5, 7, 'blah');
|
||||
}, "blah: expected {} to have a size within 5..7");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size within 5..7");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -608,9 +608,9 @@ describe('expect', function () {
|
|||
var now = new Date();
|
||||
var oneSecondAgo = new Date(now.getTime() - 1000);
|
||||
var oneSecondAfter = new Date(now.getTime() + 1000);
|
||||
var nowUTC = now.toUTCString();
|
||||
var beforeUTC = oneSecondAgo.toUTCString();
|
||||
var afterUTC = oneSecondAfter.toUTCString();
|
||||
var nowISO = now.toISOString();
|
||||
var beforeISO = oneSecondAgo.toISOString();
|
||||
var afterISO = oneSecondAfter.toISOString();
|
||||
|
||||
expect(now).to.be.within(oneSecondAgo, oneSecondAfter);
|
||||
expect(now).to.be.within(now, oneSecondAfter);
|
||||
|
@ -619,15 +619,15 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(now).to.not.be.within(now, oneSecondAfter, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to not be within " + nowUTC + ".." + afterUTC);
|
||||
}, "blah: expected " + nowISO + " to not be within " + nowISO + ".." + afterISO);
|
||||
|
||||
err(function(){
|
||||
expect(now, 'blah').to.not.be.within(oneSecondAgo, oneSecondAfter);
|
||||
}, "blah: expected " + nowUTC + " to not be within " + beforeUTC + ".." + afterUTC);
|
||||
}, "blah: expected " + nowISO + " to not be within " + beforeISO + ".." + afterISO);
|
||||
|
||||
err(function () {
|
||||
expect(now).to.have.length.within(5, 7, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to have property 'length'");
|
||||
}, "blah: expected " + nowISO + " to have property 'length'");
|
||||
|
||||
err(function () {
|
||||
expect('foo').to.have.lengthOf.within(now, 7, 'blah');
|
||||
|
@ -750,11 +750,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(map).to.have.length.above(5, 'blah');
|
||||
}, "blah: expected {} to have a size above 5 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size above 5 but got 3");
|
||||
|
||||
err(function () {
|
||||
expect(map).to.have.lengthOf.above(5, 'blah');
|
||||
}, "blah: expected {} to have a size above 5 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size above 5 but got 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -771,11 +771,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(set).to.have.length.above(5, 'blah');
|
||||
}, "blah: expected {} to have a size above 5 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size above 5 but got 3");
|
||||
|
||||
err(function () {
|
||||
expect(set).to.have.lengthOf.above(5, 'blah');
|
||||
}, "blah: expected {} to have a size above 5 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size above 5 but got 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -791,7 +791,7 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(now).to.be.above(oneSecondAfter, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to be above " + oneSecondAfter.toUTCString());
|
||||
}, "blah: expected " + now.toISOString() + " to be above " + oneSecondAfter.toISOString());
|
||||
|
||||
err(function(){
|
||||
expect(10).to.not.be.above(6, 'blah');
|
||||
|
@ -799,7 +799,7 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(now).to.have.length.above(4, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to have property 'length'");
|
||||
}, "blah: expected " + now.toISOString() + " to have property 'length'");
|
||||
|
||||
err(function () {
|
||||
expect([ 1, 2, 3 ]).to.have.length.above(now, 'blah');
|
||||
|
@ -917,11 +917,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(map).to.have.length.of.at.least(4, 'blah');
|
||||
}, "blah: expected {} to have a size at least 4 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size at least 4 but got 3");
|
||||
|
||||
err(function () {
|
||||
expect(map).to.have.lengthOf.at.least(4, 'blah');
|
||||
}, "blah: expected {} to have a size at least 4 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size at least 4 but got 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -938,11 +938,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(set).to.have.length.of.at.least(4, 'blah');
|
||||
}, "blah: expected {} to have a size at least 4 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size at least 4 but got 3");
|
||||
|
||||
err(function () {
|
||||
expect(set).to.have.lengthOf.at.least(4, 'blah');
|
||||
}, "blah: expected {} to have a size at least 4 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size at least 4 but got 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1038,11 +1038,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(map).to.have.length.below(2, 'blah');
|
||||
}, "blah: expected {} to have a size below 2 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size below 2 but got 3");
|
||||
|
||||
err(function () {
|
||||
expect(map).to.have.lengthOf.below(2, 'blah');
|
||||
}, "blah: expected {} to have a size below 2 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size below 2 but got 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -1059,11 +1059,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(set).to.have.length.below(2, 'blah');
|
||||
}, "blah: expected {} to have a size below 2 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size below 2 but got 3");
|
||||
|
||||
err(function () {
|
||||
expect(set).to.have.lengthOf.below(2, 'blah');
|
||||
}, "blah: expected {} to have a size below 2 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size below 2 but got 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1079,11 +1079,11 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(now).to.be.below(oneSecondAgo, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to be below " + oneSecondAgo.toUTCString());
|
||||
}, "blah: expected " + now.toISOString() + " to be below " + oneSecondAgo.toISOString());
|
||||
|
||||
err(function(){
|
||||
expect(now).to.not.be.below(oneSecondAfter, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to be at least " + oneSecondAfter.toUTCString());
|
||||
}, "blah: expected " + now.toISOString() + " to be at least " + oneSecondAfter.toISOString());
|
||||
|
||||
err(function () {
|
||||
expect('foo').to.have.length.below(2, 'blah');
|
||||
|
@ -1103,7 +1103,7 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(now).to.have.length.below(0, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to have property 'length'");
|
||||
}, "blah: expected " + now.toISOString() + " to have property 'length'");
|
||||
|
||||
err(function () {
|
||||
expect('asdasd').to.have.length.below(now, 'blah');
|
||||
|
@ -1209,11 +1209,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(map).to.have.length.of.at.most(2, 'blah');
|
||||
}, "blah: expected {} to have a size at most 2 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size at most 2 but got 3");
|
||||
|
||||
err(function () {
|
||||
expect(map).to.have.lengthOf.at.most(2, 'blah');
|
||||
}, "blah: expected {} to have a size at most 2 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size at most 2 but got 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -1230,11 +1230,11 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(set).to.have.length.of.at.most(2, 'blah');
|
||||
}, "blah: expected {} to have a size at most 2 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size at most 2 but got 3");
|
||||
|
||||
err(function () {
|
||||
expect(set).to.have.lengthOf.at.most(2, 'blah');
|
||||
}, "blah: expected {} to have a size at most 2 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size at most 2 but got 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1242,9 +1242,9 @@ describe('expect', function () {
|
|||
var now = new Date();
|
||||
var oneSecondBefore = new Date(now.getTime() - 1000);
|
||||
var oneSecondAfter = new Date(now.getTime() + 1000);
|
||||
var nowUTC = now.toUTCString();
|
||||
var beforeUTC = oneSecondBefore.toUTCString();
|
||||
var afterUTC = oneSecondAfter.toUTCString();
|
||||
var nowISO = now.toISOString();
|
||||
var beforeISO = oneSecondBefore.toISOString();
|
||||
var afterISO = oneSecondAfter.toISOString();
|
||||
|
||||
expect(now).to.be.at.most(oneSecondAfter);
|
||||
expect(now).to.be.at.most(now);
|
||||
|
@ -1252,15 +1252,15 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(now).to.be.at.most(oneSecondBefore, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to be at most " + beforeUTC);
|
||||
}, "blah: expected " + nowISO + " to be at most " + beforeISO);
|
||||
|
||||
err(function(){
|
||||
expect(now).to.not.be.at.most(now, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to be above " + nowUTC);
|
||||
}, "blah: expected " + nowISO + " to be above " + nowISO);
|
||||
|
||||
err(function () {
|
||||
expect(now).to.have.length.of.at.most(2, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to have property 'length'");
|
||||
}, "blah: expected " + nowISO + " to have property 'length'");
|
||||
|
||||
err(function () {
|
||||
expect('foo', 'blah').to.have.length.of.at.most(now);
|
||||
|
@ -1355,11 +1355,11 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(map).to.not.have.length(3, 'blah');
|
||||
}, "blah: expected {} to not have a size of 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to not have a size of 3");
|
||||
|
||||
err(function(){
|
||||
expect(map).to.not.have.lengthOf(3, 'blah');
|
||||
}, "blah: expected {} to not have a size of 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to not have a size of 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -1376,11 +1376,11 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(set).to.not.have.length(3, 'blah');
|
||||
}, "blah: expected {} to not have a size of 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to not have a size of 3");
|
||||
|
||||
err(function(){
|
||||
expect(set).to.not.have.lengthOf(3, 'blah');;
|
||||
}, "blah: expected {} to not have a size of 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to not have a size of 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1406,7 +1406,7 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect(Buffer.from([ 0 ])).to.eql(Buffer.from([ 1 ]));
|
||||
}, 'expected <Buffer 00> to deeply equal <Buffer 01>');
|
||||
}, 'expected Buffer[ 0 ] to deeply equal Buffer[ 1 ]');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1508,7 +1508,7 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(new Map).not.to.be.empty;
|
||||
}, "expected {} not to be empty");
|
||||
}, "expected Map{} not to be empty");
|
||||
|
||||
map = new Map;
|
||||
map.key = 'val';
|
||||
|
@ -1516,7 +1516,7 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(map).not.to.be.empty;
|
||||
}, "expected { key: 'val' } not to be empty");
|
||||
}, "expected Map{} not to be empty");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -1529,7 +1529,7 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(new Set).not.to.be.empty;
|
||||
}, "expected {} not to be empty");
|
||||
}, "expected Set{} not to be empty");
|
||||
|
||||
set = new Set;
|
||||
set.key = 'val';
|
||||
|
@ -1537,7 +1537,7 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(set).not.to.be.empty;
|
||||
}, "expected { key: 'val' } not to be empty");
|
||||
}, "expected Set{} not to be empty");
|
||||
}
|
||||
|
||||
err(function(){
|
||||
|
@ -1558,11 +1558,11 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(new FakeArgs).not.to.be.empty;
|
||||
}, "expected { length: 0 } not to be empty");
|
||||
}, "expected FakeArgs{} not to be empty");
|
||||
|
||||
err(function(){
|
||||
expect({arguments: 0}).to.be.empty;
|
||||
}, "expected { arguments: 0 } to be empty");
|
||||
}, "expected { arguments: +0 } to be empty");
|
||||
|
||||
err(function(){
|
||||
expect({}).not.to.be.empty;
|
||||
|
@ -1598,7 +1598,7 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(0).to.be.empty;
|
||||
}, ".empty was passed non-string primitive 0");
|
||||
}, ".empty was passed non-string primitive +0");
|
||||
|
||||
err(function(){
|
||||
expect(1).to.be.empty;
|
||||
|
@ -1775,13 +1775,13 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(deepObj).to.have.nested.property('teas[3]');
|
||||
}, "expected { Object (green, teas) } to have nested property 'teas[3]'");
|
||||
}, "expected { green: { tea: 'matcha' }, …(1) } to have nested property 'teas[3]'");
|
||||
err(function(){
|
||||
expect(deepObj).to.have.nested.property('teas[3]', 'bar');
|
||||
}, "expected { Object (green, teas) } to have nested property 'teas[3]'");
|
||||
}, "expected { green: { tea: 'matcha' }, …(1) } to have nested property 'teas[3]'");
|
||||
err(function(){
|
||||
expect(deepObj).to.have.nested.property('teas[3].tea', 'bar');
|
||||
}, "expected { Object (green, teas) } to have nested property 'teas[3].tea'");
|
||||
}, "expected { green: { tea: 'matcha' }, …(1) } to have nested property 'teas[3].tea'");
|
||||
|
||||
var arr = [
|
||||
[ 'chai', 'matcha', 'konacha' ]
|
||||
|
@ -1793,13 +1793,13 @@ describe('expect', function () {
|
|||
expect(arr).to.have.nested.property('[1][2].tea', 'konacha');
|
||||
err(function(){
|
||||
expect(arr).to.have.nested.property('[2][1]');
|
||||
}, "expected [ Array(2) ] to have nested property '[2][1]'");
|
||||
}, "expected [ …(2) ] to have nested property '[2][1]'");
|
||||
err(function(){
|
||||
expect(arr).to.have.nested.property('[2][1]', 'none');
|
||||
}, "expected [ Array(2) ] to have nested property '[2][1]'");
|
||||
}, "expected [ …(2) ] to have nested property '[2][1]'");
|
||||
err(function(){
|
||||
expect(arr).to.have.nested.property('[0][3]', 'none');
|
||||
}, "expected [ Array(2) ] to have nested property '[0][3]'");
|
||||
}, "expected [ …(2) ] to have nested property '[0][3]'");
|
||||
|
||||
err(function(){
|
||||
expect('asd').to.have.property('length', 4, 'blah');
|
||||
|
@ -1815,7 +1815,7 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect('asd').to.have.property('constructor', Number, 'blah');
|
||||
}, "blah: expected 'asd' to have property 'constructor' of [Function: Number], but got [Function: String]");
|
||||
}, "blah: expected 'asd' to have property 'constructor' of [Function Number], but got [Function String]");
|
||||
|
||||
err(function() {
|
||||
expect({a: {b: 1}}).to.have.own.nested.property("a.b", 1, 'blah');
|
||||
|
@ -2447,23 +2447,23 @@ describe('expect', function () {
|
|||
|
||||
err(function () {
|
||||
expect({a: {b: [{x: 1}]}}).to.deep.nested.include({'a.b[0]': {y: 2}}, 'blah');
|
||||
}, "blah: expected { a: { b: [ [Object] ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
}, "blah: expected { a: { b: [ { x: 1 } ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
|
||||
err(function () {
|
||||
expect({a: {b: [{x: 1}]}}, 'blah').to.deep.nested.include({'a.b[0]': {y: 2}});
|
||||
}, "blah: expected { a: { b: [ [Object] ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
}, "blah: expected { a: { b: [ { x: 1 } ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
|
||||
err(function () {
|
||||
expect({a: {b: [{x: 1}]}}).to.deep.nested.include({'a.c': {x: 1}});
|
||||
}, "expected { a: { b: [ [Object] ] } } to have deep nested property 'a.c'");
|
||||
}, "expected { a: { b: [ { x: 1 } ] } } to have deep nested property 'a.c'");
|
||||
|
||||
err(function () {
|
||||
expect({a: {b: [{x: 1}]}}).to.not.deep.nested.include({'a.b[0]': {x: 1}}, 'blah');
|
||||
}, "blah: expected { a: { b: [ [Object] ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
|
||||
}, "blah: expected { a: { b: [ { x: 1 } ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
|
||||
|
||||
err(function () {
|
||||
expect({a: {b: [{x: 1}]}}, 'blah').to.not.deep.nested.include({'a.b[0]': {x: 1}});
|
||||
}, "blah: expected { a: { b: [ [Object] ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
|
||||
}, "blah: expected { a: { b: [ { x: 1 } ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
|
||||
});
|
||||
|
||||
it('own.include()', function () {
|
||||
|
@ -3073,103 +3073,103 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(goodFn, 'blah').to.throw();
|
||||
}, /^blah: expected \[Function(: goodFn)*\] to throw an error$/);
|
||||
}, /^blah: expected \[Function( goodFn)*\] to throw an error$/);
|
||||
|
||||
err(function(){
|
||||
expect(goodFn, 'blah').to.throw(ReferenceError);
|
||||
}, /^blah: expected \[Function(: goodFn)*\] to throw ReferenceError$/);
|
||||
}, /^blah: expected \[Function( goodFn)*\] to throw ReferenceError$/);
|
||||
|
||||
err(function(){
|
||||
expect(goodFn, 'blah').to.throw(specificError);
|
||||
}, /^blah: expected \[Function(: goodFn)*\] to throw 'RangeError: boo'$/);
|
||||
}, /^blah: expected \[Function( goodFn)*\] to throw 'RangeError: boo'$/);
|
||||
|
||||
err(function(){
|
||||
expect(badFn, 'blah').to.not.throw();
|
||||
}, /^blah: expected \[Function(: badFn)*\] to not throw an error but 'Error: testing' was thrown$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to not throw an error but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(badFn, 'blah').to.throw(ReferenceError);
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw 'ReferenceError' but 'Error: testing' was thrown$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw 'ReferenceError' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(badFn, 'blah').to.throw(specificError);
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw 'RangeError: boo' but 'Error: testing' was thrown$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw 'RangeError: boo' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(badFn, 'blah').to.not.throw(Error);
|
||||
}, /^blah: expected \[Function(: badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(refErrFn, 'blah').to.not.throw(ReferenceError);
|
||||
}, /^blah: expected \[Function(: refErrFn)*\] to not throw 'ReferenceError' but 'ReferenceError: hello' was thrown$/);
|
||||
}, /^blah: expected \[Function( refErrFn)*\] to not throw 'ReferenceError' but 'ReferenceError: hello' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(badFn, 'blah').to.throw(PoorlyConstructedError);
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw 'PoorlyConstructedError' but 'Error: testing' was thrown$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw 'PoorlyConstructedError' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(ickyErrFn, 'blah').to.not.throw(PoorlyConstructedError);
|
||||
}, /^blah: (expected \[Function(: ickyErrFn)*\] to not throw 'PoorlyConstructedError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
||||
}, /^blah: (expected \[Function( ickyErrFn)*\] to not throw 'PoorlyConstructedError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
||||
|
||||
err(function(){
|
||||
expect(ickyErrFn, 'blah').to.throw(ReferenceError);
|
||||
}, /^blah: (expected \[Function(: ickyErrFn)*\] to throw 'ReferenceError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
||||
}, /^blah: (expected \[Function( ickyErrFn)*\] to throw 'ReferenceError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
||||
|
||||
err(function(){
|
||||
expect(specificErrFn, 'blah').to.throw(new ReferenceError('eek'));
|
||||
}, /^blah: expected \[Function(: specificErrFn)*\] to throw 'ReferenceError: eek' but 'RangeError: boo' was thrown$/);
|
||||
}, /^blah: expected \[Function( specificErrFn)*\] to throw 'ReferenceError: eek' but 'RangeError: boo' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(specificErrFn, 'blah').to.not.throw(specificError);
|
||||
}, /^blah: expected \[Function(: specificErrFn)*\] to not throw 'RangeError: boo'$/);
|
||||
}, /^blah: expected \[Function( specificErrFn)*\] to not throw 'RangeError: boo'$/);
|
||||
|
||||
err(function (){
|
||||
expect(badFn, 'blah').to.not.throw(/testing/);
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw error not matching \/testing\/$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw error not matching \/testing\/$/);
|
||||
|
||||
err(function () {
|
||||
expect(badFn, 'blah').to.throw(/hello/);
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw error matching \/hello\/ but got 'testing'$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw error matching \/hello\/ but got 'testing'$/);
|
||||
|
||||
err(function () {
|
||||
expect(badFn).to.throw(Error, /hello/, 'blah');
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw error matching \/hello\/ but got 'testing'$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw error matching \/hello\/ but got 'testing'$/);
|
||||
|
||||
err(function () {
|
||||
expect(badFn, 'blah').to.throw(Error, /hello/);
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw error matching \/hello\/ but got 'testing'$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw error matching \/hello\/ but got 'testing'$/);
|
||||
|
||||
err(function () {
|
||||
expect(badFn).to.throw(Error, 'hello', 'blah');
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw error including 'hello' but got 'testing'$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw error including 'hello' but got 'testing'$/);
|
||||
|
||||
err(function () {
|
||||
expect(badFn, 'blah').to.throw(Error, 'hello');
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw error including 'hello' but got 'testing'$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw error including 'hello' but got 'testing'$/);
|
||||
|
||||
err(function () {
|
||||
expect(customErrFn, 'blah').to.not.throw();
|
||||
}, /^blah: expected \[Function(: customErrFn)*\] to not throw an error but 'CustomError: foo' was thrown$/);
|
||||
}, /^blah: expected \[Function( customErrFn)*\] to not throw an error but 'CustomError: foo' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(badFn).to.not.throw(Error, 'testing', 'blah');
|
||||
}, /^blah: expected \[Function(: badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(badFn, 'blah').to.not.throw(Error, 'testing');
|
||||
}, /^blah: expected \[Function(: badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(emptyStringErrFn).to.not.throw(Error, '', 'blah');
|
||||
}, /^blah: expected \[Function(: emptyStringErrFn)*\] to not throw 'Error' but 'Error' was thrown$/);
|
||||
}, /^blah: expected \[Function( emptyStringErrFn)*\] to not throw 'Error' but 'Error' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(emptyStringErrFn, 'blah').to.not.throw(Error, '');
|
||||
}, /^blah: expected \[Function(: emptyStringErrFn)*\] to not throw 'Error' but 'Error' was thrown$/);
|
||||
}, /^blah: expected \[Function( emptyStringErrFn)*\] to not throw 'Error' but 'Error' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
expect(emptyStringErrFn, 'blah').to.not.throw('');
|
||||
}, /^blah: expected \[Function(: emptyStringErrFn)*\] to throw error not including ''$/);
|
||||
}, /^blah: expected \[Function( emptyStringErrFn)*\] to throw error not including ''$/);
|
||||
|
||||
err(function () {
|
||||
expect({}, 'blah').to.throw();
|
||||
|
@ -3197,11 +3197,11 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(Foo).to.respondTo('baz', 'constructor');
|
||||
}, /^(constructor: expected)(.*)(\[Function: Foo\])(.*)(to respond to \'baz\')$/);
|
||||
}, /^(constructor: expected)(.*)(\[Function Foo\])(.*)(to respond to \'baz\')$/);
|
||||
|
||||
err(function(){
|
||||
expect(Foo, 'constructor').to.respondTo('baz');
|
||||
}, /^(constructor: expected)(.*)(\[Function: Foo\])(.*)(to respond to \'baz\')$/);
|
||||
}, /^(constructor: expected)(.*)(\[Function Foo\])(.*)(to respond to \'baz\')$/);
|
||||
|
||||
err(function(){
|
||||
expect(bar).to.respondTo('baz', 'object');
|
||||
|
@ -3221,11 +3221,11 @@ describe('expect', function () {
|
|||
|
||||
err(function(){
|
||||
expect(2).to.satisfy(matcher, 'blah');
|
||||
}, /^blah: expected 2 to satisfy \[Function(: matcher)*\]$/);
|
||||
}, /^blah: expected 2 to satisfy \[Function( matcher)*\]$/);
|
||||
|
||||
err(function(){
|
||||
expect(2, 'blah').to.satisfy(matcher);
|
||||
}, /^blah: expected 2 to satisfy \[Function(: matcher)*\]$/);
|
||||
}, /^blah: expected 2 to satisfy \[Function( matcher)*\]$/);
|
||||
});
|
||||
|
||||
it('closeTo', function(){
|
||||
|
|
|
@ -103,7 +103,7 @@ describe('globalErr', function () {
|
|||
err(function () {
|
||||
expect(f1).to.equal(f2);
|
||||
}, {
|
||||
message: "expected [Function: f1] to equal [Function: f2]"
|
||||
message: "expected [Function f1] to equal [Function f2]"
|
||||
, expected: f2
|
||||
, actual: f1
|
||||
, operator: 'deepStrictEqual'
|
||||
|
@ -112,7 +112,7 @@ describe('globalErr', function () {
|
|||
err(function () {
|
||||
expect(f1).to.not.equal(f1);
|
||||
}, {
|
||||
message: "expected [Function: f1] to not equal [Function: f1]"
|
||||
message: "expected [Function f1] to not equal [Function f1]"
|
||||
, expected: f1
|
||||
, actual: f1
|
||||
, operator: 'notDeepStrictEqual'
|
||||
|
@ -136,7 +136,7 @@ describe('globalErr', function () {
|
|||
err(function () {
|
||||
expect(val1).to.equal(val2);
|
||||
}, {
|
||||
message: 'expected [ Array(4) ] to equal [ Array(4) ]'
|
||||
message: "expected [ 'string1', 'string2', …(2) ] to equal [ 'string5', 'string6', …(2) ]"
|
||||
, expected: val2
|
||||
, actual: val1
|
||||
, operator: 'deepStrictEqual'
|
||||
|
@ -145,7 +145,7 @@ describe('globalErr', function () {
|
|||
err(function () {
|
||||
expect(val1).to.not.equal(val1);
|
||||
}, {
|
||||
message: 'expected [ Array(4) ] to not equal [ Array(4) ]'
|
||||
message: "expected [ 'string1', 'string2', …(2) ] to not equal [ 'string1', 'string2', …(2) ]"
|
||||
, expected: val1
|
||||
, actual: val1
|
||||
, operator: 'notDeepStrictEqual'
|
||||
|
@ -161,7 +161,7 @@ describe('globalErr', function () {
|
|||
it('should throw if object val\'s props are not included in error object', function () {
|
||||
err(function () {
|
||||
err(function () { throw new Err('cat') }, {text: 'cat'});
|
||||
}, /expected { Object \(message, showDiff(, \.\.\.)*\) } to have property \'text\'/);
|
||||
}, /expected AssertionError{ message: 'cat', …\(2\) } to have property \'text\'/);
|
||||
|
||||
err(function () {
|
||||
err(function () { throw new Err('cat') }, {message: 'dog'});
|
||||
|
|
164
test/should.js
164
test/should.js
|
@ -596,11 +596,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
map.should.have.length.within(5, 7, 'blah');
|
||||
}, "blah: expected {} to have a size within 5..7");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size within 5..7");
|
||||
|
||||
err(function () {
|
||||
map.should.have.lengthOf.within(5, 7, 'blah');
|
||||
}, "blah: expected {} to have a size within 5..7");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size within 5..7");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -617,11 +617,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
set.should.have.length.within(5, 7, 'blah');
|
||||
}, "blah: expected {} to have a size within 5..7");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size within 5..7");
|
||||
|
||||
err(function () {
|
||||
set.should.have.lengthOf.within(5, 7, 'blah');
|
||||
}, "blah: expected {} to have a size within 5..7");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size within 5..7");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -629,9 +629,9 @@ describe('should', function() {
|
|||
var now = new Date();
|
||||
var oneSecondBefore = new Date(now.getTime() - 1000);
|
||||
var oneSecondAfter = new Date(now.getTime() + 1000);
|
||||
var nowUTC = now.toUTCString();
|
||||
var beforeUTC = oneSecondBefore.toUTCString();
|
||||
var afterUTC = oneSecondAfter.toUTCString();
|
||||
var nowISO = now.toISOString();
|
||||
var beforeISO = oneSecondBefore.toISOString();
|
||||
var afterISO = oneSecondAfter.toISOString();
|
||||
|
||||
now.should.be.within(oneSecondBefore, oneSecondAfter);
|
||||
now.should.be.within(now, oneSecondAfter);
|
||||
|
@ -640,11 +640,11 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
now.should.not.be.within(now, oneSecondAfter, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to not be within " + nowUTC + ".." + afterUTC);
|
||||
}, "blah: expected " + nowISO + " to not be within " + nowISO + ".." + afterISO);
|
||||
|
||||
err(function(){
|
||||
oneSecondBefore.should.be.within(now, oneSecondAfter, 'blah');
|
||||
}, "blah: expected " + beforeUTC + " to be within " + nowUTC + ".." + afterUTC);
|
||||
}, "blah: expected " + beforeISO + " to be within " + nowISO + ".." + afterISO);
|
||||
|
||||
err(function(){
|
||||
([]).should.have.length.within(now, 100, 'blah');
|
||||
|
@ -652,11 +652,11 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
now.should.have.lengthOf.within(50, now, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to have property 'length'");
|
||||
}, "blah: expected " + nowISO + " to have property 'length'");
|
||||
|
||||
err(function () {
|
||||
now.should.have.length.within(5, 7);
|
||||
}, "expected " + nowUTC + " to have property 'length'");
|
||||
}, "expected " + nowISO + " to have property 'length'");
|
||||
|
||||
err(function () {
|
||||
(0).should.be.within(0, now, 'blah');
|
||||
|
@ -743,11 +743,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
map.should.have.length.above(5, 'blah');
|
||||
}, "blah: expected {} to have a size above 5 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size above 5 but got 3");
|
||||
|
||||
err(function () {
|
||||
map.should.have.lengthOf.above(5, 'blah');
|
||||
}, "blah: expected {} to have a size above 5 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size above 5 but got 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -764,11 +764,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
set.should.have.length.above(5, 'blah');
|
||||
}, "blah: expected {} to have a size above 5 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size above 5 but got 3");
|
||||
|
||||
err(function () {
|
||||
set.should.have.lengthOf.above(5, 'blah');
|
||||
}, "blah: expected {} to have a size above 5 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size above 5 but got 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -784,15 +784,15 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
now.should.be.above(oneSecondAfter, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to be above " + oneSecondAfter.toUTCString());
|
||||
}, "blah: expected " + now.toISOString() + " to be above " + oneSecondAfter.toISOString());
|
||||
|
||||
err(function(){
|
||||
now.should.not.be.above(oneSecondAgo, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to be at most " + oneSecondAgo.toUTCString());
|
||||
}, "blah: expected " + now.toISOString() + " to be at most " + oneSecondAgo.toISOString());
|
||||
|
||||
err(function(){
|
||||
now.should.have.length.above(3, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to have property 'length'");
|
||||
}, "blah: expected " + now.toISOString() + " to have property 'length'");
|
||||
|
||||
err(function(){
|
||||
('string').should.have.length.above(now, 'blah');
|
||||
|
@ -865,11 +865,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
map.should.have.length.of.at.least(4, 'blah');
|
||||
}, "blah: expected {} to have a size at least 4 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size at least 4 but got 3");
|
||||
|
||||
err(function () {
|
||||
map.should.have.lengthOf.at.least(4, 'blah');
|
||||
}, "blah: expected {} to have a size at least 4 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size at least 4 but got 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -886,11 +886,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
set.should.have.length.of.at.least(4, 'blah');
|
||||
}, "blah: expected {} to have a size at least 4 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size at least 4 but got 3");
|
||||
|
||||
err(function () {
|
||||
set.should.have.lengthOf.at.least(4, 'blah');
|
||||
}, "blah: expected {} to have a size at least 4 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size at least 4 but got 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -954,11 +954,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
map.should.have.length.below(2, 'blah');
|
||||
}, "blah: expected {} to have a size below 2 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size below 2 but got 3");
|
||||
|
||||
err(function () {
|
||||
map.should.have.lengthOf.below(2, 'blah');
|
||||
}, "blah: expected {} to have a size below 2 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size below 2 but got 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -975,11 +975,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
set.should.have.length.below(2, 'blah');
|
||||
}, "blah: expected {} to have a size below 2 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size below 2 but got 3");
|
||||
|
||||
err(function () {
|
||||
set.should.have.lengthOf.below(2, 'blah');
|
||||
}, "blah: expected {} to have a size below 2 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size below 2 but got 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -995,15 +995,15 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
now.should.be.below(now, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to be below " + now.toUTCString());
|
||||
}, "blah: expected " + now.toISOString() + " to be below " + now.toISOString());
|
||||
|
||||
err(function(){
|
||||
now.should.not.be.below(oneSecondAfter, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to be at least " + oneSecondAfter.toUTCString());
|
||||
}, "blah: expected " + now.toISOString() + " to be at least " + oneSecondAfter.toISOString());
|
||||
|
||||
err(function(){
|
||||
now.should.have.length.below(3, 'blah');
|
||||
}, "blah: expected " + now.toUTCString() + " to have property 'length'");
|
||||
}, "blah: expected " + now.toISOString() + " to have property 'length'");
|
||||
|
||||
err(function () {
|
||||
now.should.be.below(null, 'blah');
|
||||
|
@ -1084,11 +1084,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
map.should.have.length.of.at.most(2, 'blah');
|
||||
}, "blah: expected {} to have a size at most 2 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size at most 2 but got 3");
|
||||
|
||||
err(function () {
|
||||
map.should.have.lengthOf.at.most(2, 'blah');
|
||||
}, "blah: expected {} to have a size at most 2 but got 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to have a size at most 2 but got 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -1105,11 +1105,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
set.should.have.length.of.at.most(2, 'blah');
|
||||
}, "blah: expected {} to have a size at most 2 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size at most 2 but got 3");
|
||||
|
||||
err(function () {
|
||||
set.should.have.lengthOf.at.most(2, 'blah');
|
||||
}, "blah: expected {} to have a size at most 2 but got 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to have a size at most 2 but got 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1117,9 +1117,9 @@ describe('should', function() {
|
|||
var now = new Date();
|
||||
var oneSecondBefore = new Date(now.getTime() - 1000);
|
||||
var oneSecondAfter = new Date(now.getTime() + 1000);
|
||||
var nowUTC = now.toUTCString();
|
||||
var beforeUTC = oneSecondBefore.toUTCString();
|
||||
var afterUTC = oneSecondAfter.toUTCString();
|
||||
var nowISO = now.toISOString();
|
||||
var beforeISO = oneSecondBefore.toISOString();
|
||||
var afterISO = oneSecondAfter.toISOString();
|
||||
|
||||
now.should.be.at.most(now);
|
||||
now.should.be.at.most(oneSecondAfter);
|
||||
|
@ -1127,11 +1127,11 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
now.should.be.at.most(oneSecondBefore, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to be at most " + beforeUTC);
|
||||
}, "blah: expected " + nowISO + " to be at most " + beforeISO);
|
||||
|
||||
err(function(){
|
||||
now.should.not.be.at.most(oneSecondAfter, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to be above " + afterUTC);
|
||||
}, "blah: expected " + nowISO + " to be above " + afterISO);
|
||||
|
||||
err(function(){
|
||||
([]).should.have.length.of.at.most(now, 'blah');
|
||||
|
@ -1143,11 +1143,11 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
now.should.have.length.of.at.most(0, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to have property 'length'");
|
||||
}, "blah: expected " + nowISO + " to have property 'length'");
|
||||
|
||||
err(function () {
|
||||
now.should.not.have.lengthOf.at.most(0, 'blah');
|
||||
}, "blah: expected " + nowUTC + " to have property 'length'");
|
||||
}, "blah: expected " + nowISO + " to have property 'length'");
|
||||
|
||||
err(function () {
|
||||
now.should.be.at.most(0, 'blah');
|
||||
|
@ -1217,11 +1217,11 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
map.should.not.have.length(3, 'blah');
|
||||
}, "blah: expected {} to not have a size of 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to not have a size of 3");
|
||||
|
||||
err(function(){
|
||||
map.should.not.have.lengthOf(3, 'blah');
|
||||
}, "blah: expected {} to not have a size of 3");
|
||||
}, "blah: expected Map{ 'a' => 1, 'b' => 2, 'c' => 3 } to not have a size of 3");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -1238,11 +1238,11 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
set.should.not.have.length(3, 'blah');
|
||||
}, "blah: expected {} to not have a size of 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to not have a size of 3");
|
||||
|
||||
err(function(){
|
||||
set.should.not.have.lengthOf(3, 'blah');;
|
||||
}, "blah: expected {} to not have a size of 3");
|
||||
}, "blah: expected Set{ 1, 2, 3 } to not have a size of 3");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1343,7 +1343,7 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
(new Map).should.not.be.empty;
|
||||
}, "expected {} not to be empty");
|
||||
}, "expected Map{} not to be empty");
|
||||
|
||||
map = new Map;
|
||||
map.key = 'val';
|
||||
|
@ -1351,7 +1351,7 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
map.should.not.be.empty;
|
||||
}, "expected { key: 'val' } not to be empty");
|
||||
}, "expected Map{} not to be empty");
|
||||
}
|
||||
|
||||
if (typeof Set === 'function') {
|
||||
|
@ -1364,7 +1364,7 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
(new Set).should.not.be.empty;
|
||||
}, "expected {} not to be empty");
|
||||
}, "expected Set{} not to be empty");
|
||||
|
||||
set = new Set;
|
||||
set.key = 'val';
|
||||
|
@ -1372,7 +1372,7 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
set.should.not.be.empty;
|
||||
}, "expected { key: 'val' } not to be empty");
|
||||
}, "expected Set{} not to be empty");
|
||||
}
|
||||
|
||||
err(function(){
|
||||
|
@ -1393,11 +1393,11 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
(new FakeArgs).should.not.be.empty;
|
||||
}, "expected { length: 0 } not to be empty");
|
||||
}, "expected FakeArgs{} not to be empty");
|
||||
|
||||
err(function(){
|
||||
({arguments: 0}).should.be.empty;
|
||||
}, "expected { arguments: 0 } to be empty");
|
||||
}, "expected { arguments: +0 } to be empty");
|
||||
|
||||
err(function(){
|
||||
({}).should.not.be.empty;
|
||||
|
@ -1409,7 +1409,7 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
(0).should.be.empty;
|
||||
}, ".empty was passed non-string primitive 0");
|
||||
}, ".empty was passed non-string primitive +0");
|
||||
|
||||
err(function(){
|
||||
(1).should.be.empty;
|
||||
|
@ -1507,7 +1507,7 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
'asd'.should.have.property('constructor', Number, 'blah');
|
||||
}, "blah: expected 'asd' to have property 'constructor' of [Function: Number], but got [Function: String]");
|
||||
}, "blah: expected 'asd' to have property 'constructor' of [Function Number], but got [Function String]");
|
||||
|
||||
err(function() {
|
||||
({a: {b: 1}}).should.have.own.nested.property("a.b", 1, 'blah');
|
||||
|
@ -2064,15 +2064,15 @@ describe('should', function() {
|
|||
|
||||
err(function () {
|
||||
({a: {b: [{x: 1}]}}).should.deep.nested.include({'a.b[0]': {y: 2}}, 'blah');
|
||||
}, "blah: expected { a: { b: [ [Object] ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
}, "blah: expected { a: { b: [ { x: 1 } ] } } to have deep nested property 'a.b[0]' of { y: 2 }, but got { x: 1 }");
|
||||
|
||||
err(function () {
|
||||
({a: {b: [{x: 1}]}}).should.deep.nested.include({'a.c': {x: 1}});
|
||||
}, "expected { a: { b: [ [Object] ] } } to have deep nested property 'a.c'");
|
||||
}, "expected { a: { b: [ { x: 1 } ] } } to have deep nested property 'a.c'");
|
||||
|
||||
err(function () {
|
||||
({a: {b: [{x: 1}]}}).should.not.deep.nested.include({'a.b[0]': {x: 1}}, 'blah');
|
||||
}, "blah: expected { a: { b: [ [Object] ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
|
||||
}, "blah: expected { a: { b: [ { x: 1 } ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
|
||||
});
|
||||
|
||||
it('own.include()', function () {
|
||||
|
@ -2668,103 +2668,103 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
(goodFn).should.throw();
|
||||
}, /^expected \[Function(: goodFn)*\] to throw an error$/);
|
||||
}, /^expected \[Function( goodFn)*\] to throw an error$/);
|
||||
|
||||
err(function(){
|
||||
(goodFn).should.throw(ReferenceError);
|
||||
}, /^expected \[Function(: goodFn)*\] to throw ReferenceError$/);
|
||||
}, /^expected \[Function( goodFn)*\] to throw ReferenceError$/);
|
||||
|
||||
err(function(){
|
||||
(goodFn).should.throw(specificError);
|
||||
}, /^expected \[Function(: goodFn)*\] to throw 'RangeError: boo'$/);
|
||||
}, /^expected \[Function( goodFn)*\] to throw 'RangeError: boo'$/);
|
||||
|
||||
err(function(){
|
||||
(badFn).should.not.throw();
|
||||
}, /^expected \[Function(: badFn)*\] to not throw an error but 'Error: testing' was thrown$/);
|
||||
}, /^expected \[Function( badFn)*\] to not throw an error but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(badFn).should.throw(ReferenceError);
|
||||
}, /^expected \[Function(: badFn)*\] to throw 'ReferenceError' but 'Error: testing' was thrown$/);
|
||||
}, /^expected \[Function( badFn)*\] to throw 'ReferenceError' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(badFn).should.throw(specificError);
|
||||
}, /^expected \[Function(: badFn)*\] to throw 'RangeError: boo' but 'Error: testing' was thrown$/);
|
||||
}, /^expected \[Function( badFn)*\] to throw 'RangeError: boo' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(badFn).should.not.throw(Error);
|
||||
}, /^expected \[Function(: badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
}, /^expected \[Function( badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(stringErrFn).should.not.throw();
|
||||
}, /^expected \[Function(: stringErrFn)*\] to not throw an error but 'testing' was thrown$/);
|
||||
}, /^expected \[Function( stringErrFn)*\] to not throw an error but 'testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(stringErrFn).should.throw(ReferenceError);
|
||||
}, /^expected \[Function(: stringErrFn)*\] to throw 'ReferenceError' but 'testing' was thrown$/);
|
||||
}, /^expected \[Function( stringErrFn)*\] to throw 'ReferenceError' but 'testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(stringErrFn).should.throw(specificError);
|
||||
}, /^expected \[Function(: stringErrFn)*\] to throw 'RangeError: boo' but 'testing' was thrown$/);
|
||||
}, /^expected \[Function( stringErrFn)*\] to throw 'RangeError: boo' but 'testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(stringErrFn).should.not.throw('testing');
|
||||
}, /^expected \[Function(: stringErrFn)*\] to throw error not including 'testing'$/);
|
||||
}, /^expected \[Function( stringErrFn)*\] to throw error not including 'testing'$/);
|
||||
|
||||
err(function(){
|
||||
(refErrFn).should.not.throw(ReferenceError);
|
||||
}, /^expected \[Function(: refErrFn)*\] to not throw 'ReferenceError' but 'ReferenceError: hello' was thrown$/);
|
||||
}, /^expected \[Function( refErrFn)*\] to not throw 'ReferenceError' but 'ReferenceError: hello' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(badFn).should.throw(PoorlyConstructedError);
|
||||
}, /^expected \[Function(: badFn)*\] to throw 'PoorlyConstructedError' but 'Error: testing' was thrown$/);
|
||||
}, /^expected \[Function( badFn)*\] to throw 'PoorlyConstructedError' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(ickyErrFn).should.not.throw(PoorlyConstructedError);
|
||||
}, /^(expected \[Function(: ickyErrFn)*\] to not throw 'PoorlyConstructedError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
||||
}, /^(expected \[Function( ickyErrFn)*\] to not throw 'PoorlyConstructedError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
||||
|
||||
err(function(){
|
||||
(ickyErrFn).should.throw(ReferenceError);
|
||||
}, /^(expected \[Function(: ickyErrFn)*\] to throw 'ReferenceError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
||||
}, /^(expected \[Function( ickyErrFn)*\] to throw 'ReferenceError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/);
|
||||
|
||||
err(function(){
|
||||
(specificErrFn).should.throw(new ReferenceError('eek'));
|
||||
}, /^expected \[Function(: specificErrFn)*\] to throw 'ReferenceError: eek' but 'RangeError: boo' was thrown$/);
|
||||
}, /^expected \[Function( specificErrFn)*\] to throw 'ReferenceError: eek' but 'RangeError: boo' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(specificErrFn).should.not.throw(specificError);
|
||||
}, /^expected \[Function(: specificErrFn)*\] to not throw 'RangeError: boo'$/);
|
||||
}, /^expected \[Function( specificErrFn)*\] to not throw 'RangeError: boo'$/);
|
||||
|
||||
err(function (){
|
||||
(badFn).should.not.throw(/testing/);
|
||||
}, /^expected \[Function(: badFn)*\] to throw error not matching \/testing\/$/);
|
||||
}, /^expected \[Function( badFn)*\] to throw error not matching \/testing\/$/);
|
||||
|
||||
err(function () {
|
||||
(badFn).should.throw(/hello/);
|
||||
}, /^expected \[Function(: badFn)*\] to throw error matching \/hello\/ but got \'testing\'$/);
|
||||
}, /^expected \[Function( badFn)*\] to throw error matching \/hello\/ but got \'testing\'$/);
|
||||
|
||||
err(function () {
|
||||
(badFn).should.throw(Error, /hello/, 'blah');
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw error matching \/hello\/ but got 'testing'$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw error matching \/hello\/ but got 'testing'$/);
|
||||
|
||||
err(function () {
|
||||
(badFn).should.throw(Error, 'hello', 'blah');
|
||||
}, /^blah: expected \[Function(: badFn)*\] to throw error including 'hello' but got 'testing'$/);
|
||||
}, /^blah: expected \[Function( badFn)*\] to throw error including 'hello' but got 'testing'$/);
|
||||
|
||||
err(function () {
|
||||
(customErrFn).should.not.throw();
|
||||
}, /^expected \[Function(: customErrFn)*\] to not throw an error but 'CustomError: foo' was thrown$/);
|
||||
}, /^expected \[Function( customErrFn)*\] to not throw an error but 'CustomError: foo' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(badFn).should.not.throw(Error, 'testing');
|
||||
}, /^expected \[Function(: badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
}, /^expected \[Function( badFn)*\] to not throw 'Error' but 'Error: testing' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(emptyStringErrFn).should.not.throw(Error, '');
|
||||
}, /^expected \[Function(: emptyStringErrFn)*\] to not throw 'Error' but 'Error' was thrown$/);
|
||||
}, /^expected \[Function( emptyStringErrFn)*\] to not throw 'Error' but 'Error' was thrown$/);
|
||||
|
||||
err(function(){
|
||||
(emptyStringErrFn).should.not.throw('');
|
||||
}, /^expected \[Function(: emptyStringErrFn)*\] to throw error not including ''$/);
|
||||
}, /^expected \[Function( emptyStringErrFn)*\] to throw error not including ''$/);
|
||||
|
||||
err(function () {
|
||||
({}).should.throw();
|
||||
|
@ -2792,7 +2792,7 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
Foo.should.respondTo('baz', 'constructor');
|
||||
}, /^(constructor: expected)(.*)(\[Function: Foo\])(.*)(to respond to \'baz\')$/);
|
||||
}, /^(constructor: expected)(.*)(\[Function Foo\])(.*)(to respond to \'baz\')$/);
|
||||
|
||||
err(function(){
|
||||
bar.should.respondTo('baz', 'object');
|
||||
|
@ -2808,7 +2808,7 @@ describe('should', function() {
|
|||
|
||||
err(function(){
|
||||
(2).should.satisfy(matcher, 'blah');
|
||||
}, /^blah: expected 2 to satisfy \[Function(: matcher)*\]$/);
|
||||
}, /^blah: expected 2 to satisfy \[Function( matcher)*\]$/);
|
||||
});
|
||||
|
||||
it('closeTo', function(){
|
||||
|
|
|
@ -769,7 +769,7 @@ describe('utilities', function () {
|
|||
it('inspect every kind of available TypedArray', function () {
|
||||
chai.use(function (_chai, _) {
|
||||
var arr = [1, 2, 3]
|
||||
, exp = '[ 1, 2, 3 ]'
|
||||
, exp = 'Array[ 1, 2, 3 ]'
|
||||
, isNode = true;
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
|
@ -780,24 +780,24 @@ describe('utilities', function () {
|
|||
if ((!isNode && 'Int8Array' in window) ||
|
||||
isNode && typeof 'Int8Array' !== undefined) {
|
||||
// Typed array inspections should work as array inspections do
|
||||
expect(_.inspect(new Int8Array(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Uint8Array(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Int16Array(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Uint16Array(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Int32Array(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Uint32Array(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Float32Array(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Int8Array(arr))).to.include(exp);
|
||||
expect(_.inspect(new Uint8Array(arr))).to.include(exp);
|
||||
expect(_.inspect(new Int16Array(arr))).to.include(exp);
|
||||
expect(_.inspect(new Uint16Array(arr))).to.include(exp);
|
||||
expect(_.inspect(new Int32Array(arr))).to.include(exp);
|
||||
expect(_.inspect(new Uint32Array(arr))).to.include(exp);
|
||||
expect(_.inspect(new Float32Array(arr))).to.include(exp);
|
||||
}
|
||||
|
||||
// These ones may not be available alongside the others above
|
||||
if ((!isNode && 'Uint8ClampedArray' in window) ||
|
||||
isNode && typeof 'Uint8ClampedArray' !== undefined) {
|
||||
expect(_.inspect(new Uint8ClampedArray(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Uint8ClampedArray(arr))).to.include(exp);
|
||||
}
|
||||
|
||||
if ((!isNode && 'Float64Array' in window) ||
|
||||
isNode && typeof 'Float64Array' !== undefined) {
|
||||
expect(_.inspect(new Float64Array(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Float64Array(arr))).to.include(exp);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -817,7 +817,7 @@ describe('utilities', function () {
|
|||
chai.use(function (_chai, _) {
|
||||
|
||||
var arr = []
|
||||
, exp = '[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... ]'
|
||||
, exp = 'Int8Array[ 1, 2, 3, 4, 5, 6, 7, …(993) ]'
|
||||
, isNode = true;
|
||||
|
||||
// Filling arr with lots of elements
|
||||
|
@ -831,7 +831,7 @@ describe('utilities', function () {
|
|||
|
||||
if ((!isNode && 'Int8Array' in window) ||
|
||||
isNode && typeof 'Int8Array' !== undefined) {
|
||||
expect(_.inspect(new Int8Array(arr))).to.equal(exp);
|
||||
expect(_.inspect(new Int8Array(arr))).to.include(exp);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue