konacha 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +4 -0
- data/konacha.gemspec +1 -1
- data/vendor/assets/javascripts/chai.js +371 -231
- data/vendor/assets/javascripts/mocha.js +1 -1
- metadata +4 -4
data/History.md
CHANGED
data/konacha.gemspec
CHANGED
@@ -17,7 +17,7 @@ the asset pipeline and engines.}
|
|
17
17
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
gem.name = "konacha"
|
19
19
|
gem.require_paths = ["lib"]
|
20
|
-
gem.version = "1.2.
|
20
|
+
gem.version = "1.2.1"
|
21
21
|
|
22
22
|
gem.add_dependency "rails", "~> 3.1"
|
23
23
|
gem.add_dependency "capybara"
|
@@ -204,10 +204,10 @@ Object.defineProperty(Assertion.prototype, '_obj',
|
|
204
204
|
*
|
205
205
|
* Negates any of assertions following in the chain.
|
206
206
|
*
|
207
|
-
*
|
208
|
-
*
|
209
|
-
*
|
210
|
-
*
|
207
|
+
* expect(foo).to.not.equal('bar');
|
208
|
+
* expect(goodFn).to.not.throw(Error);
|
209
|
+
* expect({ foo: 'baz' }).to.have.property('foo')
|
210
|
+
* .and.not.equal('bar');
|
211
211
|
*
|
212
212
|
* @name not
|
213
213
|
* @api public
|
@@ -221,16 +221,40 @@ Object.defineProperty(Assertion.prototype, 'not',
|
|
221
221
|
, configurable: true
|
222
222
|
});
|
223
223
|
|
224
|
+
/**
|
225
|
+
* ### .deep
|
226
|
+
*
|
227
|
+
* Sets the `deep` flag, later used by the `equal` and
|
228
|
+
* `property` assertions.
|
229
|
+
*
|
230
|
+
* expect(foo).to.deep.equal({ bar: 'baz' });
|
231
|
+
* expect({ foo: { bar: { baz: 'quux' } } })
|
232
|
+
* .to.have.deep.property('foo.bar.baz', 'quux');
|
233
|
+
*
|
234
|
+
* @name deep
|
235
|
+
* @api public
|
236
|
+
*/
|
237
|
+
|
238
|
+
Object.defineProperty(Assertion.prototype, 'deep',
|
239
|
+
{ get: function () {
|
240
|
+
flag(this, 'deep', true);
|
241
|
+
return this;
|
242
|
+
}
|
243
|
+
, configurable: true
|
244
|
+
});
|
245
|
+
|
224
246
|
/**
|
225
247
|
* ### .a(type)
|
226
248
|
*
|
227
249
|
* The `a` and `an` assertions are aliases that can be
|
228
|
-
* used either as
|
229
|
-
*
|
250
|
+
* used either as language chains or to assert a value's
|
251
|
+
* type (as revealed by `Object.prototype.toString`).
|
230
252
|
*
|
231
253
|
* // typeof
|
232
254
|
* expect('test').to.be.a('string');
|
233
255
|
* expect({ foo: 'bar' }).to.be.an('object');
|
256
|
+
* expect(null).to.be.a('null');
|
257
|
+
* expect(undefined).to.be.an('undefined');
|
234
258
|
*
|
235
259
|
* // language chain
|
236
260
|
* expect(foo).to.be.an.instanceof(Foo);
|
@@ -244,12 +268,14 @@ Object.defineProperty(Assertion.prototype, 'not',
|
|
244
268
|
var an = function () {
|
245
269
|
var assert = function(type) {
|
246
270
|
var obj = flag(this, 'object')
|
247
|
-
,
|
271
|
+
, klassStart = type.charAt(0).toUpperCase()
|
272
|
+
, klass = klassStart + type.slice(1)
|
273
|
+
, article = ~[ 'A', 'E', 'I', 'O', 'U' ].indexOf(klassStart) ? 'an ' : 'a ';
|
248
274
|
|
249
275
|
this.assert(
|
250
276
|
'[object ' + klass + ']' === toString.call(obj)
|
251
|
-
, 'expected #{this} to be
|
252
|
-
, 'expected #{this} not to be
|
277
|
+
, 'expected #{this} to be ' + article + type
|
278
|
+
, 'expected #{this} not to be ' + article + type
|
253
279
|
, '[object ' + klass + ']'
|
254
280
|
, toString.call(obj)
|
255
281
|
);
|
@@ -274,10 +300,10 @@ Object.defineProperty(Assertion.prototype, 'a',
|
|
274
300
|
/**
|
275
301
|
* ### .include(value)
|
276
302
|
*
|
277
|
-
* The `include` and `contain` assertions can be used as either
|
278
|
-
* based language
|
279
|
-
* in an
|
280
|
-
*
|
303
|
+
* The `include` and `contain` assertions can be used as either property
|
304
|
+
* based language chains or as methods to assert the inclusion of an object
|
305
|
+
* in an array or a substring in a string. When used as language chains,
|
306
|
+
* they toggle the `contain` flag for the `keys` assertion.
|
281
307
|
*
|
282
308
|
* expect([1,2,3]).to.include(2);
|
283
309
|
* expect('foobar').to.contain('foo');
|
@@ -319,7 +345,7 @@ Object.defineProperty(Assertion.prototype, 'include',
|
|
319
345
|
/**
|
320
346
|
* ### .ok
|
321
347
|
*
|
322
|
-
*
|
348
|
+
* Asserts that the target is truthy.
|
323
349
|
*
|
324
350
|
* expect('everthing').to.be.ok;
|
325
351
|
* expect(1).to.be.ok;
|
@@ -346,7 +372,7 @@ Object.defineProperty(Assertion.prototype, 'ok',
|
|
346
372
|
/**
|
347
373
|
* ### .true
|
348
374
|
*
|
349
|
-
*
|
375
|
+
* Asserts that the target is `true`.
|
350
376
|
*
|
351
377
|
* expect(true).to.be.true;
|
352
378
|
* expect(1).to.not.be.true;
|
@@ -372,7 +398,7 @@ Object.defineProperty(Assertion.prototype, 'true',
|
|
372
398
|
/**
|
373
399
|
* ### .false
|
374
400
|
*
|
375
|
-
*
|
401
|
+
* Asserts that the target is `false`.
|
376
402
|
*
|
377
403
|
* expect(false).to.be.false;
|
378
404
|
* expect(0).to.not.be.false;
|
@@ -398,7 +424,7 @@ Object.defineProperty(Assertion.prototype, 'false',
|
|
398
424
|
/**
|
399
425
|
* ### .null
|
400
426
|
*
|
401
|
-
*
|
427
|
+
* Asserts that the target is `null`.
|
402
428
|
*
|
403
429
|
* expect(null).to.be.null;
|
404
430
|
* expect(undefined).not.to.be.null;
|
@@ -424,7 +450,7 @@ Object.defineProperty(Assertion.prototype, 'null',
|
|
424
450
|
/**
|
425
451
|
* ### .undefined
|
426
452
|
*
|
427
|
-
*
|
453
|
+
* Asserts that the target is `undefined`.
|
428
454
|
*
|
429
455
|
* expect(undefined).to.be.undefined;
|
430
456
|
* expect(null).to.not.be.undefined;
|
@@ -450,13 +476,15 @@ Object.defineProperty(Assertion.prototype, 'undefined',
|
|
450
476
|
/**
|
451
477
|
* ### .exist
|
452
478
|
*
|
453
|
-
*
|
479
|
+
* Asserts that the target is neither `null` nor `undefined`.
|
454
480
|
*
|
455
481
|
* var foo = 'hi'
|
456
|
-
* , bar
|
482
|
+
* , bar = null
|
483
|
+
* , baz;
|
457
484
|
*
|
458
485
|
* expect(foo).to.exist;
|
459
486
|
* expect(bar).to.not.exist;
|
487
|
+
* expect(baz).to.not.exist;
|
460
488
|
*
|
461
489
|
* @name exist
|
462
490
|
* @api public
|
@@ -478,8 +506,8 @@ Object.defineProperty(Assertion.prototype, 'exist',
|
|
478
506
|
/**
|
479
507
|
* ### .empty
|
480
508
|
*
|
481
|
-
*
|
482
|
-
* the length property. For objects it gets the count of
|
509
|
+
* Asserts that the target's length is `0`. For arrays, it checks
|
510
|
+
* the `length` property. For objects, it gets the count of
|
483
511
|
* enumerable keys.
|
484
512
|
*
|
485
513
|
* expect([]).to.be.empty;
|
@@ -514,7 +542,7 @@ Object.defineProperty(Assertion.prototype, 'empty',
|
|
514
542
|
/**
|
515
543
|
* ### .arguments
|
516
544
|
*
|
517
|
-
*
|
545
|
+
* Asserts that the target is an arguments object.
|
518
546
|
*
|
519
547
|
* function test () {
|
520
548
|
* expect(arguments).to.be.arguments;
|
@@ -543,11 +571,15 @@ Object.defineProperty(Assertion.prototype, 'arguments',
|
|
543
571
|
/**
|
544
572
|
* ### .equal(value)
|
545
573
|
*
|
546
|
-
*
|
574
|
+
* Asserts that the target is strictly equal (`===`) to `value`.
|
575
|
+
* Alternately, if the `deep` flag is set, asserts that
|
576
|
+
* the target is deeply equal to `value`.
|
547
577
|
*
|
548
578
|
* expect('hello').to.equal('hello');
|
549
579
|
* expect(42).to.equal(42);
|
550
580
|
* expect(1).to.not.equal(true);
|
581
|
+
* expect({ foo: 'bar' }).to.not.equal({ foo: 'bar' });
|
582
|
+
* expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
|
551
583
|
*
|
552
584
|
* @name equal
|
553
585
|
* @param {Mixed} value
|
@@ -555,11 +587,16 @@ Object.defineProperty(Assertion.prototype, 'arguments',
|
|
555
587
|
*/
|
556
588
|
|
557
589
|
Assertion.prototype.equal = function (val) {
|
558
|
-
this
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
590
|
+
var obj = flag(this, 'object');
|
591
|
+
if (flag(this, 'deep')) {
|
592
|
+
new Assertion(obj).to.eql(val);
|
593
|
+
} else {
|
594
|
+
this.assert(
|
595
|
+
val === obj
|
596
|
+
, 'expected #{this} to equal #{exp}'
|
597
|
+
, 'expected #{this} to not equal #{exp}'
|
598
|
+
, val);
|
599
|
+
}
|
563
600
|
|
564
601
|
return this;
|
565
602
|
};
|
@@ -567,13 +604,13 @@ Assertion.prototype.equal = function (val) {
|
|
567
604
|
/**
|
568
605
|
* ### .eql(value)
|
569
606
|
*
|
570
|
-
*
|
607
|
+
* Asserts that the target is deeply equal to `value`.
|
571
608
|
*
|
572
609
|
* expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
|
573
610
|
* expect([ 1, 2, 3 ]).to.eql([ 1, 2, 3 ]);
|
574
611
|
*
|
575
612
|
* @name eql
|
576
|
-
* @param {
|
613
|
+
* @param {Mixed} value
|
577
614
|
* @api public
|
578
615
|
*/
|
579
616
|
|
@@ -590,7 +627,7 @@ Assertion.prototype.eql = function (obj) {
|
|
590
627
|
/**
|
591
628
|
* ### .above(value)
|
592
629
|
*
|
593
|
-
*
|
630
|
+
* Asserts that the target is greater than `value`.
|
594
631
|
*
|
595
632
|
* expect(10).to.be.above(5);
|
596
633
|
*
|
@@ -612,7 +649,7 @@ Assertion.prototype.above = function (val) {
|
|
612
649
|
/**
|
613
650
|
* ### .below(value)
|
614
651
|
*
|
615
|
-
*
|
652
|
+
* Asserts that the target is less than `value`.
|
616
653
|
*
|
617
654
|
* expect(5).to.be.below(10);
|
618
655
|
*
|
@@ -634,7 +671,7 @@ Assertion.prototype.below = function (val) {
|
|
634
671
|
/**
|
635
672
|
* ### .within(start, finish)
|
636
673
|
*
|
637
|
-
*
|
674
|
+
* Asserts that the target is within a range.
|
638
675
|
*
|
639
676
|
* expect(7).to.be.within(5,10);
|
640
677
|
*
|
@@ -659,7 +696,7 @@ Assertion.prototype.within = function (start, finish) {
|
|
659
696
|
/**
|
660
697
|
* ### .instanceof(constructor)
|
661
698
|
*
|
662
|
-
*
|
699
|
+
* Asserts that the target is an instance of `constructor`.
|
663
700
|
*
|
664
701
|
* var Tea = function (name) { this.name = name; }
|
665
702
|
* , Chai = new Tea('chai');
|
@@ -668,7 +705,7 @@ Assertion.prototype.within = function (start, finish) {
|
|
668
705
|
* expect([ 1, 2, 3 ]).to.be.instanceof(Array);
|
669
706
|
*
|
670
707
|
* @name instanceof
|
671
|
-
* @param {Constructor}
|
708
|
+
* @param {Constructor} constructor
|
672
709
|
* @alias instanceOf
|
673
710
|
* @api public
|
674
711
|
*/
|
@@ -686,11 +723,13 @@ Assertion.prototype.instanceOf = function (constructor) {
|
|
686
723
|
/**
|
687
724
|
* ### .property(name, [value])
|
688
725
|
*
|
689
|
-
*
|
690
|
-
*
|
726
|
+
* Asserts that the target has a property `name`, optionally asserting that
|
727
|
+
* the value of that property is strictly equal to `value`.
|
728
|
+
* If the `deep` flag is set, you can use dot- and bracket-notation for deep
|
729
|
+
* references into objects and arrays.
|
691
730
|
*
|
692
|
-
* //
|
693
|
-
* var obj = { foo: 'bar' }
|
731
|
+
* // simple referencing
|
732
|
+
* var obj = { foo: 'bar' };
|
694
733
|
* expect(obj).to.have.property('foo');
|
695
734
|
* expect(obj).to.have.property('foo', 'bar');
|
696
735
|
* expect(obj).to.have.property('foo').to.be.a('string');
|
@@ -701,9 +740,9 @@ Assertion.prototype.instanceOf = function (constructor) {
|
|
701
740
|
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
|
702
741
|
* };
|
703
742
|
|
704
|
-
* expect(deepObj).to.have.property('green.tea', 'matcha');
|
705
|
-
* expect(deepObj).to.have.property('teas[1]', 'matcha');
|
706
|
-
* expect(deepObj).to.have.property('teas[2].tea', 'konacha');
|
743
|
+
* expect(deepObj).to.have.deep.property('green.tea', 'matcha');
|
744
|
+
* expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
|
745
|
+
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
|
707
746
|
*
|
708
747
|
* @name property
|
709
748
|
* @param {String} name
|
@@ -714,25 +753,26 @@ Assertion.prototype.instanceOf = function (constructor) {
|
|
714
753
|
|
715
754
|
Assertion.prototype.property = function (name, val) {
|
716
755
|
var obj = flag(this, 'object')
|
717
|
-
, value = util.getPathValue(name, obj)
|
756
|
+
, value = flag(this, 'deep') ? util.getPathValue(name, obj) : obj[name]
|
757
|
+
, descriptor = flag(this, 'deep') ? 'deep property ' : 'property '
|
718
758
|
, negate = flag(this, 'negate');
|
719
759
|
|
720
760
|
if (negate && undefined !== val) {
|
721
761
|
if (undefined === value) {
|
722
|
-
throw new Error(util.inspect(obj) + ' has no
|
762
|
+
throw new Error(util.inspect(obj) + ' has no ' + descriptor + util.inspect(name));
|
723
763
|
}
|
724
764
|
} else {
|
725
765
|
this.assert(
|
726
766
|
undefined !== value
|
727
|
-
, 'expected #{this} to have a
|
728
|
-
, 'expected #{this} to not have
|
767
|
+
, 'expected #{this} to have a ' + descriptor + util.inspect(name)
|
768
|
+
, 'expected #{this} to not have ' + descriptor + util.inspect(name));
|
729
769
|
}
|
730
770
|
|
731
771
|
if (undefined !== val) {
|
732
772
|
this.assert(
|
733
773
|
val === value
|
734
|
-
, 'expected #{this} to have a
|
735
|
-
, 'expected #{this} to not have a
|
774
|
+
, 'expected #{this} to have a ' + descriptor + util.inspect(name) + ' of #{exp}, but got #{act}'
|
775
|
+
, 'expected #{this} to not have a ' + descriptor + util.inspect(name) + ' of #{act}'
|
736
776
|
, val
|
737
777
|
, value
|
738
778
|
);
|
@@ -745,7 +785,7 @@ Assertion.prototype.property = function (name, val) {
|
|
745
785
|
/**
|
746
786
|
* ### .ownProperty(name)
|
747
787
|
*
|
748
|
-
*
|
788
|
+
* Asserts that the target has an own property `name`.
|
749
789
|
*
|
750
790
|
* expect('test').to.have.ownProperty('length');
|
751
791
|
*
|
@@ -765,9 +805,9 @@ Assertion.prototype.ownProperty = function (name) {
|
|
765
805
|
};
|
766
806
|
|
767
807
|
/**
|
768
|
-
* ### .length(
|
808
|
+
* ### .length(value)
|
769
809
|
*
|
770
|
-
*
|
810
|
+
* Asserts that the target's `length` property has the expected value.
|
771
811
|
*
|
772
812
|
* expect([1,2,3]).to.have.length(3);
|
773
813
|
* expect('foobar').to.have.length(6);
|
@@ -797,7 +837,7 @@ Assertion.prototype.length = function (n) {
|
|
797
837
|
/**
|
798
838
|
* ### .match(regexp)
|
799
839
|
*
|
800
|
-
*
|
840
|
+
* Asserts that the target matches a regular expression.
|
801
841
|
*
|
802
842
|
* expect('foobar').to.match(/^foo/);
|
803
843
|
*
|
@@ -820,7 +860,7 @@ Assertion.prototype.match = function (re) {
|
|
820
860
|
/**
|
821
861
|
* ### .string(string)
|
822
862
|
*
|
823
|
-
*
|
863
|
+
* Asserts that the string target contains another string.
|
824
864
|
*
|
825
865
|
* expect('foobar').to.have.string('bar');
|
826
866
|
*
|
@@ -844,15 +884,16 @@ Assertion.prototype.string = function (str) {
|
|
844
884
|
/**
|
845
885
|
* ### .keys(key1, [key2], [...])
|
846
886
|
*
|
847
|
-
*
|
848
|
-
*
|
887
|
+
* Asserts that the target has exactly the given keys, or
|
888
|
+
* asserts the inclusion of some keys when using the
|
889
|
+
* `include` or `contain` modifiers.
|
849
890
|
*
|
850
891
|
* expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);
|
851
892
|
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');
|
852
893
|
*
|
853
894
|
* @name keys
|
854
895
|
* @alias key
|
855
|
-
* @param {String
|
896
|
+
* @param {String...|Array} keys
|
856
897
|
* @api public
|
857
898
|
*/
|
858
899
|
|
@@ -912,7 +953,7 @@ Assertion.prototype.keys = function(keys) {
|
|
912
953
|
/**
|
913
954
|
* ### .throw(constructor)
|
914
955
|
*
|
915
|
-
*
|
956
|
+
* Asserts that the function target will throw a specific error, or specific type of error
|
916
957
|
* (as determined using `instanceof`), optionally with a RegExp or string inclusion test
|
917
958
|
* for the error's message.
|
918
959
|
*
|
@@ -1021,7 +1062,7 @@ Assertion.prototype.Throw = function (constructor, msg) {
|
|
1021
1062
|
/**
|
1022
1063
|
* ### .respondTo(method)
|
1023
1064
|
*
|
1024
|
-
*
|
1065
|
+
* Asserts that the object or class target will respond to a method.
|
1025
1066
|
*
|
1026
1067
|
* expect(Klass).to.respondTo('bar');
|
1027
1068
|
* expect(obj).to.respondTo('bar');
|
@@ -1051,7 +1092,7 @@ Assertion.prototype.respondTo = function (method) {
|
|
1051
1092
|
/**
|
1052
1093
|
* ### .satisfy(method)
|
1053
1094
|
*
|
1054
|
-
*
|
1095
|
+
* Asserts that the target passes a given truth test.
|
1055
1096
|
*
|
1056
1097
|
* expect(1).to.satisfy(function(num) { return num > 0; });
|
1057
1098
|
*
|
@@ -1076,7 +1117,7 @@ Assertion.prototype.satisfy = function (matcher) {
|
|
1076
1117
|
/**
|
1077
1118
|
* ### .closeTo(expected, delta)
|
1078
1119
|
*
|
1079
|
-
*
|
1120
|
+
* Asserts that the target is equal `expected`, to within a +/- `delta` range.
|
1080
1121
|
*
|
1081
1122
|
* expect(1.5).to.be.closeTo(1, 0.5);
|
1082
1123
|
*
|
@@ -1164,7 +1205,7 @@ var used = []
|
|
1164
1205
|
* Chai version
|
1165
1206
|
*/
|
1166
1207
|
|
1167
|
-
exports.version = '1.0.
|
1208
|
+
exports.version = '1.0.1';
|
1168
1209
|
|
1169
1210
|
/*!
|
1170
1211
|
* Primary `Assertion` prototype
|
@@ -1248,11 +1289,14 @@ module.exports = function (chai, util) {
|
|
1248
1289
|
*/
|
1249
1290
|
|
1250
1291
|
/**
|
1251
|
-
* ### assert(
|
1292
|
+
* ### assert(expression, message)
|
1252
1293
|
*
|
1253
1294
|
* Write your own test expressions.
|
1254
1295
|
*
|
1255
|
-
*
|
1296
|
+
* assert('foo' !== 'bar', 'foo is not bar');
|
1297
|
+
* assert(Array.isArray([]), 'empty arrays are arrays');
|
1298
|
+
*
|
1299
|
+
* @param {Mixed} expression to test for truthiness
|
1256
1300
|
* @param {String} message to display on error
|
1257
1301
|
* @name assert
|
1258
1302
|
* @api public
|
@@ -1268,13 +1312,13 @@ module.exports = function (chai, util) {
|
|
1268
1312
|
};
|
1269
1313
|
|
1270
1314
|
/**
|
1271
|
-
* ### .fail(actual,
|
1315
|
+
* ### .fail(actual, expected, [message], [operator])
|
1272
1316
|
*
|
1273
|
-
* Throw a failure. Node.js compatible.
|
1317
|
+
* Throw a failure. Node.js `assert` module-compatible.
|
1274
1318
|
*
|
1275
1319
|
* @name fail
|
1276
|
-
* @param {
|
1277
|
-
* @param {
|
1320
|
+
* @param {Mixed} actual
|
1321
|
+
* @param {Mixed} expected
|
1278
1322
|
* @param {String} message
|
1279
1323
|
* @param {String} operator
|
1280
1324
|
* @api public
|
@@ -1293,13 +1337,13 @@ module.exports = function (chai, util) {
|
|
1293
1337
|
/**
|
1294
1338
|
* ### .ok(object, [message])
|
1295
1339
|
*
|
1296
|
-
*
|
1340
|
+
* Asserts that `object` is truthy.
|
1297
1341
|
*
|
1298
|
-
*
|
1299
|
-
*
|
1342
|
+
* assert.ok('everything', 'everything is ok');
|
1343
|
+
* assert.ok(false, 'this will fail');
|
1300
1344
|
*
|
1301
1345
|
* @name ok
|
1302
|
-
* @param {
|
1346
|
+
* @param {Mixed} object to test
|
1303
1347
|
* @param {String} message
|
1304
1348
|
* @api public
|
1305
1349
|
*/
|
@@ -1311,13 +1355,13 @@ module.exports = function (chai, util) {
|
|
1311
1355
|
/**
|
1312
1356
|
* ### .equal(actual, expected, [message])
|
1313
1357
|
*
|
1314
|
-
*
|
1358
|
+
* Asserts non-strict equality (`==`) of `actual` and `expected`.
|
1315
1359
|
*
|
1316
|
-
*
|
1360
|
+
* assert.equal(3, '3', '== coerces values to strings');
|
1317
1361
|
*
|
1318
1362
|
* @name equal
|
1319
|
-
* @param {
|
1320
|
-
* @param {
|
1363
|
+
* @param {Mixed} actual
|
1364
|
+
* @param {Mixed} expected
|
1321
1365
|
* @param {String} message
|
1322
1366
|
* @api public
|
1323
1367
|
*/
|
@@ -1337,13 +1381,13 @@ module.exports = function (chai, util) {
|
|
1337
1381
|
/**
|
1338
1382
|
* ### .notEqual(actual, expected, [message])
|
1339
1383
|
*
|
1340
|
-
*
|
1384
|
+
* Asserts non-strict inequality (`!=`) of `actual` and `expected`.
|
1341
1385
|
*
|
1342
|
-
*
|
1386
|
+
* assert.notEqual(3, 4, 'these numbers are not equal');
|
1343
1387
|
*
|
1344
1388
|
* @name notEqual
|
1345
|
-
* @param {
|
1346
|
-
* @param {
|
1389
|
+
* @param {Mixed} actual
|
1390
|
+
* @param {Mixed} expected
|
1347
1391
|
* @param {String} message
|
1348
1392
|
* @api public
|
1349
1393
|
*/
|
@@ -1363,13 +1407,13 @@ module.exports = function (chai, util) {
|
|
1363
1407
|
/**
|
1364
1408
|
* ### .strictEqual(actual, expected, [message])
|
1365
1409
|
*
|
1366
|
-
*
|
1410
|
+
* Asserts strict equality (`===`) of `actual` and `expected`.
|
1367
1411
|
*
|
1368
|
-
*
|
1412
|
+
* assert.strictEqual(true, true, 'these booleans are strictly equal');
|
1369
1413
|
*
|
1370
1414
|
* @name strictEqual
|
1371
|
-
* @param {
|
1372
|
-
* @param {
|
1415
|
+
* @param {Mixed} actual
|
1416
|
+
* @param {Mixed} expected
|
1373
1417
|
* @param {String} message
|
1374
1418
|
* @api public
|
1375
1419
|
*/
|
@@ -1381,13 +1425,13 @@ module.exports = function (chai, util) {
|
|
1381
1425
|
/**
|
1382
1426
|
* ### .notStrictEqual(actual, expected, [message])
|
1383
1427
|
*
|
1384
|
-
*
|
1428
|
+
* Asserts strict inequality (`!==`) of `actual` and `expected`.
|
1385
1429
|
*
|
1386
|
-
*
|
1430
|
+
* assert.notStrictEqual(3, '3', 'no coercion for strict equality');
|
1387
1431
|
*
|
1388
1432
|
* @name notStrictEqual
|
1389
|
-
* @param {
|
1390
|
-
* @param {
|
1433
|
+
* @param {Mixed} actual
|
1434
|
+
* @param {Mixed} expected
|
1391
1435
|
* @param {String} message
|
1392
1436
|
* @api public
|
1393
1437
|
*/
|
@@ -1399,13 +1443,13 @@ module.exports = function (chai, util) {
|
|
1399
1443
|
/**
|
1400
1444
|
* ### .deepEqual(actual, expected, [message])
|
1401
1445
|
*
|
1402
|
-
*
|
1446
|
+
* Asserts that `actual` is deeply equal to `expected`.
|
1403
1447
|
*
|
1404
|
-
*
|
1448
|
+
* assert.deepEqual({ tea: 'green' }, { tea: 'green' });
|
1405
1449
|
*
|
1406
1450
|
* @name deepEqual
|
1407
|
-
* @param {
|
1408
|
-
* @param {
|
1451
|
+
* @param {Mixed} actual
|
1452
|
+
* @param {Mixed} expected
|
1409
1453
|
* @param {String} message
|
1410
1454
|
* @api public
|
1411
1455
|
*/
|
@@ -1417,13 +1461,13 @@ module.exports = function (chai, util) {
|
|
1417
1461
|
/**
|
1418
1462
|
* ### .notDeepEqual(actual, expected, [message])
|
1419
1463
|
*
|
1420
|
-
* Assert not
|
1464
|
+
* Assert that `actual` is not deeply equal to `expected`.
|
1421
1465
|
*
|
1422
|
-
*
|
1466
|
+
* assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });
|
1423
1467
|
*
|
1424
1468
|
* @name notDeepEqual
|
1425
|
-
* @param {
|
1426
|
-
* @param {
|
1469
|
+
* @param {Mixed} actual
|
1470
|
+
* @param {Mixed} expected
|
1427
1471
|
* @param {String} message
|
1428
1472
|
* @api public
|
1429
1473
|
*/
|
@@ -1435,13 +1479,13 @@ module.exports = function (chai, util) {
|
|
1435
1479
|
/**
|
1436
1480
|
* ### .isTrue(value, [message])
|
1437
1481
|
*
|
1438
|
-
*
|
1482
|
+
* Asserts that `value` is true.
|
1439
1483
|
*
|
1440
|
-
*
|
1441
|
-
*
|
1484
|
+
* var teaServed = true;
|
1485
|
+
* assert.isTrue(teaServed, 'the tea has been served');
|
1442
1486
|
*
|
1443
1487
|
* @name isTrue
|
1444
|
-
* @param {
|
1488
|
+
* @param {Mixed} value
|
1445
1489
|
* @param {String} message
|
1446
1490
|
* @api public
|
1447
1491
|
*/
|
@@ -1453,13 +1497,13 @@ module.exports = function (chai, util) {
|
|
1453
1497
|
/**
|
1454
1498
|
* ### .isFalse(value, [message])
|
1455
1499
|
*
|
1456
|
-
*
|
1500
|
+
* Asserts that `value` is false.
|
1457
1501
|
*
|
1458
|
-
*
|
1459
|
-
*
|
1502
|
+
* var teaServed = false;
|
1503
|
+
* assert.isFalse(teaServed, 'no tea yet? hmm...');
|
1460
1504
|
*
|
1461
1505
|
* @name isFalse
|
1462
|
-
* @param {
|
1506
|
+
* @param {Mixed} value
|
1463
1507
|
* @param {String} message
|
1464
1508
|
* @api public
|
1465
1509
|
*/
|
@@ -1471,12 +1515,12 @@ module.exports = function (chai, util) {
|
|
1471
1515
|
/**
|
1472
1516
|
* ### .isNull(value, [message])
|
1473
1517
|
*
|
1474
|
-
*
|
1518
|
+
* Asserts that `value` is null.
|
1475
1519
|
*
|
1476
|
-
*
|
1520
|
+
* assert.isNull(err, 'there was no error');
|
1477
1521
|
*
|
1478
1522
|
* @name isNull
|
1479
|
-
* @param {
|
1523
|
+
* @param {Mixed} value
|
1480
1524
|
* @param {String} message
|
1481
1525
|
* @api public
|
1482
1526
|
*/
|
@@ -1488,13 +1532,13 @@ module.exports = function (chai, util) {
|
|
1488
1532
|
/**
|
1489
1533
|
* ### .isNotNull(value, [message])
|
1490
1534
|
*
|
1491
|
-
*
|
1535
|
+
* Asserts that `value` is not null.
|
1492
1536
|
*
|
1493
|
-
*
|
1494
|
-
*
|
1537
|
+
* var tea = 'tasty chai';
|
1538
|
+
* assert.isNotNull(tea, 'great, time for tea!');
|
1495
1539
|
*
|
1496
1540
|
* @name isNotNull
|
1497
|
-
* @param {
|
1541
|
+
* @param {Mixed} value
|
1498
1542
|
* @param {String} message
|
1499
1543
|
* @api public
|
1500
1544
|
*/
|
@@ -1506,12 +1550,13 @@ module.exports = function (chai, util) {
|
|
1506
1550
|
/**
|
1507
1551
|
* ### .isUndefined(value, [message])
|
1508
1552
|
*
|
1509
|
-
*
|
1553
|
+
* Asserts that `value` is `undefined`.
|
1510
1554
|
*
|
1511
|
-
*
|
1555
|
+
* var tea;
|
1556
|
+
* assert.isUndefined(tea, 'no tea defined');
|
1512
1557
|
*
|
1513
1558
|
* @name isUndefined
|
1514
|
-
* @param {
|
1559
|
+
* @param {Mixed} value
|
1515
1560
|
* @param {String} message
|
1516
1561
|
* @api public
|
1517
1562
|
*/
|
@@ -1523,13 +1568,13 @@ module.exports = function (chai, util) {
|
|
1523
1568
|
/**
|
1524
1569
|
* ### .isDefined(value, [message])
|
1525
1570
|
*
|
1526
|
-
*
|
1571
|
+
* Asserts that `value` is not `undefined`.
|
1527
1572
|
*
|
1528
|
-
*
|
1529
|
-
*
|
1573
|
+
* var tea = 'cup of chai';
|
1574
|
+
* assert.isDefined(tea, 'tea has been defined');
|
1530
1575
|
*
|
1531
1576
|
* @name isUndefined
|
1532
|
-
* @param {
|
1577
|
+
* @param {Mixed} value
|
1533
1578
|
* @param {String} message
|
1534
1579
|
* @api public
|
1535
1580
|
*/
|
@@ -1541,13 +1586,13 @@ module.exports = function (chai, util) {
|
|
1541
1586
|
/**
|
1542
1587
|
* ### .isFunction(value, [message])
|
1543
1588
|
*
|
1544
|
-
*
|
1589
|
+
* Asserts that `value` is a function.
|
1545
1590
|
*
|
1546
|
-
*
|
1547
|
-
*
|
1591
|
+
* function serveTea() { return 'cup of tea'; };
|
1592
|
+
* assert.isFunction(serveTea, 'great, we can have tea now');
|
1548
1593
|
*
|
1549
1594
|
* @name isFunction
|
1550
|
-
* @param {
|
1595
|
+
* @param {Mixed} value
|
1551
1596
|
* @param {String} message
|
1552
1597
|
* @api public
|
1553
1598
|
*/
|
@@ -1559,10 +1604,10 @@ module.exports = function (chai, util) {
|
|
1559
1604
|
/**
|
1560
1605
|
* ### .isNotFunction(value, [message])
|
1561
1606
|
*
|
1562
|
-
*
|
1607
|
+
* Asserts that `value` is _not_ a function.
|
1563
1608
|
*
|
1564
|
-
*
|
1565
|
-
*
|
1609
|
+
* var serveTea = [ 'heat', 'pour', 'sip' ];
|
1610
|
+
* assert.isNotFunction(serveTea, 'great, we have listed the steps');
|
1566
1611
|
*
|
1567
1612
|
* @name isNotFunction
|
1568
1613
|
* @param {Mixed} value
|
@@ -1577,13 +1622,14 @@ module.exports = function (chai, util) {
|
|
1577
1622
|
/**
|
1578
1623
|
* ### .isObject(value, [message])
|
1579
1624
|
*
|
1580
|
-
*
|
1625
|
+
* Asserts that `value` is an object (as revealed by
|
1626
|
+
* `Object.prototype.toString`).
|
1581
1627
|
*
|
1582
|
-
*
|
1583
|
-
*
|
1628
|
+
* var selection = { name: 'Chai', serve: 'with spices' };
|
1629
|
+
* assert.isObject(selection, 'tea selection is an object');
|
1584
1630
|
*
|
1585
1631
|
* @name isObject
|
1586
|
-
* @param {
|
1632
|
+
* @param {Mixed} value
|
1587
1633
|
* @param {String} message
|
1588
1634
|
* @api public
|
1589
1635
|
*/
|
@@ -1595,10 +1641,11 @@ module.exports = function (chai, util) {
|
|
1595
1641
|
/**
|
1596
1642
|
* ### .isNotObject(value, [message])
|
1597
1643
|
*
|
1598
|
-
*
|
1644
|
+
* Asserts that `value` is _not_ an object.
|
1599
1645
|
*
|
1600
|
-
*
|
1601
|
-
*
|
1646
|
+
* var selection = 'chai'
|
1647
|
+
* assert.isObject(selection, 'tea selection is not an object');
|
1648
|
+
* assert.isObject(null, 'null is not an object');
|
1602
1649
|
*
|
1603
1650
|
* @name isNotObject
|
1604
1651
|
* @param {Mixed} value
|
@@ -1613,10 +1660,10 @@ module.exports = function (chai, util) {
|
|
1613
1660
|
/**
|
1614
1661
|
* ### .isArray(value, [message])
|
1615
1662
|
*
|
1616
|
-
*
|
1663
|
+
* Asserts that `value` is an array.
|
1617
1664
|
*
|
1618
|
-
*
|
1619
|
-
*
|
1665
|
+
* var menu = [ 'green', 'chai', 'oolong' ];
|
1666
|
+
* assert.isArray(menu, 'what kind of tea do we want?');
|
1620
1667
|
*
|
1621
1668
|
* @name isArray
|
1622
1669
|
* @param {Mixed} value
|
@@ -1625,16 +1672,16 @@ module.exports = function (chai, util) {
|
|
1625
1672
|
*/
|
1626
1673
|
|
1627
1674
|
assert.isArray = function (val, msg) {
|
1628
|
-
new Assertion(val, msg).to.be.
|
1675
|
+
new Assertion(val, msg).to.be.an('array');
|
1629
1676
|
};
|
1630
1677
|
|
1631
1678
|
/**
|
1632
|
-
* ### .
|
1679
|
+
* ### .isNotArray(value, [message])
|
1633
1680
|
*
|
1634
|
-
*
|
1681
|
+
* Asserts that `value` is _not_ an array.
|
1635
1682
|
*
|
1636
|
-
*
|
1637
|
-
*
|
1683
|
+
* var menu = 'green|chai|oolong';
|
1684
|
+
* assert.isNotArray(menu, 'what kind of tea do we want?');
|
1638
1685
|
*
|
1639
1686
|
* @name isNotArray
|
1640
1687
|
* @param {Mixed} value
|
@@ -1643,19 +1690,19 @@ module.exports = function (chai, util) {
|
|
1643
1690
|
*/
|
1644
1691
|
|
1645
1692
|
assert.isNotArray = function (val, msg) {
|
1646
|
-
new Assertion(val, msg).to.not.be.
|
1693
|
+
new Assertion(val, msg).to.not.be.an('array');
|
1647
1694
|
};
|
1648
1695
|
|
1649
1696
|
/**
|
1650
1697
|
* ### .isString(value, [message])
|
1651
1698
|
*
|
1652
|
-
*
|
1699
|
+
* Asserts that `value` is a string.
|
1653
1700
|
*
|
1654
|
-
*
|
1655
|
-
*
|
1701
|
+
* var teaOrder = 'chai';
|
1702
|
+
* assert.isString(teaOrder, 'order placed');
|
1656
1703
|
*
|
1657
1704
|
* @name isString
|
1658
|
-
* @param {
|
1705
|
+
* @param {Mixed} value
|
1659
1706
|
* @param {String} message
|
1660
1707
|
* @api public
|
1661
1708
|
*/
|
@@ -1667,10 +1714,10 @@ module.exports = function (chai, util) {
|
|
1667
1714
|
/**
|
1668
1715
|
* ### .isNotString(value, [message])
|
1669
1716
|
*
|
1670
|
-
*
|
1717
|
+
* Asserts that `value` is _not_ a string.
|
1671
1718
|
*
|
1672
|
-
*
|
1673
|
-
*
|
1719
|
+
* var teaOrder = 4;
|
1720
|
+
* assert.isNotString(teaOrder, 'order placed');
|
1674
1721
|
*
|
1675
1722
|
* @name isNotString
|
1676
1723
|
* @param {Mixed} value
|
@@ -1685,10 +1732,10 @@ module.exports = function (chai, util) {
|
|
1685
1732
|
/**
|
1686
1733
|
* ### .isNumber(value, [message])
|
1687
1734
|
*
|
1688
|
-
*
|
1735
|
+
* Asserts that `value` is a number.
|
1689
1736
|
*
|
1690
|
-
*
|
1691
|
-
*
|
1737
|
+
* var cups = 2;
|
1738
|
+
* assert.isNumber(cups, 'how many cups');
|
1692
1739
|
*
|
1693
1740
|
* @name isNumber
|
1694
1741
|
* @param {Number} value
|
@@ -1703,10 +1750,10 @@ module.exports = function (chai, util) {
|
|
1703
1750
|
/**
|
1704
1751
|
* ### .isNotNumber(value, [message])
|
1705
1752
|
*
|
1706
|
-
*
|
1753
|
+
* Asserts that `value` is _not_ a number.
|
1707
1754
|
*
|
1708
|
-
*
|
1709
|
-
*
|
1755
|
+
* var cups = '2 cups please';
|
1756
|
+
* assert.isNotNumber(cups, 'how many cups');
|
1710
1757
|
*
|
1711
1758
|
* @name isNotNumber
|
1712
1759
|
* @param {Mixed} value
|
@@ -1721,13 +1768,13 @@ module.exports = function (chai, util) {
|
|
1721
1768
|
/**
|
1722
1769
|
* ### .isBoolean(value, [message])
|
1723
1770
|
*
|
1724
|
-
*
|
1771
|
+
* Asserts that `value` is a boolean.
|
1725
1772
|
*
|
1726
|
-
*
|
1727
|
-
*
|
1773
|
+
* var teaReady = true
|
1774
|
+
* , teaServed = false;
|
1728
1775
|
*
|
1729
|
-
*
|
1730
|
-
*
|
1776
|
+
* assert.isBoolean(teaReady, 'is the tea ready');
|
1777
|
+
* assert.isBoolean(teaServed, 'has tea been served');
|
1731
1778
|
*
|
1732
1779
|
* @name isBoolean
|
1733
1780
|
* @param {Mixed} value
|
@@ -1742,13 +1789,13 @@ module.exports = function (chai, util) {
|
|
1742
1789
|
/**
|
1743
1790
|
* ### .isNotBoolean(value, [message])
|
1744
1791
|
*
|
1745
|
-
*
|
1792
|
+
* Asserts that `value` is _not_ a boolean.
|
1746
1793
|
*
|
1747
|
-
*
|
1748
|
-
*
|
1794
|
+
* var teaReady = 'yep'
|
1795
|
+
* , teaServed = 'nope';
|
1749
1796
|
*
|
1750
|
-
*
|
1751
|
-
*
|
1797
|
+
* assert.isNotBoolean(teaReady, 'is the tea ready');
|
1798
|
+
* assert.isNotBoolean(teaServed, 'has tea been served');
|
1752
1799
|
*
|
1753
1800
|
* @name isNotBoolean
|
1754
1801
|
* @param {Mixed} value
|
@@ -1763,13 +1810,19 @@ module.exports = function (chai, util) {
|
|
1763
1810
|
/**
|
1764
1811
|
* ### .typeOf(value, name, [message])
|
1765
1812
|
*
|
1766
|
-
*
|
1813
|
+
* Asserts that `value`'s type is `name`, as determined by
|
1814
|
+
* `Object.prototype.toString`.
|
1767
1815
|
*
|
1768
|
-
*
|
1816
|
+
* assert.typeOf({ tea: 'chai' }, 'object', 'we have an object');
|
1817
|
+
* assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array');
|
1818
|
+
* assert.typeOf('tea', 'string', 'we have a string');
|
1819
|
+
* assert.typeOf(/tea/, 'regexp', 'we have a regular expression');
|
1820
|
+
* assert.typeOf(null, 'null', 'we have a null');
|
1821
|
+
* assert.typeOf(undefined, 'undefined', 'we have an undefined');
|
1769
1822
|
*
|
1770
1823
|
* @name typeOf
|
1771
1824
|
* @param {Mixed} value
|
1772
|
-
* @param {String}
|
1825
|
+
* @param {String} name
|
1773
1826
|
* @param {String} message
|
1774
1827
|
* @api public
|
1775
1828
|
*/
|
@@ -1781,9 +1834,10 @@ module.exports = function (chai, util) {
|
|
1781
1834
|
/**
|
1782
1835
|
* ### .notTypeOf(value, name, [message])
|
1783
1836
|
*
|
1784
|
-
*
|
1837
|
+
* Asserts that `value`'s type is _not_ `name`, as determined by
|
1838
|
+
* `Object.prototype.toString`.
|
1785
1839
|
*
|
1786
|
-
*
|
1840
|
+
* assert.notTypeOf('tea', 'number', 'strings are not numbers');
|
1787
1841
|
*
|
1788
1842
|
* @name notTypeOf
|
1789
1843
|
* @param {Mixed} value
|
@@ -1799,12 +1853,12 @@ module.exports = function (chai, util) {
|
|
1799
1853
|
/**
|
1800
1854
|
* ### .instanceOf(object, constructor, [message])
|
1801
1855
|
*
|
1802
|
-
*
|
1856
|
+
* Asserts that `value` is an instance of `constructor`.
|
1803
1857
|
*
|
1804
|
-
*
|
1805
|
-
*
|
1858
|
+
* var Tea = function (name) { this.name = name; }
|
1859
|
+
* , chai = new Tea('chai');
|
1806
1860
|
*
|
1807
|
-
*
|
1861
|
+
* assert.instanceOf(chai, Tea, 'chai is an instance of tea');
|
1808
1862
|
*
|
1809
1863
|
* @name instanceOf
|
1810
1864
|
* @param {Object} object
|
@@ -1820,12 +1874,12 @@ module.exports = function (chai, util) {
|
|
1820
1874
|
/**
|
1821
1875
|
* ### .notInstanceOf(object, constructor, [message])
|
1822
1876
|
*
|
1823
|
-
*
|
1877
|
+
* Asserts `value` is not an instance of `constructor`.
|
1824
1878
|
*
|
1825
|
-
*
|
1826
|
-
*
|
1879
|
+
* var Tea = function (name) { this.name = name; }
|
1880
|
+
* , chai = new String('chai');
|
1827
1881
|
*
|
1828
|
-
*
|
1882
|
+
* assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea');
|
1829
1883
|
*
|
1830
1884
|
* @name notInstanceOf
|
1831
1885
|
* @param {Object} object
|
@@ -1839,17 +1893,17 @@ module.exports = function (chai, util) {
|
|
1839
1893
|
};
|
1840
1894
|
|
1841
1895
|
/**
|
1842
|
-
* ### .include(
|
1896
|
+
* ### .include(haystack, needle, [message])
|
1843
1897
|
*
|
1844
|
-
*
|
1898
|
+
* Asserts that `haystack` includes `needle`. Works
|
1845
1899
|
* for strings and arrays.
|
1846
1900
|
*
|
1847
|
-
*
|
1848
|
-
*
|
1901
|
+
* assert.include('foobar', 'bar', 'foobar contains string "bar"');
|
1902
|
+
* assert.include([ 1, 2, 3 ], 3, 'array contains value');
|
1849
1903
|
*
|
1850
1904
|
* @name include
|
1851
|
-
* @param {Array|String}
|
1852
|
-
* @param {
|
1905
|
+
* @param {Array|String} haystack
|
1906
|
+
* @param {Mixed} needle
|
1853
1907
|
* @param {String} message
|
1854
1908
|
* @api public
|
1855
1909
|
*/
|
@@ -1865,15 +1919,15 @@ module.exports = function (chai, util) {
|
|
1865
1919
|
};
|
1866
1920
|
|
1867
1921
|
/**
|
1868
|
-
* ### .match(value,
|
1922
|
+
* ### .match(value, regexp, [message])
|
1869
1923
|
*
|
1870
|
-
*
|
1924
|
+
* Asserts that `value` matches the regular expression `regexp`.
|
1871
1925
|
*
|
1872
|
-
*
|
1926
|
+
* assert.match('foobar', /^foo/, 'regexp matches');
|
1873
1927
|
*
|
1874
1928
|
* @name match
|
1875
|
-
* @param {
|
1876
|
-
* @param {RegExp}
|
1929
|
+
* @param {Mixed} value
|
1930
|
+
* @param {RegExp} regexp
|
1877
1931
|
* @param {String} message
|
1878
1932
|
* @api public
|
1879
1933
|
*/
|
@@ -1883,15 +1937,15 @@ module.exports = function (chai, util) {
|
|
1883
1937
|
};
|
1884
1938
|
|
1885
1939
|
/**
|
1886
|
-
* ### .notMatch(value,
|
1940
|
+
* ### .notMatch(value, regexp, [message])
|
1887
1941
|
*
|
1888
|
-
*
|
1942
|
+
* Asserts that `value` does not match the regular expression `regexp`.
|
1889
1943
|
*
|
1890
|
-
*
|
1944
|
+
* assert.notMatch('foobar', /^foo/, 'regexp does not match');
|
1891
1945
|
*
|
1892
1946
|
* @name notMatch
|
1893
|
-
* @param {
|
1894
|
-
* @param {RegExp}
|
1947
|
+
* @param {Mixed} value
|
1948
|
+
* @param {RegExp} regexp
|
1895
1949
|
* @param {String} message
|
1896
1950
|
* @api public
|
1897
1951
|
*/
|
@@ -1903,13 +1957,13 @@ module.exports = function (chai, util) {
|
|
1903
1957
|
/**
|
1904
1958
|
* ### .property(object, property, [message])
|
1905
1959
|
*
|
1906
|
-
*
|
1960
|
+
* Asserts that `object` has a property named by `property`.
|
1907
1961
|
*
|
1908
|
-
*
|
1962
|
+
* assert.property({ tea: { green: 'matcha' }}, 'tea');
|
1909
1963
|
*
|
1910
1964
|
* @name property
|
1911
1965
|
* @param {Object} object
|
1912
|
-
* @param {String}
|
1966
|
+
* @param {String} property
|
1913
1967
|
* @param {String} message
|
1914
1968
|
* @api public
|
1915
1969
|
*/
|
@@ -1919,15 +1973,15 @@ module.exports = function (chai, util) {
|
|
1919
1973
|
};
|
1920
1974
|
|
1921
1975
|
/**
|
1922
|
-
* ### .
|
1976
|
+
* ### .notProperty(object, property, [message])
|
1923
1977
|
*
|
1924
|
-
*
|
1978
|
+
* Asserts that `object` does _not_ have a property named by `property`.
|
1925
1979
|
*
|
1926
|
-
*
|
1980
|
+
* assert.notProperty({ tea: { green: 'matcha' }}, 'coffee');
|
1927
1981
|
*
|
1928
|
-
* @name
|
1982
|
+
* @name notProperty
|
1929
1983
|
* @param {Object} object
|
1930
|
-
* @param {String} property
|
1984
|
+
* @param {String} property
|
1931
1985
|
* @param {String} message
|
1932
1986
|
* @api public
|
1933
1987
|
*/
|
@@ -1936,17 +1990,55 @@ module.exports = function (chai, util) {
|
|
1936
1990
|
new Assertion(obj, msg).to.not.have.property(prop);
|
1937
1991
|
};
|
1938
1992
|
|
1993
|
+
/**
|
1994
|
+
* ### .deepProperty(object, property, [message])
|
1995
|
+
*
|
1996
|
+
* Asserts that `object` has a property named by `property`, which can be a
|
1997
|
+
* string using dot- and bracket-notation for deep reference.
|
1998
|
+
*
|
1999
|
+
* assert.deepProperty({ tea: { green: 'matcha' }}, 'tea.green');
|
2000
|
+
*
|
2001
|
+
* @name deepProperty
|
2002
|
+
* @param {Object} object
|
2003
|
+
* @param {String} property
|
2004
|
+
* @param {String} message
|
2005
|
+
* @api public
|
2006
|
+
*/
|
2007
|
+
|
2008
|
+
assert.deepProperty = function (obj, prop, msg) {
|
2009
|
+
new Assertion(obj, msg).to.have.deep.property(prop);
|
2010
|
+
};
|
2011
|
+
|
2012
|
+
/**
|
2013
|
+
* ### .notDeepProperty(object, property, [message])
|
2014
|
+
*
|
2015
|
+
* Asserts that `object` does _not_ have a property named by `property`, which
|
2016
|
+
* can be a string using dot- and bracket-notation for deep reference.
|
2017
|
+
*
|
2018
|
+
* assert.notDeepProperty({ tea: { green: 'matcha' }}, 'tea.oolong');
|
2019
|
+
*
|
2020
|
+
* @name notDeepProperty
|
2021
|
+
* @param {Object} object
|
2022
|
+
* @param {String} property
|
2023
|
+
* @param {String} message
|
2024
|
+
* @api public
|
2025
|
+
*/
|
2026
|
+
|
2027
|
+
assert.notDeepProperty = function (obj, prop, msg) {
|
2028
|
+
new Assertion(obj, msg).to.not.have.deep.property(prop);
|
2029
|
+
};
|
2030
|
+
|
1939
2031
|
/**
|
1940
2032
|
* ### .propertyVal(object, property, value, [message])
|
1941
2033
|
*
|
1942
|
-
*
|
1943
|
-
*
|
2034
|
+
* Asserts that `object` has a property named by `property` with value given
|
2035
|
+
* by `value`.
|
1944
2036
|
*
|
1945
|
-
*
|
2037
|
+
* assert.propertyVal({ tea: 'is good' }, 'tea', 'is good');
|
1946
2038
|
*
|
1947
2039
|
* @name propertyVal
|
1948
2040
|
* @param {Object} object
|
1949
|
-
* @param {String} property
|
2041
|
+
* @param {String} property
|
1950
2042
|
* @param {Mixed} value
|
1951
2043
|
* @param {String} message
|
1952
2044
|
* @api public
|
@@ -1959,32 +2051,75 @@ module.exports = function (chai, util) {
|
|
1959
2051
|
/**
|
1960
2052
|
* ### .propertyNotVal(object, property, value, [message])
|
1961
2053
|
*
|
1962
|
-
*
|
1963
|
-
*
|
2054
|
+
* Asserts that `object` has a property named by `property`, but with a value
|
2055
|
+
* different from that given by `value`.
|
1964
2056
|
*
|
1965
|
-
*
|
2057
|
+
* assert.propertyNotVal({ tea: 'is good' }, 'tea', 'is bad');
|
1966
2058
|
*
|
1967
2059
|
* @name propertyNotVal
|
1968
2060
|
* @param {Object} object
|
1969
|
-
* @param {String} property
|
2061
|
+
* @param {String} property
|
1970
2062
|
* @param {Mixed} value
|
1971
2063
|
* @param {String} message
|
1972
2064
|
* @api public
|
1973
2065
|
*/
|
2066
|
+
|
1974
2067
|
assert.propertyNotVal = function (obj, prop, val, msg) {
|
1975
2068
|
new Assertion(obj, msg).to.not.have.property(prop, val);
|
1976
2069
|
};
|
1977
2070
|
|
2071
|
+
/**
|
2072
|
+
* ### .deepPropertyVal(object, property, value, [message])
|
2073
|
+
*
|
2074
|
+
* Asserts that `object` has a property named by `property` with value given
|
2075
|
+
* by `value`. `property` can use dot- and bracket-notation for deep
|
2076
|
+
* reference.
|
2077
|
+
*
|
2078
|
+
* assert.deepPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha');
|
2079
|
+
*
|
2080
|
+
* @name deepPropertyVal
|
2081
|
+
* @param {Object} object
|
2082
|
+
* @param {String} property
|
2083
|
+
* @param {Mixed} value
|
2084
|
+
* @param {String} message
|
2085
|
+
* @api public
|
2086
|
+
*/
|
2087
|
+
|
2088
|
+
assert.deepPropertyVal = function (obj, prop, val, msg) {
|
2089
|
+
new Assertion(obj, msg).to.have.deep.property(prop, val);
|
2090
|
+
};
|
2091
|
+
|
2092
|
+
/**
|
2093
|
+
* ### .deepPropertyNotVal(object, property, value, [message])
|
2094
|
+
*
|
2095
|
+
* Asserts that `object` has a property named by `property`, but with a value
|
2096
|
+
* different from that given by `value`. `property` can use dot- and
|
2097
|
+
* bracket-notation for deep reference.
|
2098
|
+
*
|
2099
|
+
* assert.deepPropertyNotVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha');
|
2100
|
+
*
|
2101
|
+
* @name deepPropertyNotVal
|
2102
|
+
* @param {Object} object
|
2103
|
+
* @param {String} property
|
2104
|
+
* @param {Mixed} value
|
2105
|
+
* @param {String} message
|
2106
|
+
* @api public
|
2107
|
+
*/
|
2108
|
+
|
2109
|
+
assert.deepPropertyNotVal = function (obj, prop, val, msg) {
|
2110
|
+
new Assertion(obj, msg).to.not.have.deep.property(prop, val);
|
2111
|
+
};
|
2112
|
+
|
1978
2113
|
/**
|
1979
2114
|
* ### .lengthOf(object, length, [message])
|
1980
2115
|
*
|
1981
|
-
*
|
2116
|
+
* Asserts that `object` has a `length` property with the expected value.
|
1982
2117
|
*
|
1983
|
-
*
|
1984
|
-
*
|
2118
|
+
* assert.lengthOf([1,2,3], 3, 'array has length of 3');
|
2119
|
+
* assert.lengthOf('foobar', 5, 'string has length of 6');
|
1985
2120
|
*
|
1986
|
-
* @name
|
1987
|
-
* @param {
|
2121
|
+
* @name lengthOf
|
2122
|
+
* @param {Mixed} object
|
1988
2123
|
* @param {Number} length
|
1989
2124
|
* @param {String} message
|
1990
2125
|
* @api public
|
@@ -1997,21 +2132,24 @@ module.exports = function (chai, util) {
|
|
1997
2132
|
/**
|
1998
2133
|
* ### .throws(function, [constructor/regexp], [message])
|
1999
2134
|
*
|
2000
|
-
*
|
2001
|
-
*
|
2135
|
+
* Asserts that `function` will throw an error that is an instance of
|
2136
|
+
* `constructor`, or alternately that it will throw an error with message
|
2137
|
+
* matching `regexp`.
|
2002
2138
|
*
|
2003
|
-
*
|
2139
|
+
* assert.throw(fn, ReferenceError, 'function throws a reference error');
|
2004
2140
|
*
|
2005
2141
|
* @name throws
|
2006
2142
|
* @alias throw
|
2007
|
-
* @
|
2143
|
+
* @alias Throw
|
2144
|
+
* @param {Function} function
|
2008
2145
|
* @param {ErrorConstructor} constructor
|
2146
|
+
* @param {RegExp} regexp
|
2009
2147
|
* @param {String} message
|
2010
2148
|
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
2011
2149
|
* @api public
|
2012
2150
|
*/
|
2013
2151
|
|
2014
|
-
assert.
|
2152
|
+
assert.Throw = function (fn, type, msg) {
|
2015
2153
|
if ('string' === typeof type) {
|
2016
2154
|
msg = type;
|
2017
2155
|
type = null;
|
@@ -2023,15 +2161,16 @@ module.exports = function (chai, util) {
|
|
2023
2161
|
/**
|
2024
2162
|
* ### .doesNotThrow(function, [constructor/regexp], [message])
|
2025
2163
|
*
|
2026
|
-
*
|
2027
|
-
*
|
2164
|
+
* Asserts that `function` will _not_ throw an error that is an instance of
|
2165
|
+
* `constructor`, or alternately that it will not throw an error with message
|
2166
|
+
* matching `regexp`.
|
2028
2167
|
*
|
2029
|
-
*
|
2030
|
-
* assert.doesNotThrow(fn, Error, 'function throw reference error');
|
2168
|
+
* assert.doesNotThrow(fn, Error, 'function does not throw');
|
2031
2169
|
*
|
2032
2170
|
* @name doesNotThrow
|
2033
|
-
* @param {Function} function
|
2171
|
+
* @param {Function} function
|
2034
2172
|
* @param {ErrorConstructor} constructor
|
2173
|
+
* @param {RegExp} regexp
|
2035
2174
|
* @param {String} message
|
2036
2175
|
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
2037
2176
|
* @api public
|
@@ -2047,17 +2186,17 @@ module.exports = function (chai, util) {
|
|
2047
2186
|
};
|
2048
2187
|
|
2049
2188
|
/**
|
2050
|
-
* ### .operator(
|
2189
|
+
* ### .operator(val1, operator, val2, [message])
|
2051
2190
|
*
|
2052
|
-
*
|
2191
|
+
* Compares two values using `operator`.
|
2053
2192
|
*
|
2054
|
-
*
|
2055
|
-
*
|
2193
|
+
* assert.operator(1, '<', 2, 'everything is ok');
|
2194
|
+
* assert.operator(1, '>', 2, 'this will fail');
|
2056
2195
|
*
|
2057
2196
|
* @name operator
|
2058
|
-
* @param {
|
2197
|
+
* @param {Mixed} val1
|
2059
2198
|
* @param {String} operator
|
2060
|
-
* @param {
|
2199
|
+
* @param {Mixed} val2
|
2061
2200
|
* @param {String} message
|
2062
2201
|
* @api public
|
2063
2202
|
*/
|
@@ -2089,7 +2228,8 @@ module.exports = function (chai, util) {
|
|
2089
2228
|
assert[as] = assert[name];
|
2090
2229
|
return alias;
|
2091
2230
|
})
|
2092
|
-
('
|
2231
|
+
('Throw', 'throw')
|
2232
|
+
('Throw', 'throws');
|
2093
2233
|
};
|
2094
2234
|
|
2095
2235
|
}); // module: interface/assert.js
|