ende 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/component.json +1 -4
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +2 -2
- data/lib/assets/javascripts/aura/extensions/states.js.coffee +12 -2
- data/lib/assets/javascripts/config/load_components.js.coffee +19 -10
- data/lib/assets/javascripts/ende.js.coffee +1 -1
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/ende_build.js +186 -197
- data/vendor/components/indefinido-indemma/build/development.js +26041 -43
- data/vendor/components/indefinido-indemma/build/release.js +4172 -5
- data/vendor/components/indefinido-indemma/build/test.js +26104 -21867
- data/vendor/components/indefinido-indemma/lib/record/validatable.js +192 -204
- data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +0 -2
- data/vendor/components/indefinido-observable/component.json +1 -1
- data/vendor/components/indefinido-observable/lib/observable.js +3 -2
- metadata +2 -4
- data/vendor/assets/components/build.css +0 -111
- data/vendor/components/indefinido-indemma/.gitignore~ +0 -2
@@ -26,10 +26,14 @@ function require(path, parent, orig) {
|
|
26
26
|
// perform real require()
|
27
27
|
// by invoking the module's
|
28
28
|
// registered function
|
29
|
-
if (!module.exports) {
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
if (!module._resolving && !module.exports) {
|
30
|
+
var mod = {};
|
31
|
+
mod.exports = {};
|
32
|
+
mod.client = mod.component = true;
|
33
|
+
module._resolving = true;
|
34
|
+
module.call(this, mod.exports, require.relative(resolved), mod);
|
35
|
+
delete module._resolving;
|
36
|
+
module.exports = mod.exports;
|
33
37
|
}
|
34
38
|
|
35
39
|
return module.exports;
|
@@ -15071,6 +15075,4124 @@ exports.mixin = function(object) {
|
|
15071
15075
|
return $.extend(object, mixin);
|
15072
15076
|
};
|
15073
15077
|
|
15078
|
+
});
|
15079
|
+
require.register("chaijs-assertion-error/index.js", function(exports, require, module){
|
15080
|
+
/*!
|
15081
|
+
* assertion-error
|
15082
|
+
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
|
15083
|
+
* MIT Licensed
|
15084
|
+
*/
|
15085
|
+
|
15086
|
+
/*!
|
15087
|
+
* Return a function that will copy properties from
|
15088
|
+
* one object to another excluding any originally
|
15089
|
+
* listed. Returned function will create a new `{}`.
|
15090
|
+
*
|
15091
|
+
* @param {String} excluded properties ...
|
15092
|
+
* @return {Function}
|
15093
|
+
*/
|
15094
|
+
|
15095
|
+
function exclude () {
|
15096
|
+
var excludes = [].slice.call(arguments);
|
15097
|
+
|
15098
|
+
function excludeProps (res, obj) {
|
15099
|
+
Object.keys(obj).forEach(function (key) {
|
15100
|
+
if (!~excludes.indexOf(key)) res[key] = obj[key];
|
15101
|
+
});
|
15102
|
+
}
|
15103
|
+
|
15104
|
+
return function extendExclude () {
|
15105
|
+
var args = [].slice.call(arguments)
|
15106
|
+
, i = 0
|
15107
|
+
, res = {};
|
15108
|
+
|
15109
|
+
for (; i < args.length; i++) {
|
15110
|
+
excludeProps(res, args[i]);
|
15111
|
+
}
|
15112
|
+
|
15113
|
+
return res;
|
15114
|
+
};
|
15115
|
+
};
|
15116
|
+
|
15117
|
+
/*!
|
15118
|
+
* Primary Exports
|
15119
|
+
*/
|
15120
|
+
|
15121
|
+
module.exports = AssertionError;
|
15122
|
+
|
15123
|
+
/**
|
15124
|
+
* ### AssertionError
|
15125
|
+
*
|
15126
|
+
* An extension of the JavaScript `Error` constructor for
|
15127
|
+
* assertion and validation scenarios.
|
15128
|
+
*
|
15129
|
+
* @param {String} message
|
15130
|
+
* @param {Object} properties to include (optional)
|
15131
|
+
* @param {callee} start stack function (optional)
|
15132
|
+
*/
|
15133
|
+
|
15134
|
+
function AssertionError (message, _props, ssf) {
|
15135
|
+
var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
|
15136
|
+
, props = extend(_props || {});
|
15137
|
+
|
15138
|
+
// default values
|
15139
|
+
this.message = message || 'Unspecified AssertionError';
|
15140
|
+
this.showDiff = false;
|
15141
|
+
|
15142
|
+
// copy from properties
|
15143
|
+
for (var key in props) {
|
15144
|
+
this[key] = props[key];
|
15145
|
+
}
|
15146
|
+
|
15147
|
+
// capture stack trace
|
15148
|
+
ssf = ssf || arguments.callee;
|
15149
|
+
if (ssf && Error.captureStackTrace) {
|
15150
|
+
Error.captureStackTrace(this, ssf);
|
15151
|
+
}
|
15152
|
+
}
|
15153
|
+
|
15154
|
+
/*!
|
15155
|
+
* Inherit from Error.prototype
|
15156
|
+
*/
|
15157
|
+
|
15158
|
+
AssertionError.prototype = Object.create(Error.prototype);
|
15159
|
+
|
15160
|
+
/*!
|
15161
|
+
* Statically set name
|
15162
|
+
*/
|
15163
|
+
|
15164
|
+
AssertionError.prototype.name = 'AssertionError';
|
15165
|
+
|
15166
|
+
/*!
|
15167
|
+
* Ensure correct constructor
|
15168
|
+
*/
|
15169
|
+
|
15170
|
+
AssertionError.prototype.constructor = AssertionError;
|
15171
|
+
|
15172
|
+
/**
|
15173
|
+
* Allow errors to be converted to JSON for static transfer.
|
15174
|
+
*
|
15175
|
+
* @param {Boolean} include stack (default: `true`)
|
15176
|
+
* @return {Object} object that can be `JSON.stringify`
|
15177
|
+
*/
|
15178
|
+
|
15179
|
+
AssertionError.prototype.toJSON = function (stack) {
|
15180
|
+
var extend = exclude('constructor', 'toJSON', 'stack')
|
15181
|
+
, props = extend({ name: this.name }, this);
|
15182
|
+
|
15183
|
+
// include stack if exists and not turned off
|
15184
|
+
if (false !== stack && this.stack) {
|
15185
|
+
props.stack = this.stack;
|
15186
|
+
}
|
15187
|
+
|
15188
|
+
return props;
|
15189
|
+
};
|
15190
|
+
|
15191
|
+
});
|
15192
|
+
require.register("chaijs-chai/index.js", function(exports, require, module){
|
15193
|
+
module.exports = require('./lib/chai');
|
15194
|
+
|
15195
|
+
});
|
15196
|
+
require.register("chaijs-chai/lib/chai.js", function(exports, require, module){
|
15197
|
+
/*!
|
15198
|
+
* chai
|
15199
|
+
* Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
|
15200
|
+
* MIT Licensed
|
15201
|
+
*/
|
15202
|
+
|
15203
|
+
var used = []
|
15204
|
+
, exports = module.exports = {};
|
15205
|
+
|
15206
|
+
/*!
|
15207
|
+
* Chai version
|
15208
|
+
*/
|
15209
|
+
|
15210
|
+
exports.version = '1.7.2';
|
15211
|
+
|
15212
|
+
/*!
|
15213
|
+
* Assertion Error
|
15214
|
+
*/
|
15215
|
+
|
15216
|
+
exports.AssertionError = require('assertion-error');
|
15217
|
+
|
15218
|
+
/*!
|
15219
|
+
* Utils for plugins (not exported)
|
15220
|
+
*/
|
15221
|
+
|
15222
|
+
var util = require('./chai/utils');
|
15223
|
+
|
15224
|
+
/**
|
15225
|
+
* # .use(function)
|
15226
|
+
*
|
15227
|
+
* Provides a way to extend the internals of Chai
|
15228
|
+
*
|
15229
|
+
* @param {Function}
|
15230
|
+
* @returns {this} for chaining
|
15231
|
+
* @api public
|
15232
|
+
*/
|
15233
|
+
|
15234
|
+
exports.use = function (fn) {
|
15235
|
+
if (!~used.indexOf(fn)) {
|
15236
|
+
fn(this, util);
|
15237
|
+
used.push(fn);
|
15238
|
+
}
|
15239
|
+
|
15240
|
+
return this;
|
15241
|
+
};
|
15242
|
+
|
15243
|
+
/*!
|
15244
|
+
* Primary `Assertion` prototype
|
15245
|
+
*/
|
15246
|
+
|
15247
|
+
var assertion = require('./chai/assertion');
|
15248
|
+
exports.use(assertion);
|
15249
|
+
|
15250
|
+
/*!
|
15251
|
+
* Core Assertions
|
15252
|
+
*/
|
15253
|
+
|
15254
|
+
var core = require('./chai/core/assertions');
|
15255
|
+
exports.use(core);
|
15256
|
+
|
15257
|
+
/*!
|
15258
|
+
* Expect interface
|
15259
|
+
*/
|
15260
|
+
|
15261
|
+
var expect = require('./chai/interface/expect');
|
15262
|
+
exports.use(expect);
|
15263
|
+
|
15264
|
+
/*!
|
15265
|
+
* Should interface
|
15266
|
+
*/
|
15267
|
+
|
15268
|
+
var should = require('./chai/interface/should');
|
15269
|
+
exports.use(should);
|
15270
|
+
|
15271
|
+
/*!
|
15272
|
+
* Assert interface
|
15273
|
+
*/
|
15274
|
+
|
15275
|
+
var assert = require('./chai/interface/assert');
|
15276
|
+
exports.use(assert);
|
15277
|
+
|
15278
|
+
});
|
15279
|
+
require.register("chaijs-chai/lib/chai/assertion.js", function(exports, require, module){
|
15280
|
+
/*!
|
15281
|
+
* chai
|
15282
|
+
* http://chaijs.com
|
15283
|
+
* Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
|
15284
|
+
* MIT Licensed
|
15285
|
+
*/
|
15286
|
+
|
15287
|
+
module.exports = function (_chai, util) {
|
15288
|
+
/*!
|
15289
|
+
* Module dependencies.
|
15290
|
+
*/
|
15291
|
+
|
15292
|
+
var AssertionError = _chai.AssertionError
|
15293
|
+
, flag = util.flag;
|
15294
|
+
|
15295
|
+
/*!
|
15296
|
+
* Module export.
|
15297
|
+
*/
|
15298
|
+
|
15299
|
+
_chai.Assertion = Assertion;
|
15300
|
+
|
15301
|
+
/*!
|
15302
|
+
* Assertion Constructor
|
15303
|
+
*
|
15304
|
+
* Creates object for chaining.
|
15305
|
+
*
|
15306
|
+
* @api private
|
15307
|
+
*/
|
15308
|
+
|
15309
|
+
function Assertion (obj, msg, stack) {
|
15310
|
+
flag(this, 'ssfi', stack || arguments.callee);
|
15311
|
+
flag(this, 'object', obj);
|
15312
|
+
flag(this, 'message', msg);
|
15313
|
+
}
|
15314
|
+
|
15315
|
+
/*!
|
15316
|
+
* ### Assertion.includeStack
|
15317
|
+
*
|
15318
|
+
* User configurable property, influences whether stack trace
|
15319
|
+
* is included in Assertion error message. Default of false
|
15320
|
+
* suppresses stack trace in the error message
|
15321
|
+
*
|
15322
|
+
* Assertion.includeStack = true; // enable stack on error
|
15323
|
+
*
|
15324
|
+
* @api public
|
15325
|
+
*/
|
15326
|
+
|
15327
|
+
Assertion.includeStack = false;
|
15328
|
+
|
15329
|
+
/*!
|
15330
|
+
* ### Assertion.showDiff
|
15331
|
+
*
|
15332
|
+
* User configurable property, influences whether or not
|
15333
|
+
* the `showDiff` flag should be included in the thrown
|
15334
|
+
* AssertionErrors. `false` will always be `false`; `true`
|
15335
|
+
* will be true when the assertion has requested a diff
|
15336
|
+
* be shown.
|
15337
|
+
*
|
15338
|
+
* @api public
|
15339
|
+
*/
|
15340
|
+
|
15341
|
+
Assertion.showDiff = true;
|
15342
|
+
|
15343
|
+
Assertion.addProperty = function (name, fn) {
|
15344
|
+
util.addProperty(this.prototype, name, fn);
|
15345
|
+
};
|
15346
|
+
|
15347
|
+
Assertion.addMethod = function (name, fn) {
|
15348
|
+
util.addMethod(this.prototype, name, fn);
|
15349
|
+
};
|
15350
|
+
|
15351
|
+
Assertion.addChainableMethod = function (name, fn, chainingBehavior) {
|
15352
|
+
util.addChainableMethod(this.prototype, name, fn, chainingBehavior);
|
15353
|
+
};
|
15354
|
+
|
15355
|
+
Assertion.overwriteProperty = function (name, fn) {
|
15356
|
+
util.overwriteProperty(this.prototype, name, fn);
|
15357
|
+
};
|
15358
|
+
|
15359
|
+
Assertion.overwriteMethod = function (name, fn) {
|
15360
|
+
util.overwriteMethod(this.prototype, name, fn);
|
15361
|
+
};
|
15362
|
+
|
15363
|
+
/*!
|
15364
|
+
* ### .assert(expression, message, negateMessage, expected, actual)
|
15365
|
+
*
|
15366
|
+
* Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
|
15367
|
+
*
|
15368
|
+
* @name assert
|
15369
|
+
* @param {Philosophical} expression to be tested
|
15370
|
+
* @param {String} message to display if fails
|
15371
|
+
* @param {String} negatedMessage to display if negated expression fails
|
15372
|
+
* @param {Mixed} expected value (remember to check for negation)
|
15373
|
+
* @param {Mixed} actual (optional) will default to `this.obj`
|
15374
|
+
* @api private
|
15375
|
+
*/
|
15376
|
+
|
15377
|
+
Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
|
15378
|
+
var ok = util.test(this, arguments);
|
15379
|
+
if (true !== showDiff) showDiff = false;
|
15380
|
+
if (true !== Assertion.showDiff) showDiff = false;
|
15381
|
+
|
15382
|
+
if (!ok) {
|
15383
|
+
var msg = util.getMessage(this, arguments)
|
15384
|
+
, actual = util.getActual(this, arguments);
|
15385
|
+
throw new AssertionError(msg, {
|
15386
|
+
actual: actual
|
15387
|
+
, expected: expected
|
15388
|
+
, showDiff: showDiff
|
15389
|
+
}, (Assertion.includeStack) ? this.assert : flag(this, 'ssfi'));
|
15390
|
+
}
|
15391
|
+
};
|
15392
|
+
|
15393
|
+
/*!
|
15394
|
+
* ### ._obj
|
15395
|
+
*
|
15396
|
+
* Quick reference to stored `actual` value for plugin developers.
|
15397
|
+
*
|
15398
|
+
* @api private
|
15399
|
+
*/
|
15400
|
+
|
15401
|
+
Object.defineProperty(Assertion.prototype, '_obj',
|
15402
|
+
{ get: function () {
|
15403
|
+
return flag(this, 'object');
|
15404
|
+
}
|
15405
|
+
, set: function (val) {
|
15406
|
+
flag(this, 'object', val);
|
15407
|
+
}
|
15408
|
+
});
|
15409
|
+
};
|
15410
|
+
|
15411
|
+
});
|
15412
|
+
require.register("chaijs-chai/lib/chai/core/assertions.js", function(exports, require, module){
|
15413
|
+
/*!
|
15414
|
+
* chai
|
15415
|
+
* http://chaijs.com
|
15416
|
+
* Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
|
15417
|
+
* MIT Licensed
|
15418
|
+
*/
|
15419
|
+
|
15420
|
+
module.exports = function (chai, _) {
|
15421
|
+
var Assertion = chai.Assertion
|
15422
|
+
, toString = Object.prototype.toString
|
15423
|
+
, flag = _.flag;
|
15424
|
+
|
15425
|
+
/**
|
15426
|
+
* ### Language Chains
|
15427
|
+
*
|
15428
|
+
* The following are provide as chainable getters to
|
15429
|
+
* improve the readability of your assertions. They
|
15430
|
+
* do not provide an testing capability unless they
|
15431
|
+
* have been overwritten by a plugin.
|
15432
|
+
*
|
15433
|
+
* **Chains**
|
15434
|
+
*
|
15435
|
+
* - to
|
15436
|
+
* - be
|
15437
|
+
* - been
|
15438
|
+
* - is
|
15439
|
+
* - that
|
15440
|
+
* - and
|
15441
|
+
* - have
|
15442
|
+
* - with
|
15443
|
+
* - at
|
15444
|
+
* - of
|
15445
|
+
* - same
|
15446
|
+
*
|
15447
|
+
* @name language chains
|
15448
|
+
* @api public
|
15449
|
+
*/
|
15450
|
+
|
15451
|
+
[ 'to', 'be', 'been'
|
15452
|
+
, 'is', 'and', 'have'
|
15453
|
+
, 'with', 'that', 'at'
|
15454
|
+
, 'of', 'same' ].forEach(function (chain) {
|
15455
|
+
Assertion.addProperty(chain, function () {
|
15456
|
+
return this;
|
15457
|
+
});
|
15458
|
+
});
|
15459
|
+
|
15460
|
+
/**
|
15461
|
+
* ### .not
|
15462
|
+
*
|
15463
|
+
* Negates any of assertions following in the chain.
|
15464
|
+
*
|
15465
|
+
* expect(foo).to.not.equal('bar');
|
15466
|
+
* expect(goodFn).to.not.throw(Error);
|
15467
|
+
* expect({ foo: 'baz' }).to.have.property('foo')
|
15468
|
+
* .and.not.equal('bar');
|
15469
|
+
*
|
15470
|
+
* @name not
|
15471
|
+
* @api public
|
15472
|
+
*/
|
15473
|
+
|
15474
|
+
Assertion.addProperty('not', function () {
|
15475
|
+
flag(this, 'negate', true);
|
15476
|
+
});
|
15477
|
+
|
15478
|
+
/**
|
15479
|
+
* ### .deep
|
15480
|
+
*
|
15481
|
+
* Sets the `deep` flag, later used by the `equal` and
|
15482
|
+
* `property` assertions.
|
15483
|
+
*
|
15484
|
+
* expect(foo).to.deep.equal({ bar: 'baz' });
|
15485
|
+
* expect({ foo: { bar: { baz: 'quux' } } })
|
15486
|
+
* .to.have.deep.property('foo.bar.baz', 'quux');
|
15487
|
+
*
|
15488
|
+
* @name deep
|
15489
|
+
* @api public
|
15490
|
+
*/
|
15491
|
+
|
15492
|
+
Assertion.addProperty('deep', function () {
|
15493
|
+
flag(this, 'deep', true);
|
15494
|
+
});
|
15495
|
+
|
15496
|
+
/**
|
15497
|
+
* ### .a(type)
|
15498
|
+
*
|
15499
|
+
* The `a` and `an` assertions are aliases that can be
|
15500
|
+
* used either as language chains or to assert a value's
|
15501
|
+
* type.
|
15502
|
+
*
|
15503
|
+
* // typeof
|
15504
|
+
* expect('test').to.be.a('string');
|
15505
|
+
* expect({ foo: 'bar' }).to.be.an('object');
|
15506
|
+
* expect(null).to.be.a('null');
|
15507
|
+
* expect(undefined).to.be.an('undefined');
|
15508
|
+
*
|
15509
|
+
* // language chain
|
15510
|
+
* expect(foo).to.be.an.instanceof(Foo);
|
15511
|
+
*
|
15512
|
+
* @name a
|
15513
|
+
* @alias an
|
15514
|
+
* @param {String} type
|
15515
|
+
* @param {String} message _optional_
|
15516
|
+
* @api public
|
15517
|
+
*/
|
15518
|
+
|
15519
|
+
function an (type, msg) {
|
15520
|
+
if (msg) flag(this, 'message', msg);
|
15521
|
+
type = type.toLowerCase();
|
15522
|
+
var obj = flag(this, 'object')
|
15523
|
+
, article = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(type.charAt(0)) ? 'an ' : 'a ';
|
15524
|
+
|
15525
|
+
this.assert(
|
15526
|
+
type === _.type(obj)
|
15527
|
+
, 'expected #{this} to be ' + article + type
|
15528
|
+
, 'expected #{this} not to be ' + article + type
|
15529
|
+
);
|
15530
|
+
}
|
15531
|
+
|
15532
|
+
Assertion.addChainableMethod('an', an);
|
15533
|
+
Assertion.addChainableMethod('a', an);
|
15534
|
+
|
15535
|
+
/**
|
15536
|
+
* ### .include(value)
|
15537
|
+
*
|
15538
|
+
* The `include` and `contain` assertions can be used as either property
|
15539
|
+
* based language chains or as methods to assert the inclusion of an object
|
15540
|
+
* in an array or a substring in a string. When used as language chains,
|
15541
|
+
* they toggle the `contain` flag for the `keys` assertion.
|
15542
|
+
*
|
15543
|
+
* expect([1,2,3]).to.include(2);
|
15544
|
+
* expect('foobar').to.contain('foo');
|
15545
|
+
* expect({ foo: 'bar', hello: 'universe' }).to.include.keys('foo');
|
15546
|
+
*
|
15547
|
+
* @name include
|
15548
|
+
* @alias contain
|
15549
|
+
* @param {Object|String|Number} obj
|
15550
|
+
* @param {String} message _optional_
|
15551
|
+
* @api public
|
15552
|
+
*/
|
15553
|
+
|
15554
|
+
function includeChainingBehavior () {
|
15555
|
+
flag(this, 'contains', true);
|
15556
|
+
}
|
15557
|
+
|
15558
|
+
function include (val, msg) {
|
15559
|
+
if (msg) flag(this, 'message', msg);
|
15560
|
+
var obj = flag(this, 'object')
|
15561
|
+
this.assert(
|
15562
|
+
~obj.indexOf(val)
|
15563
|
+
, 'expected #{this} to include ' + _.inspect(val)
|
15564
|
+
, 'expected #{this} to not include ' + _.inspect(val));
|
15565
|
+
}
|
15566
|
+
|
15567
|
+
Assertion.addChainableMethod('include', include, includeChainingBehavior);
|
15568
|
+
Assertion.addChainableMethod('contain', include, includeChainingBehavior);
|
15569
|
+
|
15570
|
+
/**
|
15571
|
+
* ### .ok
|
15572
|
+
*
|
15573
|
+
* Asserts that the target is truthy.
|
15574
|
+
*
|
15575
|
+
* expect('everthing').to.be.ok;
|
15576
|
+
* expect(1).to.be.ok;
|
15577
|
+
* expect(false).to.not.be.ok;
|
15578
|
+
* expect(undefined).to.not.be.ok;
|
15579
|
+
* expect(null).to.not.be.ok;
|
15580
|
+
*
|
15581
|
+
* @name ok
|
15582
|
+
* @api public
|
15583
|
+
*/
|
15584
|
+
|
15585
|
+
Assertion.addProperty('ok', function () {
|
15586
|
+
this.assert(
|
15587
|
+
flag(this, 'object')
|
15588
|
+
, 'expected #{this} to be truthy'
|
15589
|
+
, 'expected #{this} to be falsy');
|
15590
|
+
});
|
15591
|
+
|
15592
|
+
/**
|
15593
|
+
* ### .true
|
15594
|
+
*
|
15595
|
+
* Asserts that the target is `true`.
|
15596
|
+
*
|
15597
|
+
* expect(true).to.be.true;
|
15598
|
+
* expect(1).to.not.be.true;
|
15599
|
+
*
|
15600
|
+
* @name true
|
15601
|
+
* @api public
|
15602
|
+
*/
|
15603
|
+
|
15604
|
+
Assertion.addProperty('true', function () {
|
15605
|
+
this.assert(
|
15606
|
+
true === flag(this, 'object')
|
15607
|
+
, 'expected #{this} to be true'
|
15608
|
+
, 'expected #{this} to be false'
|
15609
|
+
, this.negate ? false : true
|
15610
|
+
);
|
15611
|
+
});
|
15612
|
+
|
15613
|
+
/**
|
15614
|
+
* ### .false
|
15615
|
+
*
|
15616
|
+
* Asserts that the target is `false`.
|
15617
|
+
*
|
15618
|
+
* expect(false).to.be.false;
|
15619
|
+
* expect(0).to.not.be.false;
|
15620
|
+
*
|
15621
|
+
* @name false
|
15622
|
+
* @api public
|
15623
|
+
*/
|
15624
|
+
|
15625
|
+
Assertion.addProperty('false', function () {
|
15626
|
+
this.assert(
|
15627
|
+
false === flag(this, 'object')
|
15628
|
+
, 'expected #{this} to be false'
|
15629
|
+
, 'expected #{this} to be true'
|
15630
|
+
, this.negate ? true : false
|
15631
|
+
);
|
15632
|
+
});
|
15633
|
+
|
15634
|
+
/**
|
15635
|
+
* ### .null
|
15636
|
+
*
|
15637
|
+
* Asserts that the target is `null`.
|
15638
|
+
*
|
15639
|
+
* expect(null).to.be.null;
|
15640
|
+
* expect(undefined).not.to.be.null;
|
15641
|
+
*
|
15642
|
+
* @name null
|
15643
|
+
* @api public
|
15644
|
+
*/
|
15645
|
+
|
15646
|
+
Assertion.addProperty('null', function () {
|
15647
|
+
this.assert(
|
15648
|
+
null === flag(this, 'object')
|
15649
|
+
, 'expected #{this} to be null'
|
15650
|
+
, 'expected #{this} not to be null'
|
15651
|
+
);
|
15652
|
+
});
|
15653
|
+
|
15654
|
+
/**
|
15655
|
+
* ### .undefined
|
15656
|
+
*
|
15657
|
+
* Asserts that the target is `undefined`.
|
15658
|
+
*
|
15659
|
+
* expect(undefined).to.be.undefined;
|
15660
|
+
* expect(null).to.not.be.undefined;
|
15661
|
+
*
|
15662
|
+
* @name undefined
|
15663
|
+
* @api public
|
15664
|
+
*/
|
15665
|
+
|
15666
|
+
Assertion.addProperty('undefined', function () {
|
15667
|
+
this.assert(
|
15668
|
+
undefined === flag(this, 'object')
|
15669
|
+
, 'expected #{this} to be undefined'
|
15670
|
+
, 'expected #{this} not to be undefined'
|
15671
|
+
);
|
15672
|
+
});
|
15673
|
+
|
15674
|
+
/**
|
15675
|
+
* ### .exist
|
15676
|
+
*
|
15677
|
+
* Asserts that the target is neither `null` nor `undefined`.
|
15678
|
+
*
|
15679
|
+
* var foo = 'hi'
|
15680
|
+
* , bar = null
|
15681
|
+
* , baz;
|
15682
|
+
*
|
15683
|
+
* expect(foo).to.exist;
|
15684
|
+
* expect(bar).to.not.exist;
|
15685
|
+
* expect(baz).to.not.exist;
|
15686
|
+
*
|
15687
|
+
* @name exist
|
15688
|
+
* @api public
|
15689
|
+
*/
|
15690
|
+
|
15691
|
+
Assertion.addProperty('exist', function () {
|
15692
|
+
this.assert(
|
15693
|
+
null != flag(this, 'object')
|
15694
|
+
, 'expected #{this} to exist'
|
15695
|
+
, 'expected #{this} to not exist'
|
15696
|
+
);
|
15697
|
+
});
|
15698
|
+
|
15699
|
+
|
15700
|
+
/**
|
15701
|
+
* ### .empty
|
15702
|
+
*
|
15703
|
+
* Asserts that the target's length is `0`. For arrays, it checks
|
15704
|
+
* the `length` property. For objects, it gets the count of
|
15705
|
+
* enumerable keys.
|
15706
|
+
*
|
15707
|
+
* expect([]).to.be.empty;
|
15708
|
+
* expect('').to.be.empty;
|
15709
|
+
* expect({}).to.be.empty;
|
15710
|
+
*
|
15711
|
+
* @name empty
|
15712
|
+
* @api public
|
15713
|
+
*/
|
15714
|
+
|
15715
|
+
Assertion.addProperty('empty', function () {
|
15716
|
+
var obj = flag(this, 'object')
|
15717
|
+
, expected = obj;
|
15718
|
+
|
15719
|
+
if (Array.isArray(obj) || 'string' === typeof object) {
|
15720
|
+
expected = obj.length;
|
15721
|
+
} else if (typeof obj === 'object') {
|
15722
|
+
expected = Object.keys(obj).length;
|
15723
|
+
}
|
15724
|
+
|
15725
|
+
this.assert(
|
15726
|
+
!expected
|
15727
|
+
, 'expected #{this} to be empty'
|
15728
|
+
, 'expected #{this} not to be empty'
|
15729
|
+
);
|
15730
|
+
});
|
15731
|
+
|
15732
|
+
/**
|
15733
|
+
* ### .arguments
|
15734
|
+
*
|
15735
|
+
* Asserts that the target is an arguments object.
|
15736
|
+
*
|
15737
|
+
* function test () {
|
15738
|
+
* expect(arguments).to.be.arguments;
|
15739
|
+
* }
|
15740
|
+
*
|
15741
|
+
* @name arguments
|
15742
|
+
* @alias Arguments
|
15743
|
+
* @api public
|
15744
|
+
*/
|
15745
|
+
|
15746
|
+
function checkArguments () {
|
15747
|
+
var obj = flag(this, 'object')
|
15748
|
+
, type = Object.prototype.toString.call(obj);
|
15749
|
+
this.assert(
|
15750
|
+
'[object Arguments]' === type
|
15751
|
+
, 'expected #{this} to be arguments but got ' + type
|
15752
|
+
, 'expected #{this} to not be arguments'
|
15753
|
+
);
|
15754
|
+
}
|
15755
|
+
|
15756
|
+
Assertion.addProperty('arguments', checkArguments);
|
15757
|
+
Assertion.addProperty('Arguments', checkArguments);
|
15758
|
+
|
15759
|
+
/**
|
15760
|
+
* ### .equal(value)
|
15761
|
+
*
|
15762
|
+
* Asserts that the target is strictly equal (`===`) to `value`.
|
15763
|
+
* Alternately, if the `deep` flag is set, asserts that
|
15764
|
+
* the target is deeply equal to `value`.
|
15765
|
+
*
|
15766
|
+
* expect('hello').to.equal('hello');
|
15767
|
+
* expect(42).to.equal(42);
|
15768
|
+
* expect(1).to.not.equal(true);
|
15769
|
+
* expect({ foo: 'bar' }).to.not.equal({ foo: 'bar' });
|
15770
|
+
* expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
|
15771
|
+
*
|
15772
|
+
* @name equal
|
15773
|
+
* @alias equals
|
15774
|
+
* @alias eq
|
15775
|
+
* @alias deep.equal
|
15776
|
+
* @param {Mixed} value
|
15777
|
+
* @param {String} message _optional_
|
15778
|
+
* @api public
|
15779
|
+
*/
|
15780
|
+
|
15781
|
+
function assertEqual (val, msg) {
|
15782
|
+
if (msg) flag(this, 'message', msg);
|
15783
|
+
var obj = flag(this, 'object');
|
15784
|
+
if (flag(this, 'deep')) {
|
15785
|
+
return this.eql(val);
|
15786
|
+
} else {
|
15787
|
+
this.assert(
|
15788
|
+
val === obj
|
15789
|
+
, 'expected #{this} to equal #{exp}'
|
15790
|
+
, 'expected #{this} to not equal #{exp}'
|
15791
|
+
, val
|
15792
|
+
, this._obj
|
15793
|
+
, true
|
15794
|
+
);
|
15795
|
+
}
|
15796
|
+
}
|
15797
|
+
|
15798
|
+
Assertion.addMethod('equal', assertEqual);
|
15799
|
+
Assertion.addMethod('equals', assertEqual);
|
15800
|
+
Assertion.addMethod('eq', assertEqual);
|
15801
|
+
|
15802
|
+
/**
|
15803
|
+
* ### .eql(value)
|
15804
|
+
*
|
15805
|
+
* Asserts that the target is deeply equal to `value`.
|
15806
|
+
*
|
15807
|
+
* expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
|
15808
|
+
* expect([ 1, 2, 3 ]).to.eql([ 1, 2, 3 ]);
|
15809
|
+
*
|
15810
|
+
* @name eql
|
15811
|
+
* @alias eqls
|
15812
|
+
* @param {Mixed} value
|
15813
|
+
* @param {String} message _optional_
|
15814
|
+
* @api public
|
15815
|
+
*/
|
15816
|
+
|
15817
|
+
function assertEql(obj, msg) {
|
15818
|
+
if (msg) flag(this, 'message', msg);
|
15819
|
+
this.assert(
|
15820
|
+
_.eql(obj, flag(this, 'object'))
|
15821
|
+
, 'expected #{this} to deeply equal #{exp}'
|
15822
|
+
, 'expected #{this} to not deeply equal #{exp}'
|
15823
|
+
, obj
|
15824
|
+
, this._obj
|
15825
|
+
, true
|
15826
|
+
);
|
15827
|
+
}
|
15828
|
+
|
15829
|
+
Assertion.addMethod('eql', assertEql);
|
15830
|
+
Assertion.addMethod('eqls', assertEql);
|
15831
|
+
|
15832
|
+
/**
|
15833
|
+
* ### .above(value)
|
15834
|
+
*
|
15835
|
+
* Asserts that the target is greater than `value`.
|
15836
|
+
*
|
15837
|
+
* expect(10).to.be.above(5);
|
15838
|
+
*
|
15839
|
+
* Can also be used in conjunction with `length` to
|
15840
|
+
* assert a minimum length. The benefit being a
|
15841
|
+
* more informative error message than if the length
|
15842
|
+
* was supplied directly.
|
15843
|
+
*
|
15844
|
+
* expect('foo').to.have.length.above(2);
|
15845
|
+
* expect([ 1, 2, 3 ]).to.have.length.above(2);
|
15846
|
+
*
|
15847
|
+
* @name above
|
15848
|
+
* @alias gt
|
15849
|
+
* @alias greaterThan
|
15850
|
+
* @param {Number} value
|
15851
|
+
* @param {String} message _optional_
|
15852
|
+
* @api public
|
15853
|
+
*/
|
15854
|
+
|
15855
|
+
function assertAbove (n, msg) {
|
15856
|
+
if (msg) flag(this, 'message', msg);
|
15857
|
+
var obj = flag(this, 'object');
|
15858
|
+
if (flag(this, 'doLength')) {
|
15859
|
+
new Assertion(obj, msg).to.have.property('length');
|
15860
|
+
var len = obj.length;
|
15861
|
+
this.assert(
|
15862
|
+
len > n
|
15863
|
+
, 'expected #{this} to have a length above #{exp} but got #{act}'
|
15864
|
+
, 'expected #{this} to not have a length above #{exp}'
|
15865
|
+
, n
|
15866
|
+
, len
|
15867
|
+
);
|
15868
|
+
} else {
|
15869
|
+
this.assert(
|
15870
|
+
obj > n
|
15871
|
+
, 'expected #{this} to be above ' + n
|
15872
|
+
, 'expected #{this} to be at most ' + n
|
15873
|
+
);
|
15874
|
+
}
|
15875
|
+
}
|
15876
|
+
|
15877
|
+
Assertion.addMethod('above', assertAbove);
|
15878
|
+
Assertion.addMethod('gt', assertAbove);
|
15879
|
+
Assertion.addMethod('greaterThan', assertAbove);
|
15880
|
+
|
15881
|
+
/**
|
15882
|
+
* ### .least(value)
|
15883
|
+
*
|
15884
|
+
* Asserts that the target is greater than or equal to `value`.
|
15885
|
+
*
|
15886
|
+
* expect(10).to.be.at.least(10);
|
15887
|
+
*
|
15888
|
+
* Can also be used in conjunction with `length` to
|
15889
|
+
* assert a minimum length. The benefit being a
|
15890
|
+
* more informative error message than if the length
|
15891
|
+
* was supplied directly.
|
15892
|
+
*
|
15893
|
+
* expect('foo').to.have.length.of.at.least(2);
|
15894
|
+
* expect([ 1, 2, 3 ]).to.have.length.of.at.least(3);
|
15895
|
+
*
|
15896
|
+
* @name least
|
15897
|
+
* @alias gte
|
15898
|
+
* @param {Number} value
|
15899
|
+
* @param {String} message _optional_
|
15900
|
+
* @api public
|
15901
|
+
*/
|
15902
|
+
|
15903
|
+
function assertLeast (n, msg) {
|
15904
|
+
if (msg) flag(this, 'message', msg);
|
15905
|
+
var obj = flag(this, 'object');
|
15906
|
+
if (flag(this, 'doLength')) {
|
15907
|
+
new Assertion(obj, msg).to.have.property('length');
|
15908
|
+
var len = obj.length;
|
15909
|
+
this.assert(
|
15910
|
+
len >= n
|
15911
|
+
, 'expected #{this} to have a length at least #{exp} but got #{act}'
|
15912
|
+
, 'expected #{this} to have a length below #{exp}'
|
15913
|
+
, n
|
15914
|
+
, len
|
15915
|
+
);
|
15916
|
+
} else {
|
15917
|
+
this.assert(
|
15918
|
+
obj >= n
|
15919
|
+
, 'expected #{this} to be at least ' + n
|
15920
|
+
, 'expected #{this} to be below ' + n
|
15921
|
+
);
|
15922
|
+
}
|
15923
|
+
}
|
15924
|
+
|
15925
|
+
Assertion.addMethod('least', assertLeast);
|
15926
|
+
Assertion.addMethod('gte', assertLeast);
|
15927
|
+
|
15928
|
+
/**
|
15929
|
+
* ### .below(value)
|
15930
|
+
*
|
15931
|
+
* Asserts that the target is less than `value`.
|
15932
|
+
*
|
15933
|
+
* expect(5).to.be.below(10);
|
15934
|
+
*
|
15935
|
+
* Can also be used in conjunction with `length` to
|
15936
|
+
* assert a maximum length. The benefit being a
|
15937
|
+
* more informative error message than if the length
|
15938
|
+
* was supplied directly.
|
15939
|
+
*
|
15940
|
+
* expect('foo').to.have.length.below(4);
|
15941
|
+
* expect([ 1, 2, 3 ]).to.have.length.below(4);
|
15942
|
+
*
|
15943
|
+
* @name below
|
15944
|
+
* @alias lt
|
15945
|
+
* @alias lessThan
|
15946
|
+
* @param {Number} value
|
15947
|
+
* @param {String} message _optional_
|
15948
|
+
* @api public
|
15949
|
+
*/
|
15950
|
+
|
15951
|
+
function assertBelow (n, msg) {
|
15952
|
+
if (msg) flag(this, 'message', msg);
|
15953
|
+
var obj = flag(this, 'object');
|
15954
|
+
if (flag(this, 'doLength')) {
|
15955
|
+
new Assertion(obj, msg).to.have.property('length');
|
15956
|
+
var len = obj.length;
|
15957
|
+
this.assert(
|
15958
|
+
len < n
|
15959
|
+
, 'expected #{this} to have a length below #{exp} but got #{act}'
|
15960
|
+
, 'expected #{this} to not have a length below #{exp}'
|
15961
|
+
, n
|
15962
|
+
, len
|
15963
|
+
);
|
15964
|
+
} else {
|
15965
|
+
this.assert(
|
15966
|
+
obj < n
|
15967
|
+
, 'expected #{this} to be below ' + n
|
15968
|
+
, 'expected #{this} to be at least ' + n
|
15969
|
+
);
|
15970
|
+
}
|
15971
|
+
}
|
15972
|
+
|
15973
|
+
Assertion.addMethod('below', assertBelow);
|
15974
|
+
Assertion.addMethod('lt', assertBelow);
|
15975
|
+
Assertion.addMethod('lessThan', assertBelow);
|
15976
|
+
|
15977
|
+
/**
|
15978
|
+
* ### .most(value)
|
15979
|
+
*
|
15980
|
+
* Asserts that the target is less than or equal to `value`.
|
15981
|
+
*
|
15982
|
+
* expect(5).to.be.at.most(5);
|
15983
|
+
*
|
15984
|
+
* Can also be used in conjunction with `length` to
|
15985
|
+
* assert a maximum length. The benefit being a
|
15986
|
+
* more informative error message than if the length
|
15987
|
+
* was supplied directly.
|
15988
|
+
*
|
15989
|
+
* expect('foo').to.have.length.of.at.most(4);
|
15990
|
+
* expect([ 1, 2, 3 ]).to.have.length.of.at.most(3);
|
15991
|
+
*
|
15992
|
+
* @name most
|
15993
|
+
* @alias lte
|
15994
|
+
* @param {Number} value
|
15995
|
+
* @param {String} message _optional_
|
15996
|
+
* @api public
|
15997
|
+
*/
|
15998
|
+
|
15999
|
+
function assertMost (n, msg) {
|
16000
|
+
if (msg) flag(this, 'message', msg);
|
16001
|
+
var obj = flag(this, 'object');
|
16002
|
+
if (flag(this, 'doLength')) {
|
16003
|
+
new Assertion(obj, msg).to.have.property('length');
|
16004
|
+
var len = obj.length;
|
16005
|
+
this.assert(
|
16006
|
+
len <= n
|
16007
|
+
, 'expected #{this} to have a length at most #{exp} but got #{act}'
|
16008
|
+
, 'expected #{this} to have a length above #{exp}'
|
16009
|
+
, n
|
16010
|
+
, len
|
16011
|
+
);
|
16012
|
+
} else {
|
16013
|
+
this.assert(
|
16014
|
+
obj <= n
|
16015
|
+
, 'expected #{this} to be at most ' + n
|
16016
|
+
, 'expected #{this} to be above ' + n
|
16017
|
+
);
|
16018
|
+
}
|
16019
|
+
}
|
16020
|
+
|
16021
|
+
Assertion.addMethod('most', assertMost);
|
16022
|
+
Assertion.addMethod('lte', assertMost);
|
16023
|
+
|
16024
|
+
/**
|
16025
|
+
* ### .within(start, finish)
|
16026
|
+
*
|
16027
|
+
* Asserts that the target is within a range.
|
16028
|
+
*
|
16029
|
+
* expect(7).to.be.within(5,10);
|
16030
|
+
*
|
16031
|
+
* Can also be used in conjunction with `length` to
|
16032
|
+
* assert a length range. The benefit being a
|
16033
|
+
* more informative error message than if the length
|
16034
|
+
* was supplied directly.
|
16035
|
+
*
|
16036
|
+
* expect('foo').to.have.length.within(2,4);
|
16037
|
+
* expect([ 1, 2, 3 ]).to.have.length.within(2,4);
|
16038
|
+
*
|
16039
|
+
* @name within
|
16040
|
+
* @param {Number} start lowerbound inclusive
|
16041
|
+
* @param {Number} finish upperbound inclusive
|
16042
|
+
* @param {String} message _optional_
|
16043
|
+
* @api public
|
16044
|
+
*/
|
16045
|
+
|
16046
|
+
Assertion.addMethod('within', function (start, finish, msg) {
|
16047
|
+
if (msg) flag(this, 'message', msg);
|
16048
|
+
var obj = flag(this, 'object')
|
16049
|
+
, range = start + '..' + finish;
|
16050
|
+
if (flag(this, 'doLength')) {
|
16051
|
+
new Assertion(obj, msg).to.have.property('length');
|
16052
|
+
var len = obj.length;
|
16053
|
+
this.assert(
|
16054
|
+
len >= start && len <= finish
|
16055
|
+
, 'expected #{this} to have a length within ' + range
|
16056
|
+
, 'expected #{this} to not have a length within ' + range
|
16057
|
+
);
|
16058
|
+
} else {
|
16059
|
+
this.assert(
|
16060
|
+
obj >= start && obj <= finish
|
16061
|
+
, 'expected #{this} to be within ' + range
|
16062
|
+
, 'expected #{this} to not be within ' + range
|
16063
|
+
);
|
16064
|
+
}
|
16065
|
+
});
|
16066
|
+
|
16067
|
+
/**
|
16068
|
+
* ### .instanceof(constructor)
|
16069
|
+
*
|
16070
|
+
* Asserts that the target is an instance of `constructor`.
|
16071
|
+
*
|
16072
|
+
* var Tea = function (name) { this.name = name; }
|
16073
|
+
* , Chai = new Tea('chai');
|
16074
|
+
*
|
16075
|
+
* expect(Chai).to.be.an.instanceof(Tea);
|
16076
|
+
* expect([ 1, 2, 3 ]).to.be.instanceof(Array);
|
16077
|
+
*
|
16078
|
+
* @name instanceof
|
16079
|
+
* @param {Constructor} constructor
|
16080
|
+
* @param {String} message _optional_
|
16081
|
+
* @alias instanceOf
|
16082
|
+
* @api public
|
16083
|
+
*/
|
16084
|
+
|
16085
|
+
function assertInstanceOf (constructor, msg) {
|
16086
|
+
if (msg) flag(this, 'message', msg);
|
16087
|
+
var name = _.getName(constructor);
|
16088
|
+
this.assert(
|
16089
|
+
flag(this, 'object') instanceof constructor
|
16090
|
+
, 'expected #{this} to be an instance of ' + name
|
16091
|
+
, 'expected #{this} to not be an instance of ' + name
|
16092
|
+
);
|
16093
|
+
};
|
16094
|
+
|
16095
|
+
Assertion.addMethod('instanceof', assertInstanceOf);
|
16096
|
+
Assertion.addMethod('instanceOf', assertInstanceOf);
|
16097
|
+
|
16098
|
+
/**
|
16099
|
+
* ### .property(name, [value])
|
16100
|
+
*
|
16101
|
+
* Asserts that the target has a property `name`, optionally asserting that
|
16102
|
+
* the value of that property is strictly equal to `value`.
|
16103
|
+
* If the `deep` flag is set, you can use dot- and bracket-notation for deep
|
16104
|
+
* references into objects and arrays.
|
16105
|
+
*
|
16106
|
+
* // simple referencing
|
16107
|
+
* var obj = { foo: 'bar' };
|
16108
|
+
* expect(obj).to.have.property('foo');
|
16109
|
+
* expect(obj).to.have.property('foo', 'bar');
|
16110
|
+
*
|
16111
|
+
* // deep referencing
|
16112
|
+
* var deepObj = {
|
16113
|
+
* green: { tea: 'matcha' }
|
16114
|
+
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
|
16115
|
+
* };
|
16116
|
+
|
16117
|
+
* expect(deepObj).to.have.deep.property('green.tea', 'matcha');
|
16118
|
+
* expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
|
16119
|
+
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
|
16120
|
+
*
|
16121
|
+
* You can also use an array as the starting point of a `deep.property`
|
16122
|
+
* assertion, or traverse nested arrays.
|
16123
|
+
*
|
16124
|
+
* var arr = [
|
16125
|
+
* [ 'chai', 'matcha', 'konacha' ]
|
16126
|
+
* , [ { tea: 'chai' }
|
16127
|
+
* , { tea: 'matcha' }
|
16128
|
+
* , { tea: 'konacha' } ]
|
16129
|
+
* ];
|
16130
|
+
*
|
16131
|
+
* expect(arr).to.have.deep.property('[0][1]', 'matcha');
|
16132
|
+
* expect(arr).to.have.deep.property('[1][2].tea', 'konacha');
|
16133
|
+
*
|
16134
|
+
* Furthermore, `property` changes the subject of the assertion
|
16135
|
+
* to be the value of that property from the original object. This
|
16136
|
+
* permits for further chainable assertions on that property.
|
16137
|
+
*
|
16138
|
+
* expect(obj).to.have.property('foo')
|
16139
|
+
* .that.is.a('string');
|
16140
|
+
* expect(deepObj).to.have.property('green')
|
16141
|
+
* .that.is.an('object')
|
16142
|
+
* .that.deep.equals({ tea: 'matcha' });
|
16143
|
+
* expect(deepObj).to.have.property('teas')
|
16144
|
+
* .that.is.an('array')
|
16145
|
+
* .with.deep.property('[2]')
|
16146
|
+
* .that.deep.equals({ tea: 'konacha' });
|
16147
|
+
*
|
16148
|
+
* @name property
|
16149
|
+
* @alias deep.property
|
16150
|
+
* @param {String} name
|
16151
|
+
* @param {Mixed} value (optional)
|
16152
|
+
* @param {String} message _optional_
|
16153
|
+
* @returns value of property for chaining
|
16154
|
+
* @api public
|
16155
|
+
*/
|
16156
|
+
|
16157
|
+
Assertion.addMethod('property', function (name, val, msg) {
|
16158
|
+
if (msg) flag(this, 'message', msg);
|
16159
|
+
|
16160
|
+
var descriptor = flag(this, 'deep') ? 'deep property ' : 'property '
|
16161
|
+
, negate = flag(this, 'negate')
|
16162
|
+
, obj = flag(this, 'object')
|
16163
|
+
, value = flag(this, 'deep')
|
16164
|
+
? _.getPathValue(name, obj)
|
16165
|
+
: obj[name];
|
16166
|
+
|
16167
|
+
if (negate && undefined !== val) {
|
16168
|
+
if (undefined === value) {
|
16169
|
+
msg = (msg != null) ? msg + ': ' : '';
|
16170
|
+
throw new Error(msg + _.inspect(obj) + ' has no ' + descriptor + _.inspect(name));
|
16171
|
+
}
|
16172
|
+
} else {
|
16173
|
+
this.assert(
|
16174
|
+
undefined !== value
|
16175
|
+
, 'expected #{this} to have a ' + descriptor + _.inspect(name)
|
16176
|
+
, 'expected #{this} to not have ' + descriptor + _.inspect(name));
|
16177
|
+
}
|
16178
|
+
|
16179
|
+
if (undefined !== val) {
|
16180
|
+
this.assert(
|
16181
|
+
val === value
|
16182
|
+
, 'expected #{this} to have a ' + descriptor + _.inspect(name) + ' of #{exp}, but got #{act}'
|
16183
|
+
, 'expected #{this} to not have a ' + descriptor + _.inspect(name) + ' of #{act}'
|
16184
|
+
, val
|
16185
|
+
, value
|
16186
|
+
);
|
16187
|
+
}
|
16188
|
+
|
16189
|
+
flag(this, 'object', value);
|
16190
|
+
});
|
16191
|
+
|
16192
|
+
|
16193
|
+
/**
|
16194
|
+
* ### .ownProperty(name)
|
16195
|
+
*
|
16196
|
+
* Asserts that the target has an own property `name`.
|
16197
|
+
*
|
16198
|
+
* expect('test').to.have.ownProperty('length');
|
16199
|
+
*
|
16200
|
+
* @name ownProperty
|
16201
|
+
* @alias haveOwnProperty
|
16202
|
+
* @param {String} name
|
16203
|
+
* @param {String} message _optional_
|
16204
|
+
* @api public
|
16205
|
+
*/
|
16206
|
+
|
16207
|
+
function assertOwnProperty (name, msg) {
|
16208
|
+
if (msg) flag(this, 'message', msg);
|
16209
|
+
var obj = flag(this, 'object');
|
16210
|
+
this.assert(
|
16211
|
+
obj.hasOwnProperty(name)
|
16212
|
+
, 'expected #{this} to have own property ' + _.inspect(name)
|
16213
|
+
, 'expected #{this} to not have own property ' + _.inspect(name)
|
16214
|
+
);
|
16215
|
+
}
|
16216
|
+
|
16217
|
+
Assertion.addMethod('ownProperty', assertOwnProperty);
|
16218
|
+
Assertion.addMethod('haveOwnProperty', assertOwnProperty);
|
16219
|
+
|
16220
|
+
/**
|
16221
|
+
* ### .length(value)
|
16222
|
+
*
|
16223
|
+
* Asserts that the target's `length` property has
|
16224
|
+
* the expected value.
|
16225
|
+
*
|
16226
|
+
* expect([ 1, 2, 3]).to.have.length(3);
|
16227
|
+
* expect('foobar').to.have.length(6);
|
16228
|
+
*
|
16229
|
+
* Can also be used as a chain precursor to a value
|
16230
|
+
* comparison for the length property.
|
16231
|
+
*
|
16232
|
+
* expect('foo').to.have.length.above(2);
|
16233
|
+
* expect([ 1, 2, 3 ]).to.have.length.above(2);
|
16234
|
+
* expect('foo').to.have.length.below(4);
|
16235
|
+
* expect([ 1, 2, 3 ]).to.have.length.below(4);
|
16236
|
+
* expect('foo').to.have.length.within(2,4);
|
16237
|
+
* expect([ 1, 2, 3 ]).to.have.length.within(2,4);
|
16238
|
+
*
|
16239
|
+
* @name length
|
16240
|
+
* @alias lengthOf
|
16241
|
+
* @param {Number} length
|
16242
|
+
* @param {String} message _optional_
|
16243
|
+
* @api public
|
16244
|
+
*/
|
16245
|
+
|
16246
|
+
function assertLengthChain () {
|
16247
|
+
flag(this, 'doLength', true);
|
16248
|
+
}
|
16249
|
+
|
16250
|
+
function assertLength (n, msg) {
|
16251
|
+
if (msg) flag(this, 'message', msg);
|
16252
|
+
var obj = flag(this, 'object');
|
16253
|
+
new Assertion(obj, msg).to.have.property('length');
|
16254
|
+
var len = obj.length;
|
16255
|
+
|
16256
|
+
this.assert(
|
16257
|
+
len == n
|
16258
|
+
, 'expected #{this} to have a length of #{exp} but got #{act}'
|
16259
|
+
, 'expected #{this} to not have a length of #{act}'
|
16260
|
+
, n
|
16261
|
+
, len
|
16262
|
+
);
|
16263
|
+
}
|
16264
|
+
|
16265
|
+
Assertion.addChainableMethod('length', assertLength, assertLengthChain);
|
16266
|
+
Assertion.addMethod('lengthOf', assertLength, assertLengthChain);
|
16267
|
+
|
16268
|
+
/**
|
16269
|
+
* ### .match(regexp)
|
16270
|
+
*
|
16271
|
+
* Asserts that the target matches a regular expression.
|
16272
|
+
*
|
16273
|
+
* expect('foobar').to.match(/^foo/);
|
16274
|
+
*
|
16275
|
+
* @name match
|
16276
|
+
* @param {RegExp} RegularExpression
|
16277
|
+
* @param {String} message _optional_
|
16278
|
+
* @api public
|
16279
|
+
*/
|
16280
|
+
|
16281
|
+
Assertion.addMethod('match', function (re, msg) {
|
16282
|
+
if (msg) flag(this, 'message', msg);
|
16283
|
+
var obj = flag(this, 'object');
|
16284
|
+
this.assert(
|
16285
|
+
re.exec(obj)
|
16286
|
+
, 'expected #{this} to match ' + re
|
16287
|
+
, 'expected #{this} not to match ' + re
|
16288
|
+
);
|
16289
|
+
});
|
16290
|
+
|
16291
|
+
/**
|
16292
|
+
* ### .string(string)
|
16293
|
+
*
|
16294
|
+
* Asserts that the string target contains another string.
|
16295
|
+
*
|
16296
|
+
* expect('foobar').to.have.string('bar');
|
16297
|
+
*
|
16298
|
+
* @name string
|
16299
|
+
* @param {String} string
|
16300
|
+
* @param {String} message _optional_
|
16301
|
+
* @api public
|
16302
|
+
*/
|
16303
|
+
|
16304
|
+
Assertion.addMethod('string', function (str, msg) {
|
16305
|
+
if (msg) flag(this, 'message', msg);
|
16306
|
+
var obj = flag(this, 'object');
|
16307
|
+
new Assertion(obj, msg).is.a('string');
|
16308
|
+
|
16309
|
+
this.assert(
|
16310
|
+
~obj.indexOf(str)
|
16311
|
+
, 'expected #{this} to contain ' + _.inspect(str)
|
16312
|
+
, 'expected #{this} to not contain ' + _.inspect(str)
|
16313
|
+
);
|
16314
|
+
});
|
16315
|
+
|
16316
|
+
|
16317
|
+
/**
|
16318
|
+
* ### .keys(key1, [key2], [...])
|
16319
|
+
*
|
16320
|
+
* Asserts that the target has exactly the given keys, or
|
16321
|
+
* asserts the inclusion of some keys when using the
|
16322
|
+
* `include` or `contain` modifiers.
|
16323
|
+
*
|
16324
|
+
* expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);
|
16325
|
+
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');
|
16326
|
+
*
|
16327
|
+
* @name keys
|
16328
|
+
* @alias key
|
16329
|
+
* @param {String...|Array} keys
|
16330
|
+
* @api public
|
16331
|
+
*/
|
16332
|
+
|
16333
|
+
function assertKeys (keys) {
|
16334
|
+
var obj = flag(this, 'object')
|
16335
|
+
, str
|
16336
|
+
, ok = true;
|
16337
|
+
|
16338
|
+
keys = keys instanceof Array
|
16339
|
+
? keys
|
16340
|
+
: Array.prototype.slice.call(arguments);
|
16341
|
+
|
16342
|
+
if (!keys.length) throw new Error('keys required');
|
16343
|
+
|
16344
|
+
var actual = Object.keys(obj)
|
16345
|
+
, len = keys.length;
|
16346
|
+
|
16347
|
+
// Inclusion
|
16348
|
+
ok = keys.every(function(key){
|
16349
|
+
return ~actual.indexOf(key);
|
16350
|
+
});
|
16351
|
+
|
16352
|
+
// Strict
|
16353
|
+
if (!flag(this, 'negate') && !flag(this, 'contains')) {
|
16354
|
+
ok = ok && keys.length == actual.length;
|
16355
|
+
}
|
16356
|
+
|
16357
|
+
// Key string
|
16358
|
+
if (len > 1) {
|
16359
|
+
keys = keys.map(function(key){
|
16360
|
+
return _.inspect(key);
|
16361
|
+
});
|
16362
|
+
var last = keys.pop();
|
16363
|
+
str = keys.join(', ') + ', and ' + last;
|
16364
|
+
} else {
|
16365
|
+
str = _.inspect(keys[0]);
|
16366
|
+
}
|
16367
|
+
|
16368
|
+
// Form
|
16369
|
+
str = (len > 1 ? 'keys ' : 'key ') + str;
|
16370
|
+
|
16371
|
+
// Have / include
|
16372
|
+
str = (flag(this, 'contains') ? 'contain ' : 'have ') + str;
|
16373
|
+
|
16374
|
+
// Assertion
|
16375
|
+
this.assert(
|
16376
|
+
ok
|
16377
|
+
, 'expected #{this} to ' + str
|
16378
|
+
, 'expected #{this} to not ' + str
|
16379
|
+
);
|
16380
|
+
}
|
16381
|
+
|
16382
|
+
Assertion.addMethod('keys', assertKeys);
|
16383
|
+
Assertion.addMethod('key', assertKeys);
|
16384
|
+
|
16385
|
+
/**
|
16386
|
+
* ### .throw(constructor)
|
16387
|
+
*
|
16388
|
+
* Asserts that the function target will throw a specific error, or specific type of error
|
16389
|
+
* (as determined using `instanceof`), optionally with a RegExp or string inclusion test
|
16390
|
+
* for the error's message.
|
16391
|
+
*
|
16392
|
+
* var err = new ReferenceError('This is a bad function.');
|
16393
|
+
* var fn = function () { throw err; }
|
16394
|
+
* expect(fn).to.throw(ReferenceError);
|
16395
|
+
* expect(fn).to.throw(Error);
|
16396
|
+
* expect(fn).to.throw(/bad function/);
|
16397
|
+
* expect(fn).to.not.throw('good function');
|
16398
|
+
* expect(fn).to.throw(ReferenceError, /bad function/);
|
16399
|
+
* expect(fn).to.throw(err);
|
16400
|
+
* expect(fn).to.not.throw(new RangeError('Out of range.'));
|
16401
|
+
*
|
16402
|
+
* Please note that when a throw expectation is negated, it will check each
|
16403
|
+
* parameter independently, starting with error constructor type. The appropriate way
|
16404
|
+
* to check for the existence of a type of error but for a message that does not match
|
16405
|
+
* is to use `and`.
|
16406
|
+
*
|
16407
|
+
* expect(fn).to.throw(ReferenceError)
|
16408
|
+
* .and.not.throw(/good function/);
|
16409
|
+
*
|
16410
|
+
* @name throw
|
16411
|
+
* @alias throws
|
16412
|
+
* @alias Throw
|
16413
|
+
* @param {ErrorConstructor} constructor
|
16414
|
+
* @param {String|RegExp} expected error message
|
16415
|
+
* @param {String} message _optional_
|
16416
|
+
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
16417
|
+
* @api public
|
16418
|
+
*/
|
16419
|
+
|
16420
|
+
function assertThrows (constructor, errMsg, msg) {
|
16421
|
+
if (msg) flag(this, 'message', msg);
|
16422
|
+
var obj = flag(this, 'object');
|
16423
|
+
new Assertion(obj, msg).is.a('function');
|
16424
|
+
|
16425
|
+
var thrown = false
|
16426
|
+
, desiredError = null
|
16427
|
+
, name = null
|
16428
|
+
, thrownError = null;
|
16429
|
+
|
16430
|
+
if (arguments.length === 0) {
|
16431
|
+
errMsg = null;
|
16432
|
+
constructor = null;
|
16433
|
+
} else if (constructor && (constructor instanceof RegExp || 'string' === typeof constructor)) {
|
16434
|
+
errMsg = constructor;
|
16435
|
+
constructor = null;
|
16436
|
+
} else if (constructor && constructor instanceof Error) {
|
16437
|
+
desiredError = constructor;
|
16438
|
+
constructor = null;
|
16439
|
+
errMsg = null;
|
16440
|
+
} else if (typeof constructor === 'function') {
|
16441
|
+
name = (new constructor()).name;
|
16442
|
+
} else {
|
16443
|
+
constructor = null;
|
16444
|
+
}
|
16445
|
+
|
16446
|
+
try {
|
16447
|
+
obj();
|
16448
|
+
} catch (err) {
|
16449
|
+
// first, check desired error
|
16450
|
+
if (desiredError) {
|
16451
|
+
this.assert(
|
16452
|
+
err === desiredError
|
16453
|
+
, 'expected #{this} to throw #{exp} but #{act} was thrown'
|
16454
|
+
, 'expected #{this} to not throw #{exp}'
|
16455
|
+
, desiredError
|
16456
|
+
, err
|
16457
|
+
);
|
16458
|
+
|
16459
|
+
return this;
|
16460
|
+
}
|
16461
|
+
// next, check constructor
|
16462
|
+
if (constructor) {
|
16463
|
+
this.assert(
|
16464
|
+
err instanceof constructor
|
16465
|
+
, 'expected #{this} to throw #{exp} but #{act} was thrown'
|
16466
|
+
, 'expected #{this} to not throw #{exp} but #{act} was thrown'
|
16467
|
+
, name
|
16468
|
+
, err
|
16469
|
+
);
|
16470
|
+
|
16471
|
+
if (!errMsg) return this;
|
16472
|
+
}
|
16473
|
+
// next, check message
|
16474
|
+
var message = 'object' === _.type(err) && "message" in err
|
16475
|
+
? err.message
|
16476
|
+
: '' + err;
|
16477
|
+
|
16478
|
+
if ((message != null) && errMsg && errMsg instanceof RegExp) {
|
16479
|
+
this.assert(
|
16480
|
+
errMsg.exec(message)
|
16481
|
+
, 'expected #{this} to throw error matching #{exp} but got #{act}'
|
16482
|
+
, 'expected #{this} to throw error not matching #{exp}'
|
16483
|
+
, errMsg
|
16484
|
+
, message
|
16485
|
+
);
|
16486
|
+
|
16487
|
+
return this;
|
16488
|
+
} else if ((message != null) && errMsg && 'string' === typeof errMsg) {
|
16489
|
+
this.assert(
|
16490
|
+
~message.indexOf(errMsg)
|
16491
|
+
, 'expected #{this} to throw error including #{exp} but got #{act}'
|
16492
|
+
, 'expected #{this} to throw error not including #{act}'
|
16493
|
+
, errMsg
|
16494
|
+
, message
|
16495
|
+
);
|
16496
|
+
|
16497
|
+
return this;
|
16498
|
+
} else {
|
16499
|
+
thrown = true;
|
16500
|
+
thrownError = err;
|
16501
|
+
}
|
16502
|
+
}
|
16503
|
+
|
16504
|
+
var actuallyGot = ''
|
16505
|
+
, expectedThrown = name !== null
|
16506
|
+
? name
|
16507
|
+
: desiredError
|
16508
|
+
? '#{exp}' //_.inspect(desiredError)
|
16509
|
+
: 'an error';
|
16510
|
+
|
16511
|
+
if (thrown) {
|
16512
|
+
actuallyGot = ' but #{act} was thrown'
|
16513
|
+
}
|
16514
|
+
|
16515
|
+
this.assert(
|
16516
|
+
thrown === true
|
16517
|
+
, 'expected #{this} to throw ' + expectedThrown + actuallyGot
|
16518
|
+
, 'expected #{this} to not throw ' + expectedThrown + actuallyGot
|
16519
|
+
, desiredError
|
16520
|
+
, thrownError
|
16521
|
+
);
|
16522
|
+
};
|
16523
|
+
|
16524
|
+
Assertion.addMethod('throw', assertThrows);
|
16525
|
+
Assertion.addMethod('throws', assertThrows);
|
16526
|
+
Assertion.addMethod('Throw', assertThrows);
|
16527
|
+
|
16528
|
+
/**
|
16529
|
+
* ### .respondTo(method)
|
16530
|
+
*
|
16531
|
+
* Asserts that the object or class target will respond to a method.
|
16532
|
+
*
|
16533
|
+
* Klass.prototype.bar = function(){};
|
16534
|
+
* expect(Klass).to.respondTo('bar');
|
16535
|
+
* expect(obj).to.respondTo('bar');
|
16536
|
+
*
|
16537
|
+
* To check if a constructor will respond to a static function,
|
16538
|
+
* set the `itself` flag.
|
16539
|
+
*
|
16540
|
+
* Klass.baz = function(){};
|
16541
|
+
* expect(Klass).itself.to.respondTo('baz');
|
16542
|
+
*
|
16543
|
+
* @name respondTo
|
16544
|
+
* @param {String} method
|
16545
|
+
* @param {String} message _optional_
|
16546
|
+
* @api public
|
16547
|
+
*/
|
16548
|
+
|
16549
|
+
Assertion.addMethod('respondTo', function (method, msg) {
|
16550
|
+
if (msg) flag(this, 'message', msg);
|
16551
|
+
var obj = flag(this, 'object')
|
16552
|
+
, itself = flag(this, 'itself')
|
16553
|
+
, context = ('function' === _.type(obj) && !itself)
|
16554
|
+
? obj.prototype[method]
|
16555
|
+
: obj[method];
|
16556
|
+
|
16557
|
+
this.assert(
|
16558
|
+
'function' === typeof context
|
16559
|
+
, 'expected #{this} to respond to ' + _.inspect(method)
|
16560
|
+
, 'expected #{this} to not respond to ' + _.inspect(method)
|
16561
|
+
);
|
16562
|
+
});
|
16563
|
+
|
16564
|
+
/**
|
16565
|
+
* ### .itself
|
16566
|
+
*
|
16567
|
+
* Sets the `itself` flag, later used by the `respondTo` assertion.
|
16568
|
+
*
|
16569
|
+
* function Foo() {}
|
16570
|
+
* Foo.bar = function() {}
|
16571
|
+
* Foo.prototype.baz = function() {}
|
16572
|
+
*
|
16573
|
+
* expect(Foo).itself.to.respondTo('bar');
|
16574
|
+
* expect(Foo).itself.not.to.respondTo('baz');
|
16575
|
+
*
|
16576
|
+
* @name itself
|
16577
|
+
* @api public
|
16578
|
+
*/
|
16579
|
+
|
16580
|
+
Assertion.addProperty('itself', function () {
|
16581
|
+
flag(this, 'itself', true);
|
16582
|
+
});
|
16583
|
+
|
16584
|
+
/**
|
16585
|
+
* ### .satisfy(method)
|
16586
|
+
*
|
16587
|
+
* Asserts that the target passes a given truth test.
|
16588
|
+
*
|
16589
|
+
* expect(1).to.satisfy(function(num) { return num > 0; });
|
16590
|
+
*
|
16591
|
+
* @name satisfy
|
16592
|
+
* @param {Function} matcher
|
16593
|
+
* @param {String} message _optional_
|
16594
|
+
* @api public
|
16595
|
+
*/
|
16596
|
+
|
16597
|
+
Assertion.addMethod('satisfy', function (matcher, msg) {
|
16598
|
+
if (msg) flag(this, 'message', msg);
|
16599
|
+
var obj = flag(this, 'object');
|
16600
|
+
this.assert(
|
16601
|
+
matcher(obj)
|
16602
|
+
, 'expected #{this} to satisfy ' + _.objDisplay(matcher)
|
16603
|
+
, 'expected #{this} to not satisfy' + _.objDisplay(matcher)
|
16604
|
+
, this.negate ? false : true
|
16605
|
+
, matcher(obj)
|
16606
|
+
);
|
16607
|
+
});
|
16608
|
+
|
16609
|
+
/**
|
16610
|
+
* ### .closeTo(expected, delta)
|
16611
|
+
*
|
16612
|
+
* Asserts that the target is equal `expected`, to within a +/- `delta` range.
|
16613
|
+
*
|
16614
|
+
* expect(1.5).to.be.closeTo(1, 0.5);
|
16615
|
+
*
|
16616
|
+
* @name closeTo
|
16617
|
+
* @param {Number} expected
|
16618
|
+
* @param {Number} delta
|
16619
|
+
* @param {String} message _optional_
|
16620
|
+
* @api public
|
16621
|
+
*/
|
16622
|
+
|
16623
|
+
Assertion.addMethod('closeTo', function (expected, delta, msg) {
|
16624
|
+
if (msg) flag(this, 'message', msg);
|
16625
|
+
var obj = flag(this, 'object');
|
16626
|
+
this.assert(
|
16627
|
+
Math.abs(obj - expected) <= delta
|
16628
|
+
, 'expected #{this} to be close to ' + expected + ' +/- ' + delta
|
16629
|
+
, 'expected #{this} not to be close to ' + expected + ' +/- ' + delta
|
16630
|
+
);
|
16631
|
+
});
|
16632
|
+
|
16633
|
+
function isSubsetOf(subset, superset) {
|
16634
|
+
return subset.every(function(elem) {
|
16635
|
+
return superset.indexOf(elem) !== -1;
|
16636
|
+
})
|
16637
|
+
}
|
16638
|
+
|
16639
|
+
/**
|
16640
|
+
* ### .members(set)
|
16641
|
+
*
|
16642
|
+
* Asserts that the target is a superset of `set`,
|
16643
|
+
* or that the target and `set` have the same members.
|
16644
|
+
*
|
16645
|
+
* expect([1, 2, 3]).to.include.members([3, 2]);
|
16646
|
+
* expect([1, 2, 3]).to.not.include.members([3, 2, 8]);
|
16647
|
+
*
|
16648
|
+
* expect([4, 2]).to.have.members([2, 4]);
|
16649
|
+
* expect([5, 2]).to.not.have.members([5, 2, 1]);
|
16650
|
+
*
|
16651
|
+
* @name members
|
16652
|
+
* @param {Array} set
|
16653
|
+
* @param {String} message _optional_
|
16654
|
+
* @api public
|
16655
|
+
*/
|
16656
|
+
|
16657
|
+
Assertion.addMethod('members', function (subset, msg) {
|
16658
|
+
if (msg) flag(this, 'message', msg);
|
16659
|
+
var obj = flag(this, 'object');
|
16660
|
+
|
16661
|
+
new Assertion(obj).to.be.an('array');
|
16662
|
+
new Assertion(subset).to.be.an('array');
|
16663
|
+
|
16664
|
+
if (flag(this, 'contains')) {
|
16665
|
+
return this.assert(
|
16666
|
+
isSubsetOf(subset, obj)
|
16667
|
+
, 'expected #{this} to be a superset of #{act}'
|
16668
|
+
, 'expected #{this} to not be a superset of #{act}'
|
16669
|
+
, obj
|
16670
|
+
, subset
|
16671
|
+
);
|
16672
|
+
}
|
16673
|
+
|
16674
|
+
this.assert(
|
16675
|
+
isSubsetOf(obj, subset) && isSubsetOf(subset, obj)
|
16676
|
+
, 'expected #{this} to have the same members as #{act}'
|
16677
|
+
, 'expected #{this} to not have the same members as #{act}'
|
16678
|
+
, obj
|
16679
|
+
, subset
|
16680
|
+
);
|
16681
|
+
});
|
16682
|
+
};
|
16683
|
+
|
16684
|
+
});
|
16685
|
+
require.register("chaijs-chai/lib/chai/interface/assert.js", function(exports, require, module){
|
16686
|
+
/*!
|
16687
|
+
* chai
|
16688
|
+
* Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
|
16689
|
+
* MIT Licensed
|
16690
|
+
*/
|
16691
|
+
|
16692
|
+
|
16693
|
+
module.exports = function (chai, util) {
|
16694
|
+
|
16695
|
+
/*!
|
16696
|
+
* Chai dependencies.
|
16697
|
+
*/
|
16698
|
+
|
16699
|
+
var Assertion = chai.Assertion
|
16700
|
+
, flag = util.flag;
|
16701
|
+
|
16702
|
+
/*!
|
16703
|
+
* Module export.
|
16704
|
+
*/
|
16705
|
+
|
16706
|
+
/**
|
16707
|
+
* ### assert(expression, message)
|
16708
|
+
*
|
16709
|
+
* Write your own test expressions.
|
16710
|
+
*
|
16711
|
+
* assert('foo' !== 'bar', 'foo is not bar');
|
16712
|
+
* assert(Array.isArray([]), 'empty arrays are arrays');
|
16713
|
+
*
|
16714
|
+
* @param {Mixed} expression to test for truthiness
|
16715
|
+
* @param {String} message to display on error
|
16716
|
+
* @name assert
|
16717
|
+
* @api public
|
16718
|
+
*/
|
16719
|
+
|
16720
|
+
var assert = chai.assert = function (express, errmsg) {
|
16721
|
+
var test = new Assertion(null);
|
16722
|
+
test.assert(
|
16723
|
+
express
|
16724
|
+
, errmsg
|
16725
|
+
, '[ negation message unavailable ]'
|
16726
|
+
);
|
16727
|
+
};
|
16728
|
+
|
16729
|
+
/**
|
16730
|
+
* ### .fail(actual, expected, [message], [operator])
|
16731
|
+
*
|
16732
|
+
* Throw a failure. Node.js `assert` module-compatible.
|
16733
|
+
*
|
16734
|
+
* @name fail
|
16735
|
+
* @param {Mixed} actual
|
16736
|
+
* @param {Mixed} expected
|
16737
|
+
* @param {String} message
|
16738
|
+
* @param {String} operator
|
16739
|
+
* @api public
|
16740
|
+
*/
|
16741
|
+
|
16742
|
+
assert.fail = function (actual, expected, message, operator) {
|
16743
|
+
throw new chai.AssertionError({
|
16744
|
+
actual: actual
|
16745
|
+
, expected: expected
|
16746
|
+
, message: message
|
16747
|
+
, operator: operator
|
16748
|
+
, stackStartFunction: assert.fail
|
16749
|
+
});
|
16750
|
+
};
|
16751
|
+
|
16752
|
+
/**
|
16753
|
+
* ### .ok(object, [message])
|
16754
|
+
*
|
16755
|
+
* Asserts that `object` is truthy.
|
16756
|
+
*
|
16757
|
+
* assert.ok('everything', 'everything is ok');
|
16758
|
+
* assert.ok(false, 'this will fail');
|
16759
|
+
*
|
16760
|
+
* @name ok
|
16761
|
+
* @param {Mixed} object to test
|
16762
|
+
* @param {String} message
|
16763
|
+
* @api public
|
16764
|
+
*/
|
16765
|
+
|
16766
|
+
assert.ok = function (val, msg) {
|
16767
|
+
new Assertion(val, msg).is.ok;
|
16768
|
+
};
|
16769
|
+
|
16770
|
+
/**
|
16771
|
+
* ### .notOk(object, [message])
|
16772
|
+
*
|
16773
|
+
* Asserts that `object` is falsy.
|
16774
|
+
*
|
16775
|
+
* assert.notOk('everything', 'this will fail');
|
16776
|
+
* assert.notOk(false, 'this will pass');
|
16777
|
+
*
|
16778
|
+
* @name notOk
|
16779
|
+
* @param {Mixed} object to test
|
16780
|
+
* @param {String} message
|
16781
|
+
* @api public
|
16782
|
+
*/
|
16783
|
+
|
16784
|
+
assert.notOk = function (val, msg) {
|
16785
|
+
new Assertion(val, msg).is.not.ok;
|
16786
|
+
};
|
16787
|
+
|
16788
|
+
/**
|
16789
|
+
* ### .equal(actual, expected, [message])
|
16790
|
+
*
|
16791
|
+
* Asserts non-strict equality (`==`) of `actual` and `expected`.
|
16792
|
+
*
|
16793
|
+
* assert.equal(3, '3', '== coerces values to strings');
|
16794
|
+
*
|
16795
|
+
* @name equal
|
16796
|
+
* @param {Mixed} actual
|
16797
|
+
* @param {Mixed} expected
|
16798
|
+
* @param {String} message
|
16799
|
+
* @api public
|
16800
|
+
*/
|
16801
|
+
|
16802
|
+
assert.equal = function (act, exp, msg) {
|
16803
|
+
var test = new Assertion(act, msg);
|
16804
|
+
|
16805
|
+
test.assert(
|
16806
|
+
exp == flag(test, 'object')
|
16807
|
+
, 'expected #{this} to equal #{exp}'
|
16808
|
+
, 'expected #{this} to not equal #{act}'
|
16809
|
+
, exp
|
16810
|
+
, act
|
16811
|
+
);
|
16812
|
+
};
|
16813
|
+
|
16814
|
+
/**
|
16815
|
+
* ### .notEqual(actual, expected, [message])
|
16816
|
+
*
|
16817
|
+
* Asserts non-strict inequality (`!=`) of `actual` and `expected`.
|
16818
|
+
*
|
16819
|
+
* assert.notEqual(3, 4, 'these numbers are not equal');
|
16820
|
+
*
|
16821
|
+
* @name notEqual
|
16822
|
+
* @param {Mixed} actual
|
16823
|
+
* @param {Mixed} expected
|
16824
|
+
* @param {String} message
|
16825
|
+
* @api public
|
16826
|
+
*/
|
16827
|
+
|
16828
|
+
assert.notEqual = function (act, exp, msg) {
|
16829
|
+
var test = new Assertion(act, msg);
|
16830
|
+
|
16831
|
+
test.assert(
|
16832
|
+
exp != flag(test, 'object')
|
16833
|
+
, 'expected #{this} to not equal #{exp}'
|
16834
|
+
, 'expected #{this} to equal #{act}'
|
16835
|
+
, exp
|
16836
|
+
, act
|
16837
|
+
);
|
16838
|
+
};
|
16839
|
+
|
16840
|
+
/**
|
16841
|
+
* ### .strictEqual(actual, expected, [message])
|
16842
|
+
*
|
16843
|
+
* Asserts strict equality (`===`) of `actual` and `expected`.
|
16844
|
+
*
|
16845
|
+
* assert.strictEqual(true, true, 'these booleans are strictly equal');
|
16846
|
+
*
|
16847
|
+
* @name strictEqual
|
16848
|
+
* @param {Mixed} actual
|
16849
|
+
* @param {Mixed} expected
|
16850
|
+
* @param {String} message
|
16851
|
+
* @api public
|
16852
|
+
*/
|
16853
|
+
|
16854
|
+
assert.strictEqual = function (act, exp, msg) {
|
16855
|
+
new Assertion(act, msg).to.equal(exp);
|
16856
|
+
};
|
16857
|
+
|
16858
|
+
/**
|
16859
|
+
* ### .notStrictEqual(actual, expected, [message])
|
16860
|
+
*
|
16861
|
+
* Asserts strict inequality (`!==`) of `actual` and `expected`.
|
16862
|
+
*
|
16863
|
+
* assert.notStrictEqual(3, '3', 'no coercion for strict equality');
|
16864
|
+
*
|
16865
|
+
* @name notStrictEqual
|
16866
|
+
* @param {Mixed} actual
|
16867
|
+
* @param {Mixed} expected
|
16868
|
+
* @param {String} message
|
16869
|
+
* @api public
|
16870
|
+
*/
|
16871
|
+
|
16872
|
+
assert.notStrictEqual = function (act, exp, msg) {
|
16873
|
+
new Assertion(act, msg).to.not.equal(exp);
|
16874
|
+
};
|
16875
|
+
|
16876
|
+
/**
|
16877
|
+
* ### .deepEqual(actual, expected, [message])
|
16878
|
+
*
|
16879
|
+
* Asserts that `actual` is deeply equal to `expected`.
|
16880
|
+
*
|
16881
|
+
* assert.deepEqual({ tea: 'green' }, { tea: 'green' });
|
16882
|
+
*
|
16883
|
+
* @name deepEqual
|
16884
|
+
* @param {Mixed} actual
|
16885
|
+
* @param {Mixed} expected
|
16886
|
+
* @param {String} message
|
16887
|
+
* @api public
|
16888
|
+
*/
|
16889
|
+
|
16890
|
+
assert.deepEqual = function (act, exp, msg) {
|
16891
|
+
new Assertion(act, msg).to.eql(exp);
|
16892
|
+
};
|
16893
|
+
|
16894
|
+
/**
|
16895
|
+
* ### .notDeepEqual(actual, expected, [message])
|
16896
|
+
*
|
16897
|
+
* Assert that `actual` is not deeply equal to `expected`.
|
16898
|
+
*
|
16899
|
+
* assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });
|
16900
|
+
*
|
16901
|
+
* @name notDeepEqual
|
16902
|
+
* @param {Mixed} actual
|
16903
|
+
* @param {Mixed} expected
|
16904
|
+
* @param {String} message
|
16905
|
+
* @api public
|
16906
|
+
*/
|
16907
|
+
|
16908
|
+
assert.notDeepEqual = function (act, exp, msg) {
|
16909
|
+
new Assertion(act, msg).to.not.eql(exp);
|
16910
|
+
};
|
16911
|
+
|
16912
|
+
/**
|
16913
|
+
* ### .isTrue(value, [message])
|
16914
|
+
*
|
16915
|
+
* Asserts that `value` is true.
|
16916
|
+
*
|
16917
|
+
* var teaServed = true;
|
16918
|
+
* assert.isTrue(teaServed, 'the tea has been served');
|
16919
|
+
*
|
16920
|
+
* @name isTrue
|
16921
|
+
* @param {Mixed} value
|
16922
|
+
* @param {String} message
|
16923
|
+
* @api public
|
16924
|
+
*/
|
16925
|
+
|
16926
|
+
assert.isTrue = function (val, msg) {
|
16927
|
+
new Assertion(val, msg).is['true'];
|
16928
|
+
};
|
16929
|
+
|
16930
|
+
/**
|
16931
|
+
* ### .isFalse(value, [message])
|
16932
|
+
*
|
16933
|
+
* Asserts that `value` is false.
|
16934
|
+
*
|
16935
|
+
* var teaServed = false;
|
16936
|
+
* assert.isFalse(teaServed, 'no tea yet? hmm...');
|
16937
|
+
*
|
16938
|
+
* @name isFalse
|
16939
|
+
* @param {Mixed} value
|
16940
|
+
* @param {String} message
|
16941
|
+
* @api public
|
16942
|
+
*/
|
16943
|
+
|
16944
|
+
assert.isFalse = function (val, msg) {
|
16945
|
+
new Assertion(val, msg).is['false'];
|
16946
|
+
};
|
16947
|
+
|
16948
|
+
/**
|
16949
|
+
* ### .isNull(value, [message])
|
16950
|
+
*
|
16951
|
+
* Asserts that `value` is null.
|
16952
|
+
*
|
16953
|
+
* assert.isNull(err, 'there was no error');
|
16954
|
+
*
|
16955
|
+
* @name isNull
|
16956
|
+
* @param {Mixed} value
|
16957
|
+
* @param {String} message
|
16958
|
+
* @api public
|
16959
|
+
*/
|
16960
|
+
|
16961
|
+
assert.isNull = function (val, msg) {
|
16962
|
+
new Assertion(val, msg).to.equal(null);
|
16963
|
+
};
|
16964
|
+
|
16965
|
+
/**
|
16966
|
+
* ### .isNotNull(value, [message])
|
16967
|
+
*
|
16968
|
+
* Asserts that `value` is not null.
|
16969
|
+
*
|
16970
|
+
* var tea = 'tasty chai';
|
16971
|
+
* assert.isNotNull(tea, 'great, time for tea!');
|
16972
|
+
*
|
16973
|
+
* @name isNotNull
|
16974
|
+
* @param {Mixed} value
|
16975
|
+
* @param {String} message
|
16976
|
+
* @api public
|
16977
|
+
*/
|
16978
|
+
|
16979
|
+
assert.isNotNull = function (val, msg) {
|
16980
|
+
new Assertion(val, msg).to.not.equal(null);
|
16981
|
+
};
|
16982
|
+
|
16983
|
+
/**
|
16984
|
+
* ### .isUndefined(value, [message])
|
16985
|
+
*
|
16986
|
+
* Asserts that `value` is `undefined`.
|
16987
|
+
*
|
16988
|
+
* var tea;
|
16989
|
+
* assert.isUndefined(tea, 'no tea defined');
|
16990
|
+
*
|
16991
|
+
* @name isUndefined
|
16992
|
+
* @param {Mixed} value
|
16993
|
+
* @param {String} message
|
16994
|
+
* @api public
|
16995
|
+
*/
|
16996
|
+
|
16997
|
+
assert.isUndefined = function (val, msg) {
|
16998
|
+
new Assertion(val, msg).to.equal(undefined);
|
16999
|
+
};
|
17000
|
+
|
17001
|
+
/**
|
17002
|
+
* ### .isDefined(value, [message])
|
17003
|
+
*
|
17004
|
+
* Asserts that `value` is not `undefined`.
|
17005
|
+
*
|
17006
|
+
* var tea = 'cup of chai';
|
17007
|
+
* assert.isDefined(tea, 'tea has been defined');
|
17008
|
+
*
|
17009
|
+
* @name isDefined
|
17010
|
+
* @param {Mixed} value
|
17011
|
+
* @param {String} message
|
17012
|
+
* @api public
|
17013
|
+
*/
|
17014
|
+
|
17015
|
+
assert.isDefined = function (val, msg) {
|
17016
|
+
new Assertion(val, msg).to.not.equal(undefined);
|
17017
|
+
};
|
17018
|
+
|
17019
|
+
/**
|
17020
|
+
* ### .isFunction(value, [message])
|
17021
|
+
*
|
17022
|
+
* Asserts that `value` is a function.
|
17023
|
+
*
|
17024
|
+
* function serveTea() { return 'cup of tea'; };
|
17025
|
+
* assert.isFunction(serveTea, 'great, we can have tea now');
|
17026
|
+
*
|
17027
|
+
* @name isFunction
|
17028
|
+
* @param {Mixed} value
|
17029
|
+
* @param {String} message
|
17030
|
+
* @api public
|
17031
|
+
*/
|
17032
|
+
|
17033
|
+
assert.isFunction = function (val, msg) {
|
17034
|
+
new Assertion(val, msg).to.be.a('function');
|
17035
|
+
};
|
17036
|
+
|
17037
|
+
/**
|
17038
|
+
* ### .isNotFunction(value, [message])
|
17039
|
+
*
|
17040
|
+
* Asserts that `value` is _not_ a function.
|
17041
|
+
*
|
17042
|
+
* var serveTea = [ 'heat', 'pour', 'sip' ];
|
17043
|
+
* assert.isNotFunction(serveTea, 'great, we have listed the steps');
|
17044
|
+
*
|
17045
|
+
* @name isNotFunction
|
17046
|
+
* @param {Mixed} value
|
17047
|
+
* @param {String} message
|
17048
|
+
* @api public
|
17049
|
+
*/
|
17050
|
+
|
17051
|
+
assert.isNotFunction = function (val, msg) {
|
17052
|
+
new Assertion(val, msg).to.not.be.a('function');
|
17053
|
+
};
|
17054
|
+
|
17055
|
+
/**
|
17056
|
+
* ### .isObject(value, [message])
|
17057
|
+
*
|
17058
|
+
* Asserts that `value` is an object (as revealed by
|
17059
|
+
* `Object.prototype.toString`).
|
17060
|
+
*
|
17061
|
+
* var selection = { name: 'Chai', serve: 'with spices' };
|
17062
|
+
* assert.isObject(selection, 'tea selection is an object');
|
17063
|
+
*
|
17064
|
+
* @name isObject
|
17065
|
+
* @param {Mixed} value
|
17066
|
+
* @param {String} message
|
17067
|
+
* @api public
|
17068
|
+
*/
|
17069
|
+
|
17070
|
+
assert.isObject = function (val, msg) {
|
17071
|
+
new Assertion(val, msg).to.be.a('object');
|
17072
|
+
};
|
17073
|
+
|
17074
|
+
/**
|
17075
|
+
* ### .isNotObject(value, [message])
|
17076
|
+
*
|
17077
|
+
* Asserts that `value` is _not_ an object.
|
17078
|
+
*
|
17079
|
+
* var selection = 'chai'
|
17080
|
+
* assert.isObject(selection, 'tea selection is not an object');
|
17081
|
+
* assert.isObject(null, 'null is not an object');
|
17082
|
+
*
|
17083
|
+
* @name isNotObject
|
17084
|
+
* @param {Mixed} value
|
17085
|
+
* @param {String} message
|
17086
|
+
* @api public
|
17087
|
+
*/
|
17088
|
+
|
17089
|
+
assert.isNotObject = function (val, msg) {
|
17090
|
+
new Assertion(val, msg).to.not.be.a('object');
|
17091
|
+
};
|
17092
|
+
|
17093
|
+
/**
|
17094
|
+
* ### .isArray(value, [message])
|
17095
|
+
*
|
17096
|
+
* Asserts that `value` is an array.
|
17097
|
+
*
|
17098
|
+
* var menu = [ 'green', 'chai', 'oolong' ];
|
17099
|
+
* assert.isArray(menu, 'what kind of tea do we want?');
|
17100
|
+
*
|
17101
|
+
* @name isArray
|
17102
|
+
* @param {Mixed} value
|
17103
|
+
* @param {String} message
|
17104
|
+
* @api public
|
17105
|
+
*/
|
17106
|
+
|
17107
|
+
assert.isArray = function (val, msg) {
|
17108
|
+
new Assertion(val, msg).to.be.an('array');
|
17109
|
+
};
|
17110
|
+
|
17111
|
+
/**
|
17112
|
+
* ### .isNotArray(value, [message])
|
17113
|
+
*
|
17114
|
+
* Asserts that `value` is _not_ an array.
|
17115
|
+
*
|
17116
|
+
* var menu = 'green|chai|oolong';
|
17117
|
+
* assert.isNotArray(menu, 'what kind of tea do we want?');
|
17118
|
+
*
|
17119
|
+
* @name isNotArray
|
17120
|
+
* @param {Mixed} value
|
17121
|
+
* @param {String} message
|
17122
|
+
* @api public
|
17123
|
+
*/
|
17124
|
+
|
17125
|
+
assert.isNotArray = function (val, msg) {
|
17126
|
+
new Assertion(val, msg).to.not.be.an('array');
|
17127
|
+
};
|
17128
|
+
|
17129
|
+
/**
|
17130
|
+
* ### .isString(value, [message])
|
17131
|
+
*
|
17132
|
+
* Asserts that `value` is a string.
|
17133
|
+
*
|
17134
|
+
* var teaOrder = 'chai';
|
17135
|
+
* assert.isString(teaOrder, 'order placed');
|
17136
|
+
*
|
17137
|
+
* @name isString
|
17138
|
+
* @param {Mixed} value
|
17139
|
+
* @param {String} message
|
17140
|
+
* @api public
|
17141
|
+
*/
|
17142
|
+
|
17143
|
+
assert.isString = function (val, msg) {
|
17144
|
+
new Assertion(val, msg).to.be.a('string');
|
17145
|
+
};
|
17146
|
+
|
17147
|
+
/**
|
17148
|
+
* ### .isNotString(value, [message])
|
17149
|
+
*
|
17150
|
+
* Asserts that `value` is _not_ a string.
|
17151
|
+
*
|
17152
|
+
* var teaOrder = 4;
|
17153
|
+
* assert.isNotString(teaOrder, 'order placed');
|
17154
|
+
*
|
17155
|
+
* @name isNotString
|
17156
|
+
* @param {Mixed} value
|
17157
|
+
* @param {String} message
|
17158
|
+
* @api public
|
17159
|
+
*/
|
17160
|
+
|
17161
|
+
assert.isNotString = function (val, msg) {
|
17162
|
+
new Assertion(val, msg).to.not.be.a('string');
|
17163
|
+
};
|
17164
|
+
|
17165
|
+
/**
|
17166
|
+
* ### .isNumber(value, [message])
|
17167
|
+
*
|
17168
|
+
* Asserts that `value` is a number.
|
17169
|
+
*
|
17170
|
+
* var cups = 2;
|
17171
|
+
* assert.isNumber(cups, 'how many cups');
|
17172
|
+
*
|
17173
|
+
* @name isNumber
|
17174
|
+
* @param {Number} value
|
17175
|
+
* @param {String} message
|
17176
|
+
* @api public
|
17177
|
+
*/
|
17178
|
+
|
17179
|
+
assert.isNumber = function (val, msg) {
|
17180
|
+
new Assertion(val, msg).to.be.a('number');
|
17181
|
+
};
|
17182
|
+
|
17183
|
+
/**
|
17184
|
+
* ### .isNotNumber(value, [message])
|
17185
|
+
*
|
17186
|
+
* Asserts that `value` is _not_ a number.
|
17187
|
+
*
|
17188
|
+
* var cups = '2 cups please';
|
17189
|
+
* assert.isNotNumber(cups, 'how many cups');
|
17190
|
+
*
|
17191
|
+
* @name isNotNumber
|
17192
|
+
* @param {Mixed} value
|
17193
|
+
* @param {String} message
|
17194
|
+
* @api public
|
17195
|
+
*/
|
17196
|
+
|
17197
|
+
assert.isNotNumber = function (val, msg) {
|
17198
|
+
new Assertion(val, msg).to.not.be.a('number');
|
17199
|
+
};
|
17200
|
+
|
17201
|
+
/**
|
17202
|
+
* ### .isBoolean(value, [message])
|
17203
|
+
*
|
17204
|
+
* Asserts that `value` is a boolean.
|
17205
|
+
*
|
17206
|
+
* var teaReady = true
|
17207
|
+
* , teaServed = false;
|
17208
|
+
*
|
17209
|
+
* assert.isBoolean(teaReady, 'is the tea ready');
|
17210
|
+
* assert.isBoolean(teaServed, 'has tea been served');
|
17211
|
+
*
|
17212
|
+
* @name isBoolean
|
17213
|
+
* @param {Mixed} value
|
17214
|
+
* @param {String} message
|
17215
|
+
* @api public
|
17216
|
+
*/
|
17217
|
+
|
17218
|
+
assert.isBoolean = function (val, msg) {
|
17219
|
+
new Assertion(val, msg).to.be.a('boolean');
|
17220
|
+
};
|
17221
|
+
|
17222
|
+
/**
|
17223
|
+
* ### .isNotBoolean(value, [message])
|
17224
|
+
*
|
17225
|
+
* Asserts that `value` is _not_ a boolean.
|
17226
|
+
*
|
17227
|
+
* var teaReady = 'yep'
|
17228
|
+
* , teaServed = 'nope';
|
17229
|
+
*
|
17230
|
+
* assert.isNotBoolean(teaReady, 'is the tea ready');
|
17231
|
+
* assert.isNotBoolean(teaServed, 'has tea been served');
|
17232
|
+
*
|
17233
|
+
* @name isNotBoolean
|
17234
|
+
* @param {Mixed} value
|
17235
|
+
* @param {String} message
|
17236
|
+
* @api public
|
17237
|
+
*/
|
17238
|
+
|
17239
|
+
assert.isNotBoolean = function (val, msg) {
|
17240
|
+
new Assertion(val, msg).to.not.be.a('boolean');
|
17241
|
+
};
|
17242
|
+
|
17243
|
+
/**
|
17244
|
+
* ### .typeOf(value, name, [message])
|
17245
|
+
*
|
17246
|
+
* Asserts that `value`'s type is `name`, as determined by
|
17247
|
+
* `Object.prototype.toString`.
|
17248
|
+
*
|
17249
|
+
* assert.typeOf({ tea: 'chai' }, 'object', 'we have an object');
|
17250
|
+
* assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array');
|
17251
|
+
* assert.typeOf('tea', 'string', 'we have a string');
|
17252
|
+
* assert.typeOf(/tea/, 'regexp', 'we have a regular expression');
|
17253
|
+
* assert.typeOf(null, 'null', 'we have a null');
|
17254
|
+
* assert.typeOf(undefined, 'undefined', 'we have an undefined');
|
17255
|
+
*
|
17256
|
+
* @name typeOf
|
17257
|
+
* @param {Mixed} value
|
17258
|
+
* @param {String} name
|
17259
|
+
* @param {String} message
|
17260
|
+
* @api public
|
17261
|
+
*/
|
17262
|
+
|
17263
|
+
assert.typeOf = function (val, type, msg) {
|
17264
|
+
new Assertion(val, msg).to.be.a(type);
|
17265
|
+
};
|
17266
|
+
|
17267
|
+
/**
|
17268
|
+
* ### .notTypeOf(value, name, [message])
|
17269
|
+
*
|
17270
|
+
* Asserts that `value`'s type is _not_ `name`, as determined by
|
17271
|
+
* `Object.prototype.toString`.
|
17272
|
+
*
|
17273
|
+
* assert.notTypeOf('tea', 'number', 'strings are not numbers');
|
17274
|
+
*
|
17275
|
+
* @name notTypeOf
|
17276
|
+
* @param {Mixed} value
|
17277
|
+
* @param {String} typeof name
|
17278
|
+
* @param {String} message
|
17279
|
+
* @api public
|
17280
|
+
*/
|
17281
|
+
|
17282
|
+
assert.notTypeOf = function (val, type, msg) {
|
17283
|
+
new Assertion(val, msg).to.not.be.a(type);
|
17284
|
+
};
|
17285
|
+
|
17286
|
+
/**
|
17287
|
+
* ### .instanceOf(object, constructor, [message])
|
17288
|
+
*
|
17289
|
+
* Asserts that `value` is an instance of `constructor`.
|
17290
|
+
*
|
17291
|
+
* var Tea = function (name) { this.name = name; }
|
17292
|
+
* , chai = new Tea('chai');
|
17293
|
+
*
|
17294
|
+
* assert.instanceOf(chai, Tea, 'chai is an instance of tea');
|
17295
|
+
*
|
17296
|
+
* @name instanceOf
|
17297
|
+
* @param {Object} object
|
17298
|
+
* @param {Constructor} constructor
|
17299
|
+
* @param {String} message
|
17300
|
+
* @api public
|
17301
|
+
*/
|
17302
|
+
|
17303
|
+
assert.instanceOf = function (val, type, msg) {
|
17304
|
+
new Assertion(val, msg).to.be.instanceOf(type);
|
17305
|
+
};
|
17306
|
+
|
17307
|
+
/**
|
17308
|
+
* ### .notInstanceOf(object, constructor, [message])
|
17309
|
+
*
|
17310
|
+
* Asserts `value` is not an instance of `constructor`.
|
17311
|
+
*
|
17312
|
+
* var Tea = function (name) { this.name = name; }
|
17313
|
+
* , chai = new String('chai');
|
17314
|
+
*
|
17315
|
+
* assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea');
|
17316
|
+
*
|
17317
|
+
* @name notInstanceOf
|
17318
|
+
* @param {Object} object
|
17319
|
+
* @param {Constructor} constructor
|
17320
|
+
* @param {String} message
|
17321
|
+
* @api public
|
17322
|
+
*/
|
17323
|
+
|
17324
|
+
assert.notInstanceOf = function (val, type, msg) {
|
17325
|
+
new Assertion(val, msg).to.not.be.instanceOf(type);
|
17326
|
+
};
|
17327
|
+
|
17328
|
+
/**
|
17329
|
+
* ### .include(haystack, needle, [message])
|
17330
|
+
*
|
17331
|
+
* Asserts that `haystack` includes `needle`. Works
|
17332
|
+
* for strings and arrays.
|
17333
|
+
*
|
17334
|
+
* assert.include('foobar', 'bar', 'foobar contains string "bar"');
|
17335
|
+
* assert.include([ 1, 2, 3 ], 3, 'array contains value');
|
17336
|
+
*
|
17337
|
+
* @name include
|
17338
|
+
* @param {Array|String} haystack
|
17339
|
+
* @param {Mixed} needle
|
17340
|
+
* @param {String} message
|
17341
|
+
* @api public
|
17342
|
+
*/
|
17343
|
+
|
17344
|
+
assert.include = function (exp, inc, msg) {
|
17345
|
+
var obj = new Assertion(exp, msg);
|
17346
|
+
|
17347
|
+
if (Array.isArray(exp)) {
|
17348
|
+
obj.to.include(inc);
|
17349
|
+
} else if ('string' === typeof exp) {
|
17350
|
+
obj.to.contain.string(inc);
|
17351
|
+
} else {
|
17352
|
+
throw new chai.AssertionError(
|
17353
|
+
'expected an array or string'
|
17354
|
+
, null
|
17355
|
+
, assert.include
|
17356
|
+
);
|
17357
|
+
}
|
17358
|
+
};
|
17359
|
+
|
17360
|
+
/**
|
17361
|
+
* ### .notInclude(haystack, needle, [message])
|
17362
|
+
*
|
17363
|
+
* Asserts that `haystack` does not include `needle`. Works
|
17364
|
+
* for strings and arrays.
|
17365
|
+
*i
|
17366
|
+
* assert.notInclude('foobar', 'baz', 'string not include substring');
|
17367
|
+
* assert.notInclude([ 1, 2, 3 ], 4, 'array not include contain value');
|
17368
|
+
*
|
17369
|
+
* @name notInclude
|
17370
|
+
* @param {Array|String} haystack
|
17371
|
+
* @param {Mixed} needle
|
17372
|
+
* @param {String} message
|
17373
|
+
* @api public
|
17374
|
+
*/
|
17375
|
+
|
17376
|
+
assert.notInclude = function (exp, inc, msg) {
|
17377
|
+
var obj = new Assertion(exp, msg);
|
17378
|
+
|
17379
|
+
if (Array.isArray(exp)) {
|
17380
|
+
obj.to.not.include(inc);
|
17381
|
+
} else if ('string' === typeof exp) {
|
17382
|
+
obj.to.not.contain.string(inc);
|
17383
|
+
} else {
|
17384
|
+
throw new chai.AssertionError(
|
17385
|
+
'expected an array or string'
|
17386
|
+
, null
|
17387
|
+
, assert.notInclude
|
17388
|
+
);
|
17389
|
+
}
|
17390
|
+
};
|
17391
|
+
|
17392
|
+
/**
|
17393
|
+
* ### .match(value, regexp, [message])
|
17394
|
+
*
|
17395
|
+
* Asserts that `value` matches the regular expression `regexp`.
|
17396
|
+
*
|
17397
|
+
* assert.match('foobar', /^foo/, 'regexp matches');
|
17398
|
+
*
|
17399
|
+
* @name match
|
17400
|
+
* @param {Mixed} value
|
17401
|
+
* @param {RegExp} regexp
|
17402
|
+
* @param {String} message
|
17403
|
+
* @api public
|
17404
|
+
*/
|
17405
|
+
|
17406
|
+
assert.match = function (exp, re, msg) {
|
17407
|
+
new Assertion(exp, msg).to.match(re);
|
17408
|
+
};
|
17409
|
+
|
17410
|
+
/**
|
17411
|
+
* ### .notMatch(value, regexp, [message])
|
17412
|
+
*
|
17413
|
+
* Asserts that `value` does not match the regular expression `regexp`.
|
17414
|
+
*
|
17415
|
+
* assert.notMatch('foobar', /^foo/, 'regexp does not match');
|
17416
|
+
*
|
17417
|
+
* @name notMatch
|
17418
|
+
* @param {Mixed} value
|
17419
|
+
* @param {RegExp} regexp
|
17420
|
+
* @param {String} message
|
17421
|
+
* @api public
|
17422
|
+
*/
|
17423
|
+
|
17424
|
+
assert.notMatch = function (exp, re, msg) {
|
17425
|
+
new Assertion(exp, msg).to.not.match(re);
|
17426
|
+
};
|
17427
|
+
|
17428
|
+
/**
|
17429
|
+
* ### .property(object, property, [message])
|
17430
|
+
*
|
17431
|
+
* Asserts that `object` has a property named by `property`.
|
17432
|
+
*
|
17433
|
+
* assert.property({ tea: { green: 'matcha' }}, 'tea');
|
17434
|
+
*
|
17435
|
+
* @name property
|
17436
|
+
* @param {Object} object
|
17437
|
+
* @param {String} property
|
17438
|
+
* @param {String} message
|
17439
|
+
* @api public
|
17440
|
+
*/
|
17441
|
+
|
17442
|
+
assert.property = function (obj, prop, msg) {
|
17443
|
+
new Assertion(obj, msg).to.have.property(prop);
|
17444
|
+
};
|
17445
|
+
|
17446
|
+
/**
|
17447
|
+
* ### .notProperty(object, property, [message])
|
17448
|
+
*
|
17449
|
+
* Asserts that `object` does _not_ have a property named by `property`.
|
17450
|
+
*
|
17451
|
+
* assert.notProperty({ tea: { green: 'matcha' }}, 'coffee');
|
17452
|
+
*
|
17453
|
+
* @name notProperty
|
17454
|
+
* @param {Object} object
|
17455
|
+
* @param {String} property
|
17456
|
+
* @param {String} message
|
17457
|
+
* @api public
|
17458
|
+
*/
|
17459
|
+
|
17460
|
+
assert.notProperty = function (obj, prop, msg) {
|
17461
|
+
new Assertion(obj, msg).to.not.have.property(prop);
|
17462
|
+
};
|
17463
|
+
|
17464
|
+
/**
|
17465
|
+
* ### .deepProperty(object, property, [message])
|
17466
|
+
*
|
17467
|
+
* Asserts that `object` has a property named by `property`, which can be a
|
17468
|
+
* string using dot- and bracket-notation for deep reference.
|
17469
|
+
*
|
17470
|
+
* assert.deepProperty({ tea: { green: 'matcha' }}, 'tea.green');
|
17471
|
+
*
|
17472
|
+
* @name deepProperty
|
17473
|
+
* @param {Object} object
|
17474
|
+
* @param {String} property
|
17475
|
+
* @param {String} message
|
17476
|
+
* @api public
|
17477
|
+
*/
|
17478
|
+
|
17479
|
+
assert.deepProperty = function (obj, prop, msg) {
|
17480
|
+
new Assertion(obj, msg).to.have.deep.property(prop);
|
17481
|
+
};
|
17482
|
+
|
17483
|
+
/**
|
17484
|
+
* ### .notDeepProperty(object, property, [message])
|
17485
|
+
*
|
17486
|
+
* Asserts that `object` does _not_ have a property named by `property`, which
|
17487
|
+
* can be a string using dot- and bracket-notation for deep reference.
|
17488
|
+
*
|
17489
|
+
* assert.notDeepProperty({ tea: { green: 'matcha' }}, 'tea.oolong');
|
17490
|
+
*
|
17491
|
+
* @name notDeepProperty
|
17492
|
+
* @param {Object} object
|
17493
|
+
* @param {String} property
|
17494
|
+
* @param {String} message
|
17495
|
+
* @api public
|
17496
|
+
*/
|
17497
|
+
|
17498
|
+
assert.notDeepProperty = function (obj, prop, msg) {
|
17499
|
+
new Assertion(obj, msg).to.not.have.deep.property(prop);
|
17500
|
+
};
|
17501
|
+
|
17502
|
+
/**
|
17503
|
+
* ### .propertyVal(object, property, value, [message])
|
17504
|
+
*
|
17505
|
+
* Asserts that `object` has a property named by `property` with value given
|
17506
|
+
* by `value`.
|
17507
|
+
*
|
17508
|
+
* assert.propertyVal({ tea: 'is good' }, 'tea', 'is good');
|
17509
|
+
*
|
17510
|
+
* @name propertyVal
|
17511
|
+
* @param {Object} object
|
17512
|
+
* @param {String} property
|
17513
|
+
* @param {Mixed} value
|
17514
|
+
* @param {String} message
|
17515
|
+
* @api public
|
17516
|
+
*/
|
17517
|
+
|
17518
|
+
assert.propertyVal = function (obj, prop, val, msg) {
|
17519
|
+
new Assertion(obj, msg).to.have.property(prop, val);
|
17520
|
+
};
|
17521
|
+
|
17522
|
+
/**
|
17523
|
+
* ### .propertyNotVal(object, property, value, [message])
|
17524
|
+
*
|
17525
|
+
* Asserts that `object` has a property named by `property`, but with a value
|
17526
|
+
* different from that given by `value`.
|
17527
|
+
*
|
17528
|
+
* assert.propertyNotVal({ tea: 'is good' }, 'tea', 'is bad');
|
17529
|
+
*
|
17530
|
+
* @name propertyNotVal
|
17531
|
+
* @param {Object} object
|
17532
|
+
* @param {String} property
|
17533
|
+
* @param {Mixed} value
|
17534
|
+
* @param {String} message
|
17535
|
+
* @api public
|
17536
|
+
*/
|
17537
|
+
|
17538
|
+
assert.propertyNotVal = function (obj, prop, val, msg) {
|
17539
|
+
new Assertion(obj, msg).to.not.have.property(prop, val);
|
17540
|
+
};
|
17541
|
+
|
17542
|
+
/**
|
17543
|
+
* ### .deepPropertyVal(object, property, value, [message])
|
17544
|
+
*
|
17545
|
+
* Asserts that `object` has a property named by `property` with value given
|
17546
|
+
* by `value`. `property` can use dot- and bracket-notation for deep
|
17547
|
+
* reference.
|
17548
|
+
*
|
17549
|
+
* assert.deepPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha');
|
17550
|
+
*
|
17551
|
+
* @name deepPropertyVal
|
17552
|
+
* @param {Object} object
|
17553
|
+
* @param {String} property
|
17554
|
+
* @param {Mixed} value
|
17555
|
+
* @param {String} message
|
17556
|
+
* @api public
|
17557
|
+
*/
|
17558
|
+
|
17559
|
+
assert.deepPropertyVal = function (obj, prop, val, msg) {
|
17560
|
+
new Assertion(obj, msg).to.have.deep.property(prop, val);
|
17561
|
+
};
|
17562
|
+
|
17563
|
+
/**
|
17564
|
+
* ### .deepPropertyNotVal(object, property, value, [message])
|
17565
|
+
*
|
17566
|
+
* Asserts that `object` has a property named by `property`, but with a value
|
17567
|
+
* different from that given by `value`. `property` can use dot- and
|
17568
|
+
* bracket-notation for deep reference.
|
17569
|
+
*
|
17570
|
+
* assert.deepPropertyNotVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha');
|
17571
|
+
*
|
17572
|
+
* @name deepPropertyNotVal
|
17573
|
+
* @param {Object} object
|
17574
|
+
* @param {String} property
|
17575
|
+
* @param {Mixed} value
|
17576
|
+
* @param {String} message
|
17577
|
+
* @api public
|
17578
|
+
*/
|
17579
|
+
|
17580
|
+
assert.deepPropertyNotVal = function (obj, prop, val, msg) {
|
17581
|
+
new Assertion(obj, msg).to.not.have.deep.property(prop, val);
|
17582
|
+
};
|
17583
|
+
|
17584
|
+
/**
|
17585
|
+
* ### .lengthOf(object, length, [message])
|
17586
|
+
*
|
17587
|
+
* Asserts that `object` has a `length` property with the expected value.
|
17588
|
+
*
|
17589
|
+
* assert.lengthOf([1,2,3], 3, 'array has length of 3');
|
17590
|
+
* assert.lengthOf('foobar', 5, 'string has length of 6');
|
17591
|
+
*
|
17592
|
+
* @name lengthOf
|
17593
|
+
* @param {Mixed} object
|
17594
|
+
* @param {Number} length
|
17595
|
+
* @param {String} message
|
17596
|
+
* @api public
|
17597
|
+
*/
|
17598
|
+
|
17599
|
+
assert.lengthOf = function (exp, len, msg) {
|
17600
|
+
new Assertion(exp, msg).to.have.length(len);
|
17601
|
+
};
|
17602
|
+
|
17603
|
+
/**
|
17604
|
+
* ### .throws(function, [constructor/string/regexp], [string/regexp], [message])
|
17605
|
+
*
|
17606
|
+
* Asserts that `function` will throw an error that is an instance of
|
17607
|
+
* `constructor`, or alternately that it will throw an error with message
|
17608
|
+
* matching `regexp`.
|
17609
|
+
*
|
17610
|
+
* assert.throw(fn, 'function throws a reference error');
|
17611
|
+
* assert.throw(fn, /function throws a reference error/);
|
17612
|
+
* assert.throw(fn, ReferenceError);
|
17613
|
+
* assert.throw(fn, ReferenceError, 'function throws a reference error');
|
17614
|
+
* assert.throw(fn, ReferenceError, /function throws a reference error/);
|
17615
|
+
*
|
17616
|
+
* @name throws
|
17617
|
+
* @alias throw
|
17618
|
+
* @alias Throw
|
17619
|
+
* @param {Function} function
|
17620
|
+
* @param {ErrorConstructor} constructor
|
17621
|
+
* @param {RegExp} regexp
|
17622
|
+
* @param {String} message
|
17623
|
+
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
17624
|
+
* @api public
|
17625
|
+
*/
|
17626
|
+
|
17627
|
+
assert.Throw = function (fn, errt, errs, msg) {
|
17628
|
+
if ('string' === typeof errt || errt instanceof RegExp) {
|
17629
|
+
errs = errt;
|
17630
|
+
errt = null;
|
17631
|
+
}
|
17632
|
+
|
17633
|
+
new Assertion(fn, msg).to.Throw(errt, errs);
|
17634
|
+
};
|
17635
|
+
|
17636
|
+
/**
|
17637
|
+
* ### .doesNotThrow(function, [constructor/regexp], [message])
|
17638
|
+
*
|
17639
|
+
* Asserts that `function` will _not_ throw an error that is an instance of
|
17640
|
+
* `constructor`, or alternately that it will not throw an error with message
|
17641
|
+
* matching `regexp`.
|
17642
|
+
*
|
17643
|
+
* assert.doesNotThrow(fn, Error, 'function does not throw');
|
17644
|
+
*
|
17645
|
+
* @name doesNotThrow
|
17646
|
+
* @param {Function} function
|
17647
|
+
* @param {ErrorConstructor} constructor
|
17648
|
+
* @param {RegExp} regexp
|
17649
|
+
* @param {String} message
|
17650
|
+
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
17651
|
+
* @api public
|
17652
|
+
*/
|
17653
|
+
|
17654
|
+
assert.doesNotThrow = function (fn, type, msg) {
|
17655
|
+
if ('string' === typeof type) {
|
17656
|
+
msg = type;
|
17657
|
+
type = null;
|
17658
|
+
}
|
17659
|
+
|
17660
|
+
new Assertion(fn, msg).to.not.Throw(type);
|
17661
|
+
};
|
17662
|
+
|
17663
|
+
/**
|
17664
|
+
* ### .operator(val1, operator, val2, [message])
|
17665
|
+
*
|
17666
|
+
* Compares two values using `operator`.
|
17667
|
+
*
|
17668
|
+
* assert.operator(1, '<', 2, 'everything is ok');
|
17669
|
+
* assert.operator(1, '>', 2, 'this will fail');
|
17670
|
+
*
|
17671
|
+
* @name operator
|
17672
|
+
* @param {Mixed} val1
|
17673
|
+
* @param {String} operator
|
17674
|
+
* @param {Mixed} val2
|
17675
|
+
* @param {String} message
|
17676
|
+
* @api public
|
17677
|
+
*/
|
17678
|
+
|
17679
|
+
assert.operator = function (val, operator, val2, msg) {
|
17680
|
+
if (!~['==', '===', '>', '>=', '<', '<=', '!=', '!=='].indexOf(operator)) {
|
17681
|
+
throw new Error('Invalid operator "' + operator + '"');
|
17682
|
+
}
|
17683
|
+
var test = new Assertion(eval(val + operator + val2), msg);
|
17684
|
+
test.assert(
|
17685
|
+
true === flag(test, 'object')
|
17686
|
+
, 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2)
|
17687
|
+
, 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) );
|
17688
|
+
};
|
17689
|
+
|
17690
|
+
/**
|
17691
|
+
* ### .closeTo(actual, expected, delta, [message])
|
17692
|
+
*
|
17693
|
+
* Asserts that the target is equal `expected`, to within a +/- `delta` range.
|
17694
|
+
*
|
17695
|
+
* assert.closeTo(1.5, 1, 0.5, 'numbers are close');
|
17696
|
+
*
|
17697
|
+
* @name closeTo
|
17698
|
+
* @param {Number} actual
|
17699
|
+
* @param {Number} expected
|
17700
|
+
* @param {Number} delta
|
17701
|
+
* @param {String} message
|
17702
|
+
* @api public
|
17703
|
+
*/
|
17704
|
+
|
17705
|
+
assert.closeTo = function (act, exp, delta, msg) {
|
17706
|
+
new Assertion(act, msg).to.be.closeTo(exp, delta);
|
17707
|
+
};
|
17708
|
+
|
17709
|
+
/**
|
17710
|
+
* ### .sameMembers(set1, set2, [message])
|
17711
|
+
*
|
17712
|
+
* Asserts that `set1` and `set2` have the same members.
|
17713
|
+
* Order is not taken into account.
|
17714
|
+
*
|
17715
|
+
* assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members');
|
17716
|
+
*
|
17717
|
+
* @name sameMembers
|
17718
|
+
* @param {Array} superset
|
17719
|
+
* @param {Array} subset
|
17720
|
+
* @param {String} message
|
17721
|
+
* @api public
|
17722
|
+
*/
|
17723
|
+
|
17724
|
+
assert.sameMembers = function (set1, set2, msg) {
|
17725
|
+
new Assertion(set1, msg).to.have.same.members(set2);
|
17726
|
+
}
|
17727
|
+
|
17728
|
+
/**
|
17729
|
+
* ### .includeMembers(superset, subset, [message])
|
17730
|
+
*
|
17731
|
+
* Asserts that `subset` is included in `superset`.
|
17732
|
+
* Order is not taken into account.
|
17733
|
+
*
|
17734
|
+
* assert.includeMembers([ 1, 2, 3 ], [ 2, 1 ], 'include members');
|
17735
|
+
*
|
17736
|
+
* @name includeMembers
|
17737
|
+
* @param {Array} superset
|
17738
|
+
* @param {Array} subset
|
17739
|
+
* @param {String} message
|
17740
|
+
* @api public
|
17741
|
+
*/
|
17742
|
+
|
17743
|
+
assert.includeMembers = function (superset, subset, msg) {
|
17744
|
+
new Assertion(superset, msg).to.include.members(subset);
|
17745
|
+
}
|
17746
|
+
|
17747
|
+
/*!
|
17748
|
+
* Undocumented / untested
|
17749
|
+
*/
|
17750
|
+
|
17751
|
+
assert.ifError = function (val, msg) {
|
17752
|
+
new Assertion(val, msg).to.not.be.ok;
|
17753
|
+
};
|
17754
|
+
|
17755
|
+
/*!
|
17756
|
+
* Aliases.
|
17757
|
+
*/
|
17758
|
+
|
17759
|
+
(function alias(name, as){
|
17760
|
+
assert[as] = assert[name];
|
17761
|
+
return alias;
|
17762
|
+
})
|
17763
|
+
('Throw', 'throw')
|
17764
|
+
('Throw', 'throws');
|
17765
|
+
};
|
17766
|
+
|
17767
|
+
});
|
17768
|
+
require.register("chaijs-chai/lib/chai/interface/expect.js", function(exports, require, module){
|
17769
|
+
/*!
|
17770
|
+
* chai
|
17771
|
+
* Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
|
17772
|
+
* MIT Licensed
|
17773
|
+
*/
|
17774
|
+
|
17775
|
+
module.exports = function (chai, util) {
|
17776
|
+
chai.expect = function (val, message) {
|
17777
|
+
return new chai.Assertion(val, message);
|
17778
|
+
};
|
17779
|
+
};
|
17780
|
+
|
17781
|
+
|
17782
|
+
});
|
17783
|
+
require.register("chaijs-chai/lib/chai/interface/should.js", function(exports, require, module){
|
17784
|
+
/*!
|
17785
|
+
* chai
|
17786
|
+
* Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
|
17787
|
+
* MIT Licensed
|
17788
|
+
*/
|
17789
|
+
|
17790
|
+
module.exports = function (chai, util) {
|
17791
|
+
var Assertion = chai.Assertion;
|
17792
|
+
|
17793
|
+
function loadShould () {
|
17794
|
+
// modify Object.prototype to have `should`
|
17795
|
+
Object.defineProperty(Object.prototype, 'should',
|
17796
|
+
{
|
17797
|
+
set: function (value) {
|
17798
|
+
// See https://github.com/chaijs/chai/issues/86: this makes
|
17799
|
+
// `whatever.should = someValue` actually set `someValue`, which is
|
17800
|
+
// especially useful for `global.should = require('chai').should()`.
|
17801
|
+
//
|
17802
|
+
// Note that we have to use [[DefineProperty]] instead of [[Put]]
|
17803
|
+
// since otherwise we would trigger this very setter!
|
17804
|
+
Object.defineProperty(this, 'should', {
|
17805
|
+
value: value,
|
17806
|
+
enumerable: true,
|
17807
|
+
configurable: true,
|
17808
|
+
writable: true
|
17809
|
+
});
|
17810
|
+
}
|
17811
|
+
, get: function(){
|
17812
|
+
if (this instanceof String || this instanceof Number) {
|
17813
|
+
return new Assertion(this.constructor(this));
|
17814
|
+
} else if (this instanceof Boolean) {
|
17815
|
+
return new Assertion(this == true);
|
17816
|
+
}
|
17817
|
+
return new Assertion(this);
|
17818
|
+
}
|
17819
|
+
, configurable: true
|
17820
|
+
});
|
17821
|
+
|
17822
|
+
var should = {};
|
17823
|
+
|
17824
|
+
should.equal = function (val1, val2, msg) {
|
17825
|
+
new Assertion(val1, msg).to.equal(val2);
|
17826
|
+
};
|
17827
|
+
|
17828
|
+
should.Throw = function (fn, errt, errs, msg) {
|
17829
|
+
new Assertion(fn, msg).to.Throw(errt, errs);
|
17830
|
+
};
|
17831
|
+
|
17832
|
+
should.exist = function (val, msg) {
|
17833
|
+
new Assertion(val, msg).to.exist;
|
17834
|
+
}
|
17835
|
+
|
17836
|
+
// negation
|
17837
|
+
should.not = {}
|
17838
|
+
|
17839
|
+
should.not.equal = function (val1, val2, msg) {
|
17840
|
+
new Assertion(val1, msg).to.not.equal(val2);
|
17841
|
+
};
|
17842
|
+
|
17843
|
+
should.not.Throw = function (fn, errt, errs, msg) {
|
17844
|
+
new Assertion(fn, msg).to.not.Throw(errt, errs);
|
17845
|
+
};
|
17846
|
+
|
17847
|
+
should.not.exist = function (val, msg) {
|
17848
|
+
new Assertion(val, msg).to.not.exist;
|
17849
|
+
}
|
17850
|
+
|
17851
|
+
should['throw'] = should['Throw'];
|
17852
|
+
should.not['throw'] = should.not['Throw'];
|
17853
|
+
|
17854
|
+
return should;
|
17855
|
+
};
|
17856
|
+
|
17857
|
+
chai.should = loadShould;
|
17858
|
+
chai.Should = loadShould;
|
17859
|
+
};
|
17860
|
+
|
17861
|
+
});
|
17862
|
+
require.register("chaijs-chai/lib/chai/utils/addChainableMethod.js", function(exports, require, module){
|
17863
|
+
/*!
|
17864
|
+
* Chai - addChainingMethod utility
|
17865
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
17866
|
+
* MIT Licensed
|
17867
|
+
*/
|
17868
|
+
|
17869
|
+
/*!
|
17870
|
+
* Module dependencies
|
17871
|
+
*/
|
17872
|
+
|
17873
|
+
var transferFlags = require('./transferFlags');
|
17874
|
+
|
17875
|
+
/*!
|
17876
|
+
* Module variables
|
17877
|
+
*/
|
17878
|
+
|
17879
|
+
// Check whether `__proto__` is supported
|
17880
|
+
var hasProtoSupport = '__proto__' in Object;
|
17881
|
+
|
17882
|
+
// Without `__proto__` support, this module will need to add properties to a function.
|
17883
|
+
// However, some Function.prototype methods cannot be overwritten,
|
17884
|
+
// and there seems no easy cross-platform way to detect them (@see chaijs/chai/issues/69).
|
17885
|
+
var excludeNames = /^(?:length|name|arguments|caller)$/;
|
17886
|
+
|
17887
|
+
// Cache `Function` properties
|
17888
|
+
var call = Function.prototype.call,
|
17889
|
+
apply = Function.prototype.apply;
|
17890
|
+
|
17891
|
+
/**
|
17892
|
+
* ### addChainableMethod (ctx, name, method, chainingBehavior)
|
17893
|
+
*
|
17894
|
+
* Adds a method to an object, such that the method can also be chained.
|
17895
|
+
*
|
17896
|
+
* utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
|
17897
|
+
* var obj = utils.flag(this, 'object');
|
17898
|
+
* new chai.Assertion(obj).to.be.equal(str);
|
17899
|
+
* });
|
17900
|
+
*
|
17901
|
+
* Can also be accessed directly from `chai.Assertion`.
|
17902
|
+
*
|
17903
|
+
* chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
|
17904
|
+
*
|
17905
|
+
* The result can then be used as both a method assertion, executing both `method` and
|
17906
|
+
* `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
|
17907
|
+
*
|
17908
|
+
* expect(fooStr).to.be.foo('bar');
|
17909
|
+
* expect(fooStr).to.be.foo.equal('foo');
|
17910
|
+
*
|
17911
|
+
* @param {Object} ctx object to which the method is added
|
17912
|
+
* @param {String} name of method to add
|
17913
|
+
* @param {Function} method function to be used for `name`, when called
|
17914
|
+
* @param {Function} chainingBehavior function to be called every time the property is accessed
|
17915
|
+
* @name addChainableMethod
|
17916
|
+
* @api public
|
17917
|
+
*/
|
17918
|
+
|
17919
|
+
module.exports = function (ctx, name, method, chainingBehavior) {
|
17920
|
+
if (typeof chainingBehavior !== 'function')
|
17921
|
+
chainingBehavior = function () { };
|
17922
|
+
|
17923
|
+
Object.defineProperty(ctx, name,
|
17924
|
+
{ get: function () {
|
17925
|
+
chainingBehavior.call(this);
|
17926
|
+
|
17927
|
+
var assert = function () {
|
17928
|
+
var result = method.apply(this, arguments);
|
17929
|
+
return result === undefined ? this : result;
|
17930
|
+
};
|
17931
|
+
|
17932
|
+
// Use `__proto__` if available
|
17933
|
+
if (hasProtoSupport) {
|
17934
|
+
// Inherit all properties from the object by replacing the `Function` prototype
|
17935
|
+
var prototype = assert.__proto__ = Object.create(this);
|
17936
|
+
// Restore the `call` and `apply` methods from `Function`
|
17937
|
+
prototype.call = call;
|
17938
|
+
prototype.apply = apply;
|
17939
|
+
}
|
17940
|
+
// Otherwise, redefine all properties (slow!)
|
17941
|
+
else {
|
17942
|
+
var asserterNames = Object.getOwnPropertyNames(ctx);
|
17943
|
+
asserterNames.forEach(function (asserterName) {
|
17944
|
+
if (!excludeNames.test(asserterName)) {
|
17945
|
+
var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
17946
|
+
Object.defineProperty(assert, asserterName, pd);
|
17947
|
+
}
|
17948
|
+
});
|
17949
|
+
}
|
17950
|
+
|
17951
|
+
transferFlags(this, assert);
|
17952
|
+
return assert;
|
17953
|
+
}
|
17954
|
+
, configurable: true
|
17955
|
+
});
|
17956
|
+
};
|
17957
|
+
|
17958
|
+
});
|
17959
|
+
require.register("chaijs-chai/lib/chai/utils/addMethod.js", function(exports, require, module){
|
17960
|
+
/*!
|
17961
|
+
* Chai - addMethod utility
|
17962
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
17963
|
+
* MIT Licensed
|
17964
|
+
*/
|
17965
|
+
|
17966
|
+
/**
|
17967
|
+
* ### .addMethod (ctx, name, method)
|
17968
|
+
*
|
17969
|
+
* Adds a method to the prototype of an object.
|
17970
|
+
*
|
17971
|
+
* utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
|
17972
|
+
* var obj = utils.flag(this, 'object');
|
17973
|
+
* new chai.Assertion(obj).to.be.equal(str);
|
17974
|
+
* });
|
17975
|
+
*
|
17976
|
+
* Can also be accessed directly from `chai.Assertion`.
|
17977
|
+
*
|
17978
|
+
* chai.Assertion.addMethod('foo', fn);
|
17979
|
+
*
|
17980
|
+
* Then can be used as any other assertion.
|
17981
|
+
*
|
17982
|
+
* expect(fooStr).to.be.foo('bar');
|
17983
|
+
*
|
17984
|
+
* @param {Object} ctx object to which the method is added
|
17985
|
+
* @param {String} name of method to add
|
17986
|
+
* @param {Function} method function to be used for name
|
17987
|
+
* @name addMethod
|
17988
|
+
* @api public
|
17989
|
+
*/
|
17990
|
+
|
17991
|
+
module.exports = function (ctx, name, method) {
|
17992
|
+
ctx[name] = function () {
|
17993
|
+
var result = method.apply(this, arguments);
|
17994
|
+
return result === undefined ? this : result;
|
17995
|
+
};
|
17996
|
+
};
|
17997
|
+
|
17998
|
+
});
|
17999
|
+
require.register("chaijs-chai/lib/chai/utils/addProperty.js", function(exports, require, module){
|
18000
|
+
/*!
|
18001
|
+
* Chai - addProperty utility
|
18002
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18003
|
+
* MIT Licensed
|
18004
|
+
*/
|
18005
|
+
|
18006
|
+
/**
|
18007
|
+
* ### addProperty (ctx, name, getter)
|
18008
|
+
*
|
18009
|
+
* Adds a property to the prototype of an object.
|
18010
|
+
*
|
18011
|
+
* utils.addProperty(chai.Assertion.prototype, 'foo', function () {
|
18012
|
+
* var obj = utils.flag(this, 'object');
|
18013
|
+
* new chai.Assertion(obj).to.be.instanceof(Foo);
|
18014
|
+
* });
|
18015
|
+
*
|
18016
|
+
* Can also be accessed directly from `chai.Assertion`.
|
18017
|
+
*
|
18018
|
+
* chai.Assertion.addProperty('foo', fn);
|
18019
|
+
*
|
18020
|
+
* Then can be used as any other assertion.
|
18021
|
+
*
|
18022
|
+
* expect(myFoo).to.be.foo;
|
18023
|
+
*
|
18024
|
+
* @param {Object} ctx object to which the property is added
|
18025
|
+
* @param {String} name of property to add
|
18026
|
+
* @param {Function} getter function to be used for name
|
18027
|
+
* @name addProperty
|
18028
|
+
* @api public
|
18029
|
+
*/
|
18030
|
+
|
18031
|
+
module.exports = function (ctx, name, getter) {
|
18032
|
+
Object.defineProperty(ctx, name,
|
18033
|
+
{ get: function () {
|
18034
|
+
var result = getter.call(this);
|
18035
|
+
return result === undefined ? this : result;
|
18036
|
+
}
|
18037
|
+
, configurable: true
|
18038
|
+
});
|
18039
|
+
};
|
18040
|
+
|
18041
|
+
});
|
18042
|
+
require.register("chaijs-chai/lib/chai/utils/eql.js", function(exports, require, module){
|
18043
|
+
// This is (almost) directly from Node.js assert
|
18044
|
+
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
|
18045
|
+
|
18046
|
+
module.exports = _deepEqual;
|
18047
|
+
|
18048
|
+
var getEnumerableProperties = require('./getEnumerableProperties');
|
18049
|
+
|
18050
|
+
// for the browser
|
18051
|
+
var Buffer;
|
18052
|
+
try {
|
18053
|
+
Buffer = require('buffer').Buffer;
|
18054
|
+
} catch (ex) {
|
18055
|
+
Buffer = {
|
18056
|
+
isBuffer: function () { return false; }
|
18057
|
+
};
|
18058
|
+
}
|
18059
|
+
|
18060
|
+
function _deepEqual(actual, expected, memos) {
|
18061
|
+
|
18062
|
+
// 7.1. All identical values are equivalent, as determined by ===.
|
18063
|
+
if (actual === expected) {
|
18064
|
+
return true;
|
18065
|
+
|
18066
|
+
} else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
|
18067
|
+
if (actual.length != expected.length) return false;
|
18068
|
+
|
18069
|
+
for (var i = 0; i < actual.length; i++) {
|
18070
|
+
if (actual[i] !== expected[i]) return false;
|
18071
|
+
}
|
18072
|
+
|
18073
|
+
return true;
|
18074
|
+
|
18075
|
+
// 7.2. If the expected value is a Date object, the actual value is
|
18076
|
+
// equivalent if it is also a Date object that refers to the same time.
|
18077
|
+
} else if (expected instanceof Date) {
|
18078
|
+
if (!(actual instanceof Date)) return false;
|
18079
|
+
return actual.getTime() === expected.getTime();
|
18080
|
+
|
18081
|
+
// 7.3. Other pairs that do not both pass typeof value == 'object',
|
18082
|
+
// equivalence is determined by ==.
|
18083
|
+
} else if (typeof actual != 'object' && typeof expected != 'object') {
|
18084
|
+
return actual === expected;
|
18085
|
+
|
18086
|
+
} else if (expected instanceof RegExp) {
|
18087
|
+
if (!(actual instanceof RegExp)) return false;
|
18088
|
+
return actual.toString() === expected.toString();
|
18089
|
+
|
18090
|
+
// 7.4. For all other Object pairs, including Array objects, equivalence is
|
18091
|
+
// determined by having the same number of owned properties (as verified
|
18092
|
+
// with Object.prototype.hasOwnProperty.call), the same set of keys
|
18093
|
+
// (although not necessarily the same order), equivalent values for every
|
18094
|
+
// corresponding key, and an identical 'prototype' property. Note: this
|
18095
|
+
// accounts for both named and indexed properties on Arrays.
|
18096
|
+
} else {
|
18097
|
+
return objEquiv(actual, expected, memos);
|
18098
|
+
}
|
18099
|
+
}
|
18100
|
+
|
18101
|
+
function isUndefinedOrNull(value) {
|
18102
|
+
return value === null || value === undefined;
|
18103
|
+
}
|
18104
|
+
|
18105
|
+
function isArguments(object) {
|
18106
|
+
return Object.prototype.toString.call(object) == '[object Arguments]';
|
18107
|
+
}
|
18108
|
+
|
18109
|
+
function objEquiv(a, b, memos) {
|
18110
|
+
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
|
18111
|
+
return false;
|
18112
|
+
|
18113
|
+
// an identical 'prototype' property.
|
18114
|
+
if (a.prototype !== b.prototype) return false;
|
18115
|
+
|
18116
|
+
// check if we have already compared a and b
|
18117
|
+
var i;
|
18118
|
+
if (memos) {
|
18119
|
+
for(i = 0; i < memos.length; i++) {
|
18120
|
+
if ((memos[i][0] === a && memos[i][1] === b) ||
|
18121
|
+
(memos[i][0] === b && memos[i][1] === a))
|
18122
|
+
return true;
|
18123
|
+
}
|
18124
|
+
} else {
|
18125
|
+
memos = [];
|
18126
|
+
}
|
18127
|
+
|
18128
|
+
//~~~I've managed to break Object.keys through screwy arguments passing.
|
18129
|
+
// Converting to array solves the problem.
|
18130
|
+
if (isArguments(a)) {
|
18131
|
+
if (!isArguments(b)) {
|
18132
|
+
return false;
|
18133
|
+
}
|
18134
|
+
a = pSlice.call(a);
|
18135
|
+
b = pSlice.call(b);
|
18136
|
+
return _deepEqual(a, b, memos);
|
18137
|
+
}
|
18138
|
+
try {
|
18139
|
+
var ka = getEnumerableProperties(a),
|
18140
|
+
kb = getEnumerableProperties(b),
|
18141
|
+
key;
|
18142
|
+
} catch (e) {//happens when one is a string literal and the other isn't
|
18143
|
+
return false;
|
18144
|
+
}
|
18145
|
+
|
18146
|
+
// having the same number of owned properties (keys incorporates
|
18147
|
+
// hasOwnProperty)
|
18148
|
+
if (ka.length != kb.length)
|
18149
|
+
return false;
|
18150
|
+
|
18151
|
+
//the same set of keys (although not necessarily the same order),
|
18152
|
+
ka.sort();
|
18153
|
+
kb.sort();
|
18154
|
+
//~~~cheap key test
|
18155
|
+
for (i = ka.length - 1; i >= 0; i--) {
|
18156
|
+
if (ka[i] != kb[i])
|
18157
|
+
return false;
|
18158
|
+
}
|
18159
|
+
|
18160
|
+
// remember objects we have compared to guard against circular references
|
18161
|
+
memos.push([ a, b ]);
|
18162
|
+
|
18163
|
+
//equivalent values for every corresponding key, and
|
18164
|
+
//~~~possibly expensive deep test
|
18165
|
+
for (i = ka.length - 1; i >= 0; i--) {
|
18166
|
+
key = ka[i];
|
18167
|
+
if (!_deepEqual(a[key], b[key], memos)) return false;
|
18168
|
+
}
|
18169
|
+
|
18170
|
+
return true;
|
18171
|
+
}
|
18172
|
+
|
18173
|
+
});
|
18174
|
+
require.register("chaijs-chai/lib/chai/utils/flag.js", function(exports, require, module){
|
18175
|
+
/*!
|
18176
|
+
* Chai - flag utility
|
18177
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18178
|
+
* MIT Licensed
|
18179
|
+
*/
|
18180
|
+
|
18181
|
+
/**
|
18182
|
+
* ### flag(object ,key, [value])
|
18183
|
+
*
|
18184
|
+
* Get or set a flag value on an object. If a
|
18185
|
+
* value is provided it will be set, else it will
|
18186
|
+
* return the currently set value or `undefined` if
|
18187
|
+
* the value is not set.
|
18188
|
+
*
|
18189
|
+
* utils.flag(this, 'foo', 'bar'); // setter
|
18190
|
+
* utils.flag(this, 'foo'); // getter, returns `bar`
|
18191
|
+
*
|
18192
|
+
* @param {Object} object (constructed Assertion
|
18193
|
+
* @param {String} key
|
18194
|
+
* @param {Mixed} value (optional)
|
18195
|
+
* @name flag
|
18196
|
+
* @api private
|
18197
|
+
*/
|
18198
|
+
|
18199
|
+
module.exports = function (obj, key, value) {
|
18200
|
+
var flags = obj.__flags || (obj.__flags = Object.create(null));
|
18201
|
+
if (arguments.length === 3) {
|
18202
|
+
flags[key] = value;
|
18203
|
+
} else {
|
18204
|
+
return flags[key];
|
18205
|
+
}
|
18206
|
+
};
|
18207
|
+
|
18208
|
+
});
|
18209
|
+
require.register("chaijs-chai/lib/chai/utils/getActual.js", function(exports, require, module){
|
18210
|
+
/*!
|
18211
|
+
* Chai - getActual utility
|
18212
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18213
|
+
* MIT Licensed
|
18214
|
+
*/
|
18215
|
+
|
18216
|
+
/**
|
18217
|
+
* # getActual(object, [actual])
|
18218
|
+
*
|
18219
|
+
* Returns the `actual` value for an Assertion
|
18220
|
+
*
|
18221
|
+
* @param {Object} object (constructed Assertion)
|
18222
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
18223
|
+
*/
|
18224
|
+
|
18225
|
+
module.exports = function (obj, args) {
|
18226
|
+
var actual = args[4];
|
18227
|
+
return 'undefined' !== typeof actual ? actual : obj._obj;
|
18228
|
+
};
|
18229
|
+
|
18230
|
+
});
|
18231
|
+
require.register("chaijs-chai/lib/chai/utils/getEnumerableProperties.js", function(exports, require, module){
|
18232
|
+
/*!
|
18233
|
+
* Chai - getEnumerableProperties utility
|
18234
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18235
|
+
* MIT Licensed
|
18236
|
+
*/
|
18237
|
+
|
18238
|
+
/**
|
18239
|
+
* ### .getEnumerableProperties(object)
|
18240
|
+
*
|
18241
|
+
* This allows the retrieval of enumerable property names of an object,
|
18242
|
+
* inherited or not.
|
18243
|
+
*
|
18244
|
+
* @param {Object} object
|
18245
|
+
* @returns {Array}
|
18246
|
+
* @name getEnumerableProperties
|
18247
|
+
* @api public
|
18248
|
+
*/
|
18249
|
+
|
18250
|
+
module.exports = function getEnumerableProperties(object) {
|
18251
|
+
var result = [];
|
18252
|
+
for (var name in object) {
|
18253
|
+
result.push(name);
|
18254
|
+
}
|
18255
|
+
return result;
|
18256
|
+
};
|
18257
|
+
|
18258
|
+
});
|
18259
|
+
require.register("chaijs-chai/lib/chai/utils/getMessage.js", function(exports, require, module){
|
18260
|
+
/*!
|
18261
|
+
* Chai - message composition utility
|
18262
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18263
|
+
* MIT Licensed
|
18264
|
+
*/
|
18265
|
+
|
18266
|
+
/*!
|
18267
|
+
* Module dependancies
|
18268
|
+
*/
|
18269
|
+
|
18270
|
+
var flag = require('./flag')
|
18271
|
+
, getActual = require('./getActual')
|
18272
|
+
, inspect = require('./inspect')
|
18273
|
+
, objDisplay = require('./objDisplay');
|
18274
|
+
|
18275
|
+
/**
|
18276
|
+
* ### .getMessage(object, message, negateMessage)
|
18277
|
+
*
|
18278
|
+
* Construct the error message based on flags
|
18279
|
+
* and template tags. Template tags will return
|
18280
|
+
* a stringified inspection of the object referenced.
|
18281
|
+
*
|
18282
|
+
* Message template tags:
|
18283
|
+
* - `#{this}` current asserted object
|
18284
|
+
* - `#{act}` actual value
|
18285
|
+
* - `#{exp}` expected value
|
18286
|
+
*
|
18287
|
+
* @param {Object} object (constructed Assertion)
|
18288
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
18289
|
+
* @name getMessage
|
18290
|
+
* @api public
|
18291
|
+
*/
|
18292
|
+
|
18293
|
+
module.exports = function (obj, args) {
|
18294
|
+
var negate = flag(obj, 'negate')
|
18295
|
+
, val = flag(obj, 'object')
|
18296
|
+
, expected = args[3]
|
18297
|
+
, actual = getActual(obj, args)
|
18298
|
+
, msg = negate ? args[2] : args[1]
|
18299
|
+
, flagMsg = flag(obj, 'message');
|
18300
|
+
|
18301
|
+
msg = msg || '';
|
18302
|
+
msg = msg
|
18303
|
+
.replace(/#{this}/g, objDisplay(val))
|
18304
|
+
.replace(/#{act}/g, objDisplay(actual))
|
18305
|
+
.replace(/#{exp}/g, objDisplay(expected));
|
18306
|
+
|
18307
|
+
return flagMsg ? flagMsg + ': ' + msg : msg;
|
18308
|
+
};
|
18309
|
+
|
18310
|
+
});
|
18311
|
+
require.register("chaijs-chai/lib/chai/utils/getName.js", function(exports, require, module){
|
18312
|
+
/*!
|
18313
|
+
* Chai - getName utility
|
18314
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18315
|
+
* MIT Licensed
|
18316
|
+
*/
|
18317
|
+
|
18318
|
+
/**
|
18319
|
+
* # getName(func)
|
18320
|
+
*
|
18321
|
+
* Gets the name of a function, in a cross-browser way.
|
18322
|
+
*
|
18323
|
+
* @param {Function} a function (usually a constructor)
|
18324
|
+
*/
|
18325
|
+
|
18326
|
+
module.exports = function (func) {
|
18327
|
+
if (func.name) return func.name;
|
18328
|
+
|
18329
|
+
var match = /^\s?function ([^(]*)\(/.exec(func);
|
18330
|
+
return match && match[1] ? match[1] : "";
|
18331
|
+
};
|
18332
|
+
|
18333
|
+
});
|
18334
|
+
require.register("chaijs-chai/lib/chai/utils/getPathValue.js", function(exports, require, module){
|
18335
|
+
/*!
|
18336
|
+
* Chai - getPathValue utility
|
18337
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18338
|
+
* @see https://github.com/logicalparadox/filtr
|
18339
|
+
* MIT Licensed
|
18340
|
+
*/
|
18341
|
+
|
18342
|
+
/**
|
18343
|
+
* ### .getPathValue(path, object)
|
18344
|
+
*
|
18345
|
+
* This allows the retrieval of values in an
|
18346
|
+
* object given a string path.
|
18347
|
+
*
|
18348
|
+
* var obj = {
|
18349
|
+
* prop1: {
|
18350
|
+
* arr: ['a', 'b', 'c']
|
18351
|
+
* , str: 'Hello'
|
18352
|
+
* }
|
18353
|
+
* , prop2: {
|
18354
|
+
* arr: [ { nested: 'Universe' } ]
|
18355
|
+
* , str: 'Hello again!'
|
18356
|
+
* }
|
18357
|
+
* }
|
18358
|
+
*
|
18359
|
+
* The following would be the results.
|
18360
|
+
*
|
18361
|
+
* getPathValue('prop1.str', obj); // Hello
|
18362
|
+
* getPathValue('prop1.att[2]', obj); // b
|
18363
|
+
* getPathValue('prop2.arr[0].nested', obj); // Universe
|
18364
|
+
*
|
18365
|
+
* @param {String} path
|
18366
|
+
* @param {Object} object
|
18367
|
+
* @returns {Object} value or `undefined`
|
18368
|
+
* @name getPathValue
|
18369
|
+
* @api public
|
18370
|
+
*/
|
18371
|
+
|
18372
|
+
var getPathValue = module.exports = function (path, obj) {
|
18373
|
+
var parsed = parsePath(path);
|
18374
|
+
return _getPathValue(parsed, obj);
|
18375
|
+
};
|
18376
|
+
|
18377
|
+
/*!
|
18378
|
+
* ## parsePath(path)
|
18379
|
+
*
|
18380
|
+
* Helper function used to parse string object
|
18381
|
+
* paths. Use in conjunction with `_getPathValue`.
|
18382
|
+
*
|
18383
|
+
* var parsed = parsePath('myobject.property.subprop');
|
18384
|
+
*
|
18385
|
+
* ### Paths:
|
18386
|
+
*
|
18387
|
+
* * Can be as near infinitely deep and nested
|
18388
|
+
* * Arrays are also valid using the formal `myobject.document[3].property`.
|
18389
|
+
*
|
18390
|
+
* @param {String} path
|
18391
|
+
* @returns {Object} parsed
|
18392
|
+
* @api private
|
18393
|
+
*/
|
18394
|
+
|
18395
|
+
function parsePath (path) {
|
18396
|
+
var str = path.replace(/\[/g, '.[')
|
18397
|
+
, parts = str.match(/(\\\.|[^.]+?)+/g);
|
18398
|
+
return parts.map(function (value) {
|
18399
|
+
var re = /\[(\d+)\]$/
|
18400
|
+
, mArr = re.exec(value)
|
18401
|
+
if (mArr) return { i: parseFloat(mArr[1]) };
|
18402
|
+
else return { p: value };
|
18403
|
+
});
|
18404
|
+
};
|
18405
|
+
|
18406
|
+
/*!
|
18407
|
+
* ## _getPathValue(parsed, obj)
|
18408
|
+
*
|
18409
|
+
* Helper companion function for `.parsePath` that returns
|
18410
|
+
* the value located at the parsed address.
|
18411
|
+
*
|
18412
|
+
* var value = getPathValue(parsed, obj);
|
18413
|
+
*
|
18414
|
+
* @param {Object} parsed definition from `parsePath`.
|
18415
|
+
* @param {Object} object to search against
|
18416
|
+
* @returns {Object|Undefined} value
|
18417
|
+
* @api private
|
18418
|
+
*/
|
18419
|
+
|
18420
|
+
function _getPathValue (parsed, obj) {
|
18421
|
+
var tmp = obj
|
18422
|
+
, res;
|
18423
|
+
for (var i = 0, l = parsed.length; i < l; i++) {
|
18424
|
+
var part = parsed[i];
|
18425
|
+
if (tmp) {
|
18426
|
+
if ('undefined' !== typeof part.p)
|
18427
|
+
tmp = tmp[part.p];
|
18428
|
+
else if ('undefined' !== typeof part.i)
|
18429
|
+
tmp = tmp[part.i];
|
18430
|
+
if (i == (l - 1)) res = tmp;
|
18431
|
+
} else {
|
18432
|
+
res = undefined;
|
18433
|
+
}
|
18434
|
+
}
|
18435
|
+
return res;
|
18436
|
+
};
|
18437
|
+
|
18438
|
+
});
|
18439
|
+
require.register("chaijs-chai/lib/chai/utils/getProperties.js", function(exports, require, module){
|
18440
|
+
/*!
|
18441
|
+
* Chai - getProperties utility
|
18442
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18443
|
+
* MIT Licensed
|
18444
|
+
*/
|
18445
|
+
|
18446
|
+
/**
|
18447
|
+
* ### .getProperties(object)
|
18448
|
+
*
|
18449
|
+
* This allows the retrieval of property names of an object, enumerable or not,
|
18450
|
+
* inherited or not.
|
18451
|
+
*
|
18452
|
+
* @param {Object} object
|
18453
|
+
* @returns {Array}
|
18454
|
+
* @name getProperties
|
18455
|
+
* @api public
|
18456
|
+
*/
|
18457
|
+
|
18458
|
+
module.exports = function getProperties(object) {
|
18459
|
+
var result = Object.getOwnPropertyNames(subject);
|
18460
|
+
|
18461
|
+
function addProperty(property) {
|
18462
|
+
if (result.indexOf(property) === -1) {
|
18463
|
+
result.push(property);
|
18464
|
+
}
|
18465
|
+
}
|
18466
|
+
|
18467
|
+
var proto = Object.getPrototypeOf(subject);
|
18468
|
+
while (proto !== null) {
|
18469
|
+
Object.getOwnPropertyNames(proto).forEach(addProperty);
|
18470
|
+
proto = Object.getPrototypeOf(proto);
|
18471
|
+
}
|
18472
|
+
|
18473
|
+
return result;
|
18474
|
+
};
|
18475
|
+
|
18476
|
+
});
|
18477
|
+
require.register("chaijs-chai/lib/chai/utils/index.js", function(exports, require, module){
|
18478
|
+
/*!
|
18479
|
+
* chai
|
18480
|
+
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
18481
|
+
* MIT Licensed
|
18482
|
+
*/
|
18483
|
+
|
18484
|
+
/*!
|
18485
|
+
* Main exports
|
18486
|
+
*/
|
18487
|
+
|
18488
|
+
var exports = module.exports = {};
|
18489
|
+
|
18490
|
+
/*!
|
18491
|
+
* test utility
|
18492
|
+
*/
|
18493
|
+
|
18494
|
+
exports.test = require('./test');
|
18495
|
+
|
18496
|
+
/*!
|
18497
|
+
* type utility
|
18498
|
+
*/
|
18499
|
+
|
18500
|
+
exports.type = require('./type');
|
18501
|
+
|
18502
|
+
/*!
|
18503
|
+
* message utility
|
18504
|
+
*/
|
18505
|
+
|
18506
|
+
exports.getMessage = require('./getMessage');
|
18507
|
+
|
18508
|
+
/*!
|
18509
|
+
* actual utility
|
18510
|
+
*/
|
18511
|
+
|
18512
|
+
exports.getActual = require('./getActual');
|
18513
|
+
|
18514
|
+
/*!
|
18515
|
+
* Inspect util
|
18516
|
+
*/
|
18517
|
+
|
18518
|
+
exports.inspect = require('./inspect');
|
18519
|
+
|
18520
|
+
/*!
|
18521
|
+
* Object Display util
|
18522
|
+
*/
|
18523
|
+
|
18524
|
+
exports.objDisplay = require('./objDisplay');
|
18525
|
+
|
18526
|
+
/*!
|
18527
|
+
* Flag utility
|
18528
|
+
*/
|
18529
|
+
|
18530
|
+
exports.flag = require('./flag');
|
18531
|
+
|
18532
|
+
/*!
|
18533
|
+
* Flag transferring utility
|
18534
|
+
*/
|
18535
|
+
|
18536
|
+
exports.transferFlags = require('./transferFlags');
|
18537
|
+
|
18538
|
+
/*!
|
18539
|
+
* Deep equal utility
|
18540
|
+
*/
|
18541
|
+
|
18542
|
+
exports.eql = require('./eql');
|
18543
|
+
|
18544
|
+
/*!
|
18545
|
+
* Deep path value
|
18546
|
+
*/
|
18547
|
+
|
18548
|
+
exports.getPathValue = require('./getPathValue');
|
18549
|
+
|
18550
|
+
/*!
|
18551
|
+
* Function name
|
18552
|
+
*/
|
18553
|
+
|
18554
|
+
exports.getName = require('./getName');
|
18555
|
+
|
18556
|
+
/*!
|
18557
|
+
* add Property
|
18558
|
+
*/
|
18559
|
+
|
18560
|
+
exports.addProperty = require('./addProperty');
|
18561
|
+
|
18562
|
+
/*!
|
18563
|
+
* add Method
|
18564
|
+
*/
|
18565
|
+
|
18566
|
+
exports.addMethod = require('./addMethod');
|
18567
|
+
|
18568
|
+
/*!
|
18569
|
+
* overwrite Property
|
18570
|
+
*/
|
18571
|
+
|
18572
|
+
exports.overwriteProperty = require('./overwriteProperty');
|
18573
|
+
|
18574
|
+
/*!
|
18575
|
+
* overwrite Method
|
18576
|
+
*/
|
18577
|
+
|
18578
|
+
exports.overwriteMethod = require('./overwriteMethod');
|
18579
|
+
|
18580
|
+
/*!
|
18581
|
+
* Add a chainable method
|
18582
|
+
*/
|
18583
|
+
|
18584
|
+
exports.addChainableMethod = require('./addChainableMethod');
|
18585
|
+
|
18586
|
+
|
18587
|
+
});
|
18588
|
+
require.register("chaijs-chai/lib/chai/utils/inspect.js", function(exports, require, module){
|
18589
|
+
// This is (almost) directly from Node.js utils
|
18590
|
+
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
|
18591
|
+
|
18592
|
+
var getName = require('./getName');
|
18593
|
+
var getProperties = require('./getProperties');
|
18594
|
+
var getEnumerableProperties = require('./getEnumerableProperties');
|
18595
|
+
|
18596
|
+
module.exports = inspect;
|
18597
|
+
|
18598
|
+
/**
|
18599
|
+
* Echos the value of a value. Trys to print the value out
|
18600
|
+
* in the best way possible given the different types.
|
18601
|
+
*
|
18602
|
+
* @param {Object} obj The object to print out.
|
18603
|
+
* @param {Boolean} showHidden Flag that shows hidden (not enumerable)
|
18604
|
+
* properties of objects.
|
18605
|
+
* @param {Number} depth Depth in which to descend in object. Default is 2.
|
18606
|
+
* @param {Boolean} colors Flag to turn on ANSI escape codes to color the
|
18607
|
+
* output. Default is false (no coloring).
|
18608
|
+
*/
|
18609
|
+
function inspect(obj, showHidden, depth, colors) {
|
18610
|
+
var ctx = {
|
18611
|
+
showHidden: showHidden,
|
18612
|
+
seen: [],
|
18613
|
+
stylize: function (str) { return str; }
|
18614
|
+
};
|
18615
|
+
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
|
18616
|
+
}
|
18617
|
+
|
18618
|
+
// https://gist.github.com/1044128/
|
18619
|
+
var getOuterHTML = function(element) {
|
18620
|
+
if ('outerHTML' in element) return element.outerHTML;
|
18621
|
+
var ns = "http://www.w3.org/1999/xhtml";
|
18622
|
+
var container = document.createElementNS(ns, '_');
|
18623
|
+
var elemProto = (window.HTMLElement || window.Element).prototype;
|
18624
|
+
var xmlSerializer = new XMLSerializer();
|
18625
|
+
var html;
|
18626
|
+
if (document.xmlVersion) {
|
18627
|
+
return xmlSerializer.serializeToString(element);
|
18628
|
+
} else {
|
18629
|
+
container.appendChild(element.cloneNode(false));
|
18630
|
+
html = container.innerHTML.replace('><', '>' + element.innerHTML + '<');
|
18631
|
+
container.innerHTML = '';
|
18632
|
+
return html;
|
18633
|
+
}
|
18634
|
+
};
|
18635
|
+
|
18636
|
+
// Returns true if object is a DOM element.
|
18637
|
+
var isDOMElement = function (object) {
|
18638
|
+
if (typeof HTMLElement === 'object') {
|
18639
|
+
return object instanceof HTMLElement;
|
18640
|
+
} else {
|
18641
|
+
return object &&
|
18642
|
+
typeof object === 'object' &&
|
18643
|
+
object.nodeType === 1 &&
|
18644
|
+
typeof object.nodeName === 'string';
|
18645
|
+
}
|
18646
|
+
};
|
18647
|
+
|
18648
|
+
function formatValue(ctx, value, recurseTimes) {
|
18649
|
+
// Provide a hook for user-specified inspect functions.
|
18650
|
+
// Check that value is an object with an inspect function on it
|
18651
|
+
if (value && typeof value.inspect === 'function' &&
|
18652
|
+
// Filter out the util module, it's inspect function is special
|
18653
|
+
value.inspect !== exports.inspect &&
|
18654
|
+
// Also filter out any prototype objects using the circular check.
|
18655
|
+
!(value.constructor && value.constructor.prototype === value)) {
|
18656
|
+
var ret = value.inspect(recurseTimes);
|
18657
|
+
if (typeof ret !== 'string') {
|
18658
|
+
ret = formatValue(ctx, ret, recurseTimes);
|
18659
|
+
}
|
18660
|
+
return ret;
|
18661
|
+
}
|
18662
|
+
|
18663
|
+
// Primitive types cannot have properties
|
18664
|
+
var primitive = formatPrimitive(ctx, value);
|
18665
|
+
if (primitive) {
|
18666
|
+
return primitive;
|
18667
|
+
}
|
18668
|
+
|
18669
|
+
// If it's DOM elem, get outer HTML.
|
18670
|
+
if (isDOMElement(value)) {
|
18671
|
+
return getOuterHTML(value);
|
18672
|
+
}
|
18673
|
+
|
18674
|
+
// Look up the keys of the object.
|
18675
|
+
var visibleKeys = getEnumerableProperties(value);
|
18676
|
+
var keys = ctx.showHidden ? getProperties(value) : visibleKeys;
|
18677
|
+
|
18678
|
+
// Some type of object without properties can be shortcutted.
|
18679
|
+
// In IE, errors have a single `stack` property, or if they are vanilla `Error`,
|
18680
|
+
// a `stack` plus `description` property; ignore those for consistency.
|
18681
|
+
if (keys.length === 0 || (isError(value) && (
|
18682
|
+
(keys.length === 1 && keys[0] === 'stack') ||
|
18683
|
+
(keys.length === 2 && keys[0] === 'description' && keys[1] === 'stack')
|
18684
|
+
))) {
|
18685
|
+
if (typeof value === 'function') {
|
18686
|
+
var name = getName(value);
|
18687
|
+
var nameSuffix = name ? ': ' + name : '';
|
18688
|
+
return ctx.stylize('[Function' + nameSuffix + ']', 'special');
|
18689
|
+
}
|
18690
|
+
if (isRegExp(value)) {
|
18691
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
18692
|
+
}
|
18693
|
+
if (isDate(value)) {
|
18694
|
+
return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
|
18695
|
+
}
|
18696
|
+
if (isError(value)) {
|
18697
|
+
return formatError(value);
|
18698
|
+
}
|
18699
|
+
}
|
18700
|
+
|
18701
|
+
var base = '', array = false, braces = ['{', '}'];
|
18702
|
+
|
18703
|
+
// Make Array say that they are Array
|
18704
|
+
if (isArray(value)) {
|
18705
|
+
array = true;
|
18706
|
+
braces = ['[', ']'];
|
18707
|
+
}
|
18708
|
+
|
18709
|
+
// Make functions say that they are functions
|
18710
|
+
if (typeof value === 'function') {
|
18711
|
+
var name = getName(value);
|
18712
|
+
var nameSuffix = name ? ': ' + name : '';
|
18713
|
+
base = ' [Function' + nameSuffix + ']';
|
18714
|
+
}
|
18715
|
+
|
18716
|
+
// Make RegExps say that they are RegExps
|
18717
|
+
if (isRegExp(value)) {
|
18718
|
+
base = ' ' + RegExp.prototype.toString.call(value);
|
18719
|
+
}
|
18720
|
+
|
18721
|
+
// Make dates with properties first say the date
|
18722
|
+
if (isDate(value)) {
|
18723
|
+
base = ' ' + Date.prototype.toUTCString.call(value);
|
18724
|
+
}
|
18725
|
+
|
18726
|
+
// Make error with message first say the error
|
18727
|
+
if (isError(value)) {
|
18728
|
+
return formatError(value);
|
18729
|
+
}
|
18730
|
+
|
18731
|
+
if (keys.length === 0 && (!array || value.length == 0)) {
|
18732
|
+
return braces[0] + base + braces[1];
|
18733
|
+
}
|
18734
|
+
|
18735
|
+
if (recurseTimes < 0) {
|
18736
|
+
if (isRegExp(value)) {
|
18737
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
18738
|
+
} else {
|
18739
|
+
return ctx.stylize('[Object]', 'special');
|
18740
|
+
}
|
18741
|
+
}
|
18742
|
+
|
18743
|
+
ctx.seen.push(value);
|
18744
|
+
|
18745
|
+
var output;
|
18746
|
+
if (array) {
|
18747
|
+
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
18748
|
+
} else {
|
18749
|
+
output = keys.map(function(key) {
|
18750
|
+
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
18751
|
+
});
|
18752
|
+
}
|
18753
|
+
|
18754
|
+
ctx.seen.pop();
|
18755
|
+
|
18756
|
+
return reduceToSingleString(output, base, braces);
|
18757
|
+
}
|
18758
|
+
|
18759
|
+
|
18760
|
+
function formatPrimitive(ctx, value) {
|
18761
|
+
switch (typeof value) {
|
18762
|
+
case 'undefined':
|
18763
|
+
return ctx.stylize('undefined', 'undefined');
|
18764
|
+
|
18765
|
+
case 'string':
|
18766
|
+
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
18767
|
+
.replace(/'/g, "\\'")
|
18768
|
+
.replace(/\\"/g, '"') + '\'';
|
18769
|
+
return ctx.stylize(simple, 'string');
|
18770
|
+
|
18771
|
+
case 'number':
|
18772
|
+
return ctx.stylize('' + value, 'number');
|
18773
|
+
|
18774
|
+
case 'boolean':
|
18775
|
+
return ctx.stylize('' + value, 'boolean');
|
18776
|
+
}
|
18777
|
+
// For some reason typeof null is "object", so special case here.
|
18778
|
+
if (value === null) {
|
18779
|
+
return ctx.stylize('null', 'null');
|
18780
|
+
}
|
18781
|
+
}
|
18782
|
+
|
18783
|
+
|
18784
|
+
function formatError(value) {
|
18785
|
+
return '[' + Error.prototype.toString.call(value) + ']';
|
18786
|
+
}
|
18787
|
+
|
18788
|
+
|
18789
|
+
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
18790
|
+
var output = [];
|
18791
|
+
for (var i = 0, l = value.length; i < l; ++i) {
|
18792
|
+
if (Object.prototype.hasOwnProperty.call(value, String(i))) {
|
18793
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
18794
|
+
String(i), true));
|
18795
|
+
} else {
|
18796
|
+
output.push('');
|
18797
|
+
}
|
18798
|
+
}
|
18799
|
+
keys.forEach(function(key) {
|
18800
|
+
if (!key.match(/^\d+$/)) {
|
18801
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
18802
|
+
key, true));
|
18803
|
+
}
|
18804
|
+
});
|
18805
|
+
return output;
|
18806
|
+
}
|
18807
|
+
|
18808
|
+
|
18809
|
+
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
18810
|
+
var name, str;
|
18811
|
+
if (value.__lookupGetter__) {
|
18812
|
+
if (value.__lookupGetter__(key)) {
|
18813
|
+
if (value.__lookupSetter__(key)) {
|
18814
|
+
str = ctx.stylize('[Getter/Setter]', 'special');
|
18815
|
+
} else {
|
18816
|
+
str = ctx.stylize('[Getter]', 'special');
|
18817
|
+
}
|
18818
|
+
} else {
|
18819
|
+
if (value.__lookupSetter__(key)) {
|
18820
|
+
str = ctx.stylize('[Setter]', 'special');
|
18821
|
+
}
|
18822
|
+
}
|
18823
|
+
}
|
18824
|
+
if (visibleKeys.indexOf(key) < 0) {
|
18825
|
+
name = '[' + key + ']';
|
18826
|
+
}
|
18827
|
+
if (!str) {
|
18828
|
+
if (ctx.seen.indexOf(value[key]) < 0) {
|
18829
|
+
if (recurseTimes === null) {
|
18830
|
+
str = formatValue(ctx, value[key], null);
|
18831
|
+
} else {
|
18832
|
+
str = formatValue(ctx, value[key], recurseTimes - 1);
|
18833
|
+
}
|
18834
|
+
if (str.indexOf('\n') > -1) {
|
18835
|
+
if (array) {
|
18836
|
+
str = str.split('\n').map(function(line) {
|
18837
|
+
return ' ' + line;
|
18838
|
+
}).join('\n').substr(2);
|
18839
|
+
} else {
|
18840
|
+
str = '\n' + str.split('\n').map(function(line) {
|
18841
|
+
return ' ' + line;
|
18842
|
+
}).join('\n');
|
18843
|
+
}
|
18844
|
+
}
|
18845
|
+
} else {
|
18846
|
+
str = ctx.stylize('[Circular]', 'special');
|
18847
|
+
}
|
18848
|
+
}
|
18849
|
+
if (typeof name === 'undefined') {
|
18850
|
+
if (array && key.match(/^\d+$/)) {
|
18851
|
+
return str;
|
18852
|
+
}
|
18853
|
+
name = JSON.stringify('' + key);
|
18854
|
+
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
18855
|
+
name = name.substr(1, name.length - 2);
|
18856
|
+
name = ctx.stylize(name, 'name');
|
18857
|
+
} else {
|
18858
|
+
name = name.replace(/'/g, "\\'")
|
18859
|
+
.replace(/\\"/g, '"')
|
18860
|
+
.replace(/(^"|"$)/g, "'");
|
18861
|
+
name = ctx.stylize(name, 'string');
|
18862
|
+
}
|
18863
|
+
}
|
18864
|
+
|
18865
|
+
return name + ': ' + str;
|
18866
|
+
}
|
18867
|
+
|
18868
|
+
|
18869
|
+
function reduceToSingleString(output, base, braces) {
|
18870
|
+
var numLinesEst = 0;
|
18871
|
+
var length = output.reduce(function(prev, cur) {
|
18872
|
+
numLinesEst++;
|
18873
|
+
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
18874
|
+
return prev + cur.length + 1;
|
18875
|
+
}, 0);
|
18876
|
+
|
18877
|
+
if (length > 60) {
|
18878
|
+
return braces[0] +
|
18879
|
+
(base === '' ? '' : base + '\n ') +
|
18880
|
+
' ' +
|
18881
|
+
output.join(',\n ') +
|
18882
|
+
' ' +
|
18883
|
+
braces[1];
|
18884
|
+
}
|
18885
|
+
|
18886
|
+
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
18887
|
+
}
|
18888
|
+
|
18889
|
+
function isArray(ar) {
|
18890
|
+
return Array.isArray(ar) ||
|
18891
|
+
(typeof ar === 'object' && objectToString(ar) === '[object Array]');
|
18892
|
+
}
|
18893
|
+
|
18894
|
+
function isRegExp(re) {
|
18895
|
+
return typeof re === 'object' && objectToString(re) === '[object RegExp]';
|
18896
|
+
}
|
18897
|
+
|
18898
|
+
function isDate(d) {
|
18899
|
+
return typeof d === 'object' && objectToString(d) === '[object Date]';
|
18900
|
+
}
|
18901
|
+
|
18902
|
+
function isError(e) {
|
18903
|
+
return typeof e === 'object' && objectToString(e) === '[object Error]';
|
18904
|
+
}
|
18905
|
+
|
18906
|
+
function objectToString(o) {
|
18907
|
+
return Object.prototype.toString.call(o);
|
18908
|
+
}
|
18909
|
+
|
18910
|
+
});
|
18911
|
+
require.register("chaijs-chai/lib/chai/utils/objDisplay.js", function(exports, require, module){
|
18912
|
+
/*!
|
18913
|
+
* Chai - flag utility
|
18914
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18915
|
+
* MIT Licensed
|
18916
|
+
*/
|
18917
|
+
|
18918
|
+
/*!
|
18919
|
+
* Module dependancies
|
18920
|
+
*/
|
18921
|
+
|
18922
|
+
var inspect = require('./inspect');
|
18923
|
+
|
18924
|
+
/**
|
18925
|
+
* ### .objDisplay (object)
|
18926
|
+
*
|
18927
|
+
* Determines if an object or an array matches
|
18928
|
+
* criteria to be inspected in-line for error
|
18929
|
+
* messages or should be truncated.
|
18930
|
+
*
|
18931
|
+
* @param {Mixed} javascript object to inspect
|
18932
|
+
* @name objDisplay
|
18933
|
+
* @api public
|
18934
|
+
*/
|
18935
|
+
|
18936
|
+
module.exports = function (obj) {
|
18937
|
+
var str = inspect(obj)
|
18938
|
+
, type = Object.prototype.toString.call(obj);
|
18939
|
+
|
18940
|
+
if (str.length >= 40) {
|
18941
|
+
if (type === '[object Function]') {
|
18942
|
+
return !obj.name || obj.name === ''
|
18943
|
+
? '[Function]'
|
18944
|
+
: '[Function: ' + obj.name + ']';
|
18945
|
+
} else if (type === '[object Array]') {
|
18946
|
+
return '[ Array(' + obj.length + ') ]';
|
18947
|
+
} else if (type === '[object Object]') {
|
18948
|
+
var keys = Object.keys(obj)
|
18949
|
+
, kstr = keys.length > 2
|
18950
|
+
? keys.splice(0, 2).join(', ') + ', ...'
|
18951
|
+
: keys.join(', ');
|
18952
|
+
return '{ Object (' + kstr + ') }';
|
18953
|
+
} else {
|
18954
|
+
return str;
|
18955
|
+
}
|
18956
|
+
} else {
|
18957
|
+
return str;
|
18958
|
+
}
|
18959
|
+
};
|
18960
|
+
|
18961
|
+
});
|
18962
|
+
require.register("chaijs-chai/lib/chai/utils/overwriteMethod.js", function(exports, require, module){
|
18963
|
+
/*!
|
18964
|
+
* Chai - overwriteMethod utility
|
18965
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
18966
|
+
* MIT Licensed
|
18967
|
+
*/
|
18968
|
+
|
18969
|
+
/**
|
18970
|
+
* ### overwriteMethod (ctx, name, fn)
|
18971
|
+
*
|
18972
|
+
* Overwites an already existing method and provides
|
18973
|
+
* access to previous function. Must return function
|
18974
|
+
* to be used for name.
|
18975
|
+
*
|
18976
|
+
* utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
|
18977
|
+
* return function (str) {
|
18978
|
+
* var obj = utils.flag(this, 'object');
|
18979
|
+
* if (obj instanceof Foo) {
|
18980
|
+
* new chai.Assertion(obj.value).to.equal(str);
|
18981
|
+
* } else {
|
18982
|
+
* _super.apply(this, arguments);
|
18983
|
+
* }
|
18984
|
+
* }
|
18985
|
+
* });
|
18986
|
+
*
|
18987
|
+
* Can also be accessed directly from `chai.Assertion`.
|
18988
|
+
*
|
18989
|
+
* chai.Assertion.overwriteMethod('foo', fn);
|
18990
|
+
*
|
18991
|
+
* Then can be used as any other assertion.
|
18992
|
+
*
|
18993
|
+
* expect(myFoo).to.equal('bar');
|
18994
|
+
*
|
18995
|
+
* @param {Object} ctx object whose method is to be overwritten
|
18996
|
+
* @param {String} name of method to overwrite
|
18997
|
+
* @param {Function} method function that returns a function to be used for name
|
18998
|
+
* @name overwriteMethod
|
18999
|
+
* @api public
|
19000
|
+
*/
|
19001
|
+
|
19002
|
+
module.exports = function (ctx, name, method) {
|
19003
|
+
var _method = ctx[name]
|
19004
|
+
, _super = function () { return this; };
|
19005
|
+
|
19006
|
+
if (_method && 'function' === typeof _method)
|
19007
|
+
_super = _method;
|
19008
|
+
|
19009
|
+
ctx[name] = function () {
|
19010
|
+
var result = method(_super).apply(this, arguments);
|
19011
|
+
return result === undefined ? this : result;
|
19012
|
+
}
|
19013
|
+
};
|
19014
|
+
|
19015
|
+
});
|
19016
|
+
require.register("chaijs-chai/lib/chai/utils/overwriteProperty.js", function(exports, require, module){
|
19017
|
+
/*!
|
19018
|
+
* Chai - overwriteProperty utility
|
19019
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
19020
|
+
* MIT Licensed
|
19021
|
+
*/
|
19022
|
+
|
19023
|
+
/**
|
19024
|
+
* ### overwriteProperty (ctx, name, fn)
|
19025
|
+
*
|
19026
|
+
* Overwites an already existing property getter and provides
|
19027
|
+
* access to previous value. Must return function to use as getter.
|
19028
|
+
*
|
19029
|
+
* utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
|
19030
|
+
* return function () {
|
19031
|
+
* var obj = utils.flag(this, 'object');
|
19032
|
+
* if (obj instanceof Foo) {
|
19033
|
+
* new chai.Assertion(obj.name).to.equal('bar');
|
19034
|
+
* } else {
|
19035
|
+
* _super.call(this);
|
19036
|
+
* }
|
19037
|
+
* }
|
19038
|
+
* });
|
19039
|
+
*
|
19040
|
+
*
|
19041
|
+
* Can also be accessed directly from `chai.Assertion`.
|
19042
|
+
*
|
19043
|
+
* chai.Assertion.overwriteProperty('foo', fn);
|
19044
|
+
*
|
19045
|
+
* Then can be used as any other assertion.
|
19046
|
+
*
|
19047
|
+
* expect(myFoo).to.be.ok;
|
19048
|
+
*
|
19049
|
+
* @param {Object} ctx object whose property is to be overwritten
|
19050
|
+
* @param {String} name of property to overwrite
|
19051
|
+
* @param {Function} getter function that returns a getter function to be used for name
|
19052
|
+
* @name overwriteProperty
|
19053
|
+
* @api public
|
19054
|
+
*/
|
19055
|
+
|
19056
|
+
module.exports = function (ctx, name, getter) {
|
19057
|
+
var _get = Object.getOwnPropertyDescriptor(ctx, name)
|
19058
|
+
, _super = function () {};
|
19059
|
+
|
19060
|
+
if (_get && 'function' === typeof _get.get)
|
19061
|
+
_super = _get.get
|
19062
|
+
|
19063
|
+
Object.defineProperty(ctx, name,
|
19064
|
+
{ get: function () {
|
19065
|
+
var result = getter(_super).call(this);
|
19066
|
+
return result === undefined ? this : result;
|
19067
|
+
}
|
19068
|
+
, configurable: true
|
19069
|
+
});
|
19070
|
+
};
|
19071
|
+
|
19072
|
+
});
|
19073
|
+
require.register("chaijs-chai/lib/chai/utils/test.js", function(exports, require, module){
|
19074
|
+
/*!
|
19075
|
+
* Chai - test utility
|
19076
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
19077
|
+
* MIT Licensed
|
19078
|
+
*/
|
19079
|
+
|
19080
|
+
/*!
|
19081
|
+
* Module dependancies
|
19082
|
+
*/
|
19083
|
+
|
19084
|
+
var flag = require('./flag');
|
19085
|
+
|
19086
|
+
/**
|
19087
|
+
* # test(object, expression)
|
19088
|
+
*
|
19089
|
+
* Test and object for expression.
|
19090
|
+
*
|
19091
|
+
* @param {Object} object (constructed Assertion)
|
19092
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
19093
|
+
*/
|
19094
|
+
|
19095
|
+
module.exports = function (obj, args) {
|
19096
|
+
var negate = flag(obj, 'negate')
|
19097
|
+
, expr = args[0];
|
19098
|
+
return negate ? !expr : expr;
|
19099
|
+
};
|
19100
|
+
|
19101
|
+
});
|
19102
|
+
require.register("chaijs-chai/lib/chai/utils/transferFlags.js", function(exports, require, module){
|
19103
|
+
/*!
|
19104
|
+
* Chai - transferFlags utility
|
19105
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
19106
|
+
* MIT Licensed
|
19107
|
+
*/
|
19108
|
+
|
19109
|
+
/**
|
19110
|
+
* ### transferFlags(assertion, object, includeAll = true)
|
19111
|
+
*
|
19112
|
+
* Transfer all the flags for `assertion` to `object`. If
|
19113
|
+
* `includeAll` is set to `false`, then the base Chai
|
19114
|
+
* assertion flags (namely `object`, `ssfi`, and `message`)
|
19115
|
+
* will not be transferred.
|
19116
|
+
*
|
19117
|
+
*
|
19118
|
+
* var newAssertion = new Assertion();
|
19119
|
+
* utils.transferFlags(assertion, newAssertion);
|
19120
|
+
*
|
19121
|
+
* var anotherAsseriton = new Assertion(myObj);
|
19122
|
+
* utils.transferFlags(assertion, anotherAssertion, false);
|
19123
|
+
*
|
19124
|
+
* @param {Assertion} assertion the assertion to transfer the flags from
|
19125
|
+
* @param {Object} object the object to transfer the flags too; usually a new assertion
|
19126
|
+
* @param {Boolean} includeAll
|
19127
|
+
* @name getAllFlags
|
19128
|
+
* @api private
|
19129
|
+
*/
|
19130
|
+
|
19131
|
+
module.exports = function (assertion, object, includeAll) {
|
19132
|
+
var flags = assertion.__flags || (assertion.__flags = Object.create(null));
|
19133
|
+
|
19134
|
+
if (!object.__flags) {
|
19135
|
+
object.__flags = Object.create(null);
|
19136
|
+
}
|
19137
|
+
|
19138
|
+
includeAll = arguments.length === 3 ? includeAll : true;
|
19139
|
+
|
19140
|
+
for (var flag in flags) {
|
19141
|
+
if (includeAll ||
|
19142
|
+
(flag !== 'object' && flag !== 'ssfi' && flag != 'message')) {
|
19143
|
+
object.__flags[flag] = flags[flag];
|
19144
|
+
}
|
19145
|
+
}
|
19146
|
+
};
|
19147
|
+
|
19148
|
+
});
|
19149
|
+
require.register("chaijs-chai/lib/chai/utils/type.js", function(exports, require, module){
|
19150
|
+
/*!
|
19151
|
+
* Chai - type utility
|
19152
|
+
* Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
|
19153
|
+
* MIT Licensed
|
19154
|
+
*/
|
19155
|
+
|
19156
|
+
/*!
|
19157
|
+
* Detectable javascript natives
|
19158
|
+
*/
|
19159
|
+
|
19160
|
+
var natives = {
|
19161
|
+
'[object Arguments]': 'arguments'
|
19162
|
+
, '[object Array]': 'array'
|
19163
|
+
, '[object Date]': 'date'
|
19164
|
+
, '[object Function]': 'function'
|
19165
|
+
, '[object Number]': 'number'
|
19166
|
+
, '[object RegExp]': 'regexp'
|
19167
|
+
, '[object String]': 'string'
|
19168
|
+
};
|
19169
|
+
|
19170
|
+
/**
|
19171
|
+
* ### type(object)
|
19172
|
+
*
|
19173
|
+
* Better implementation of `typeof` detection that can
|
19174
|
+
* be used cross-browser. Handles the inconsistencies of
|
19175
|
+
* Array, `null`, and `undefined` detection.
|
19176
|
+
*
|
19177
|
+
* utils.type({}) // 'object'
|
19178
|
+
* utils.type(null) // `null'
|
19179
|
+
* utils.type(undefined) // `undefined`
|
19180
|
+
* utils.type([]) // `array`
|
19181
|
+
*
|
19182
|
+
* @param {Mixed} object to detect type of
|
19183
|
+
* @name type
|
19184
|
+
* @api private
|
19185
|
+
*/
|
19186
|
+
|
19187
|
+
module.exports = function (obj) {
|
19188
|
+
var str = Object.prototype.toString.call(obj);
|
19189
|
+
if (natives[str]) return natives[str];
|
19190
|
+
if (obj === null) return 'null';
|
19191
|
+
if (obj === undefined) return 'undefined';
|
19192
|
+
if (obj === Object(obj)) return 'object';
|
19193
|
+
return typeof obj;
|
19194
|
+
};
|
19195
|
+
|
15074
19196
|
});
|
15075
19197
|
require.register("indemma/index.js", function(exports, require, module){
|
15076
19198
|
module.exports = require('./lib/record');
|
@@ -22071,11 +26193,24 @@ model.rivets = function() {
|
|
22071
26193
|
};
|
22072
26194
|
|
22073
26195
|
});
|
26196
|
+
|
26197
|
+
|
26198
|
+
|
26199
|
+
|
26200
|
+
|
26201
|
+
|
26202
|
+
|
26203
|
+
|
26204
|
+
|
26205
|
+
|
26206
|
+
|
26207
|
+
|
26208
|
+
|
26209
|
+
|
22074
26210
|
require.alias("pluma-assimilate/dist/assimilate.js", "indemma/deps/assimilate/dist/assimilate.js");
|
22075
26211
|
require.alias("pluma-assimilate/dist/assimilate.js", "indemma/deps/assimilate/index.js");
|
22076
26212
|
require.alias("pluma-assimilate/dist/assimilate.js", "assimilate/index.js");
|
22077
26213
|
require.alias("pluma-assimilate/dist/assimilate.js", "pluma-assimilate/index.js");
|
22078
|
-
|
22079
26214
|
require.alias("component-type/index.js", "indemma/deps/type/index.js");
|
22080
26215
|
require.alias("component-type/index.js", "type/index.js");
|
22081
26216
|
|
@@ -22102,3 +26237,35 @@ require.alias("indefinido-advisable/lib/advisable.js", "indemma/deps/advisable/l
|
|
22102
26237
|
require.alias("indefinido-advisable/index.js", "advisable/index.js");
|
22103
26238
|
require.alias("component-jquery/index.js", "indefinido-advisable/deps/jquery/index.js");
|
22104
26239
|
|
26240
|
+
require.alias("chaijs-chai/index.js", "indemma/deps/chai/index.js");
|
26241
|
+
require.alias("chaijs-chai/lib/chai.js", "indemma/deps/chai/lib/chai.js");
|
26242
|
+
require.alias("chaijs-chai/lib/chai/assertion.js", "indemma/deps/chai/lib/chai/assertion.js");
|
26243
|
+
require.alias("chaijs-chai/lib/chai/core/assertions.js", "indemma/deps/chai/lib/chai/core/assertions.js");
|
26244
|
+
require.alias("chaijs-chai/lib/chai/interface/assert.js", "indemma/deps/chai/lib/chai/interface/assert.js");
|
26245
|
+
require.alias("chaijs-chai/lib/chai/interface/expect.js", "indemma/deps/chai/lib/chai/interface/expect.js");
|
26246
|
+
require.alias("chaijs-chai/lib/chai/interface/should.js", "indemma/deps/chai/lib/chai/interface/should.js");
|
26247
|
+
require.alias("chaijs-chai/lib/chai/utils/addChainableMethod.js", "indemma/deps/chai/lib/chai/utils/addChainableMethod.js");
|
26248
|
+
require.alias("chaijs-chai/lib/chai/utils/addMethod.js", "indemma/deps/chai/lib/chai/utils/addMethod.js");
|
26249
|
+
require.alias("chaijs-chai/lib/chai/utils/addProperty.js", "indemma/deps/chai/lib/chai/utils/addProperty.js");
|
26250
|
+
require.alias("chaijs-chai/lib/chai/utils/eql.js", "indemma/deps/chai/lib/chai/utils/eql.js");
|
26251
|
+
require.alias("chaijs-chai/lib/chai/utils/flag.js", "indemma/deps/chai/lib/chai/utils/flag.js");
|
26252
|
+
require.alias("chaijs-chai/lib/chai/utils/getActual.js", "indemma/deps/chai/lib/chai/utils/getActual.js");
|
26253
|
+
require.alias("chaijs-chai/lib/chai/utils/getEnumerableProperties.js", "indemma/deps/chai/lib/chai/utils/getEnumerableProperties.js");
|
26254
|
+
require.alias("chaijs-chai/lib/chai/utils/getMessage.js", "indemma/deps/chai/lib/chai/utils/getMessage.js");
|
26255
|
+
require.alias("chaijs-chai/lib/chai/utils/getName.js", "indemma/deps/chai/lib/chai/utils/getName.js");
|
26256
|
+
require.alias("chaijs-chai/lib/chai/utils/getPathValue.js", "indemma/deps/chai/lib/chai/utils/getPathValue.js");
|
26257
|
+
require.alias("chaijs-chai/lib/chai/utils/getProperties.js", "indemma/deps/chai/lib/chai/utils/getProperties.js");
|
26258
|
+
require.alias("chaijs-chai/lib/chai/utils/index.js", "indemma/deps/chai/lib/chai/utils/index.js");
|
26259
|
+
require.alias("chaijs-chai/lib/chai/utils/inspect.js", "indemma/deps/chai/lib/chai/utils/inspect.js");
|
26260
|
+
require.alias("chaijs-chai/lib/chai/utils/objDisplay.js", "indemma/deps/chai/lib/chai/utils/objDisplay.js");
|
26261
|
+
require.alias("chaijs-chai/lib/chai/utils/overwriteMethod.js", "indemma/deps/chai/lib/chai/utils/overwriteMethod.js");
|
26262
|
+
require.alias("chaijs-chai/lib/chai/utils/overwriteProperty.js", "indemma/deps/chai/lib/chai/utils/overwriteProperty.js");
|
26263
|
+
require.alias("chaijs-chai/lib/chai/utils/test.js", "indemma/deps/chai/lib/chai/utils/test.js");
|
26264
|
+
require.alias("chaijs-chai/lib/chai/utils/transferFlags.js", "indemma/deps/chai/lib/chai/utils/transferFlags.js");
|
26265
|
+
require.alias("chaijs-chai/lib/chai/utils/type.js", "indemma/deps/chai/lib/chai/utils/type.js");
|
26266
|
+
require.alias("chaijs-chai/index.js", "indemma/deps/chai/index.js");
|
26267
|
+
require.alias("chaijs-chai/index.js", "chai/index.js");
|
26268
|
+
require.alias("chaijs-assertion-error/index.js", "chaijs-chai/deps/assertion-error/index.js");
|
26269
|
+
require.alias("chaijs-assertion-error/index.js", "chaijs-chai/deps/assertion-error/index.js");
|
26270
|
+
require.alias("chaijs-assertion-error/index.js", "chaijs-assertion-error/index.js");
|
26271
|
+
require.alias("chaijs-chai/index.js", "chaijs-chai/index.js");
|