chai 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/History.md +14 -0
- package/README.md +43 -40
- package/ReleaseNotes.md +31 -0
- package/bower.json +1 -1
- package/chai.js +64 -15
- package/lib/chai/core/assertions.js +63 -14
- package/lib/chai.js +1 -1
- package/package.json +2 -1
package/History.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
2.3.0 / 2015-04-26
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
* Merge pull request #423 from ehntoo/patch-1
|
|
5
|
+
* Merge pull request #422 from ljharb/fix_descriptor_tests
|
|
6
|
+
* Fix a small bug in the .null assertion docs
|
|
7
|
+
* Use a regex to account for property ordering issues across engines.
|
|
8
|
+
* Add `make test-firefox`
|
|
9
|
+
* Merge pull request #417 from astorije/astorije/minimalist-typo
|
|
10
|
+
* Remove trailing whitespaces
|
|
11
|
+
* Fix super minor typo in an example
|
|
12
|
+
* Merge pull request #408 from ljharb/enumerableProperty
|
|
13
|
+
* Add `ownPropertyDescriptor` assertion.
|
|
14
|
+
|
|
1
15
|
2.2.0 / 2015-03-26
|
|
2
16
|
==================
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -25,82 +25,85 @@ Chai offers a robust Plugin architecture for extending Chai's assertions and int
|
|
|
25
25
|
### Contributors
|
|
26
26
|
|
|
27
27
|
project : chai
|
|
28
|
-
repo age : 3 years,
|
|
29
|
-
active :
|
|
30
|
-
commits :
|
|
28
|
+
repo age : 3 years, 5 months
|
|
29
|
+
active : 244 days
|
|
30
|
+
commits : 900
|
|
31
31
|
files : 59
|
|
32
32
|
authors :
|
|
33
|
-
555 Jake Luer
|
|
34
|
-
79 Veselin Todorov
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
555 Jake Luer 61.7%
|
|
34
|
+
79 Veselin Todorov 8.8%
|
|
35
|
+
52 Keith Cirkel 5.8%
|
|
36
|
+
43 Domenic Denicola 4.8%
|
|
37
37
|
14 Joshua Perry 1.6%
|
|
38
38
|
8 Chris Polis 0.9%
|
|
39
39
|
6 Ruben Verborgh 0.7%
|
|
40
40
|
6 Ian Zamojc 0.7%
|
|
41
|
-
5 leider 0.6%
|
|
42
41
|
5 George Kats 0.6%
|
|
42
|
+
5 leider 0.6%
|
|
43
43
|
5 Scott Nonnenberg 0.6%
|
|
44
|
-
5 Jo Liss 0.6%
|
|
45
44
|
5 Juliusz Gonera 0.6%
|
|
46
|
-
|
|
47
|
-
4
|
|
48
|
-
4
|
|
49
|
-
4
|
|
50
|
-
4
|
|
51
|
-
4
|
|
52
|
-
4
|
|
53
|
-
4
|
|
45
|
+
5 Jo Liss 0.6%
|
|
46
|
+
4 Jérémie Astori 0.4%
|
|
47
|
+
4 John Firebaugh 0.4%
|
|
48
|
+
4 charlierudolph 0.4%
|
|
49
|
+
4 Veselin 0.4%
|
|
50
|
+
4 Chris Jones 0.4%
|
|
51
|
+
4 Nick Heiner 0.4%
|
|
52
|
+
4 Max Edmands 0.4%
|
|
53
|
+
4 David da Silva 0.4%
|
|
54
|
+
4 Kaito Udagawa 0.4%
|
|
55
|
+
4 josher19 0.4%
|
|
56
|
+
3 Jordan Harband 0.3%
|
|
54
57
|
3 Ryunosuke SATO 0.3%
|
|
58
|
+
3 Jake Rosoman 0.3%
|
|
59
|
+
3 Duncan Beevers 0.3%
|
|
55
60
|
3 Jason Karns 0.3%
|
|
56
61
|
3 Jeff Barczewski 0.3%
|
|
57
62
|
3 Andrei Neculau 0.3%
|
|
58
|
-
|
|
59
|
-
3 Jake Rosoman 0.3%
|
|
60
|
-
2 Teddy Cross 0.2%
|
|
63
|
+
2 eldritch fossicker 0.2%
|
|
61
64
|
2 Bartvds 0.2%
|
|
62
65
|
2 Edwin Shao 0.2%
|
|
63
66
|
2 Gregg Lind 0.2%
|
|
64
|
-
2 Roman Masek 0.2%
|
|
65
|
-
2 Jérémie Astori 0.2%
|
|
66
67
|
2 Jakub Nešetřil 0.2%
|
|
67
|
-
2
|
|
68
|
-
|
|
69
|
-
1 toastynerd 0.1%
|
|
70
|
-
1 Anand Patil 0.1%
|
|
71
|
-
1 Benjamin Horsleben 0.1%
|
|
72
|
-
1 Brandon Payton 0.1%
|
|
73
|
-
1 Chasen Le Hara 0.1%
|
|
74
|
-
1 Chris Connelly 0.1%
|
|
75
|
-
1 Chris Thompson 0.1%
|
|
76
|
-
1 Christopher Hiller 0.1%
|
|
77
|
-
1 Chun-Yi 0.1%
|
|
78
|
-
1 DD 0.1%
|
|
79
|
-
1 Danilo Vaz 0.1%
|
|
80
|
-
1 Dido Arellano 0.1%
|
|
81
|
-
1 Doug Neiner 0.1%
|
|
82
|
-
1 Jeff Welch 0.1%
|
|
68
|
+
2 Roman Masek 0.2%
|
|
69
|
+
2 Teddy Cross 0.2%
|
|
83
70
|
1 Jesse McCarthy 0.1%
|
|
84
|
-
1
|
|
71
|
+
1 Doug Neiner 0.1%
|
|
72
|
+
1 Dido Arellano 0.1%
|
|
85
73
|
1 Kilian Ciuffolo 0.1%
|
|
86
74
|
1 Luís Cardoso 0.1%
|
|
87
75
|
1 Martin Middel 0.1%
|
|
88
76
|
1 Mathias Schreck 0.1%
|
|
77
|
+
1 Danilo Vaz 0.1%
|
|
89
78
|
1 Michael Lange 0.1%
|
|
79
|
+
1 Mitchell Johnson 0.1%
|
|
80
|
+
1 DD 0.1%
|
|
90
81
|
1 Niklas Närhinen 0.1%
|
|
91
82
|
1 Paul Miller 0.1%
|
|
92
83
|
1 Refael Ackermann 0.1%
|
|
84
|
+
1 shinnn 0.1%
|
|
85
|
+
1 Chun-Yi 0.1%
|
|
86
|
+
1 Christopher Hiller 0.1%
|
|
93
87
|
1 Sasha Koss 0.1%
|
|
88
|
+
1 Chris Thompson 0.1%
|
|
89
|
+
1 toastynerd 0.1%
|
|
90
|
+
1 Chris Connelly 0.1%
|
|
91
|
+
1 Chasen Le Hara 0.1%
|
|
94
92
|
1 Victor Costan 0.1%
|
|
95
93
|
1 Vinay Pulim 0.1%
|
|
96
94
|
1 Virginie BARDALES 0.1%
|
|
97
95
|
1 Vlad GURDIGA 0.1%
|
|
96
|
+
1 Brandon Payton 0.1%
|
|
97
|
+
1 Adam Hull 0.1%
|
|
98
98
|
1 ericdouglas 0.1%
|
|
99
|
+
1 Benjamin Horsleben 0.1%
|
|
99
100
|
1 laconbass 0.1%
|
|
101
|
+
1 Anand Patil 0.1%
|
|
100
102
|
1 mohayonao 0.1%
|
|
101
103
|
1 piecioshka 0.1%
|
|
102
104
|
1 root 0.1%
|
|
103
|
-
1
|
|
105
|
+
1 Julien Wajsberg 0.1%
|
|
106
|
+
1 Jeff Welch 0.1%
|
|
104
107
|
|
|
105
108
|
## License
|
|
106
109
|
|
package/ReleaseNotes.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## 2.3.0 / 2015-04-26
|
|
4
|
+
|
|
5
|
+
Added `ownPropertyDescriptor` assertion:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
expect('test').to.have.ownPropertyDescriptor('length');
|
|
9
|
+
expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 });
|
|
10
|
+
expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 });
|
|
11
|
+
expect('test').ownPropertyDescriptor('length').to.have.property('enumerable', false);
|
|
12
|
+
expect('test').ownPropertyDescriptor('length').to.have.keys('value');
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Community Contributions
|
|
16
|
+
|
|
17
|
+
#### Code Features & Fixes
|
|
18
|
+
|
|
19
|
+
* [#408](https://github.com/chaijs/chai/pull/408) Add `ownPropertyDescriptor`
|
|
20
|
+
assertion.
|
|
21
|
+
By [@ljharb](https://github.com/ljharb)
|
|
22
|
+
* [#422](https://github.com/chaijs/chai/pull/422) Improve ownPropertyDescriptor
|
|
23
|
+
tests.
|
|
24
|
+
By [@ljharb](https://github.com/ljharb)
|
|
25
|
+
|
|
26
|
+
#### Documentation fixes
|
|
27
|
+
|
|
28
|
+
* [#417](https://github.com/chaijs/chai/pull/417) Fix documentation typo
|
|
29
|
+
By [@astorije](https://github.com/astorije)
|
|
30
|
+
* [#423](https://github.com/chaijs/chai/pull/423) Fix inconsistency in docs.
|
|
31
|
+
By [@ehntoo](https://github.com/ehntoo)
|
|
32
|
+
|
|
33
|
+
|
|
3
34
|
## 2.2.0 / 2015-03-26
|
|
4
35
|
|
|
5
36
|
Deep property strings can now be escaped using `\\` - for example:
|
package/bower.json
CHANGED
package/chai.js
CHANGED
|
@@ -678,7 +678,7 @@ var used = []
|
|
|
678
678
|
* Chai version
|
|
679
679
|
*/
|
|
680
680
|
|
|
681
|
-
exports.version = '2.
|
|
681
|
+
exports.version = '2.3.0';
|
|
682
682
|
|
|
683
683
|
/*!
|
|
684
684
|
* Assertion Error
|
|
@@ -1051,7 +1051,7 @@ module.exports = function (chai, _) {
|
|
|
1051
1051
|
* ### .any
|
|
1052
1052
|
*
|
|
1053
1053
|
* Sets the `any` flag, (opposite of the `all` flag)
|
|
1054
|
-
* later used in the `keys` assertion.
|
|
1054
|
+
* later used in the `keys` assertion.
|
|
1055
1055
|
*
|
|
1056
1056
|
* expect(foo).to.have.any.keys('bar', 'baz');
|
|
1057
1057
|
*
|
|
@@ -1068,7 +1068,7 @@ module.exports = function (chai, _) {
|
|
|
1068
1068
|
/**
|
|
1069
1069
|
* ### .all
|
|
1070
1070
|
*
|
|
1071
|
-
* Sets the `all` flag (opposite of the `any` flag)
|
|
1071
|
+
* Sets the `all` flag (opposite of the `any` flag)
|
|
1072
1072
|
* later used by the `keys` assertion.
|
|
1073
1073
|
*
|
|
1074
1074
|
* expect(foo).to.have.all.keys('bar', 'baz');
|
|
@@ -1249,7 +1249,7 @@ module.exports = function (chai, _) {
|
|
|
1249
1249
|
* Asserts that the target is `null`.
|
|
1250
1250
|
*
|
|
1251
1251
|
* expect(null).to.be.null;
|
|
1252
|
-
* expect(undefined).not.
|
|
1252
|
+
* expect(undefined).to.not.be.null;
|
|
1253
1253
|
*
|
|
1254
1254
|
* @name null
|
|
1255
1255
|
* @api public
|
|
@@ -1725,7 +1725,7 @@ module.exports = function (chai, _) {
|
|
|
1725
1725
|
* green: { tea: 'matcha' }
|
|
1726
1726
|
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
|
|
1727
1727
|
* };
|
|
1728
|
-
*
|
|
1728
|
+
*
|
|
1729
1729
|
* expect(deepObj).to.have.deep.property('green.tea', 'matcha');
|
|
1730
1730
|
* expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
|
|
1731
1731
|
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
|
|
@@ -1846,6 +1846,55 @@ module.exports = function (chai, _) {
|
|
|
1846
1846
|
Assertion.addMethod('ownProperty', assertOwnProperty);
|
|
1847
1847
|
Assertion.addMethod('haveOwnProperty', assertOwnProperty);
|
|
1848
1848
|
|
|
1849
|
+
/**
|
|
1850
|
+
* ### .ownPropertyDescriptor(name[, descriptor[, message]])
|
|
1851
|
+
*
|
|
1852
|
+
* Asserts that the target has an own property descriptor `name`, that optionally matches `descriptor`.
|
|
1853
|
+
*
|
|
1854
|
+
* expect('test').to.have.ownPropertyDescriptor('length');
|
|
1855
|
+
* expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 });
|
|
1856
|
+
* expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 });
|
|
1857
|
+
* expect('test').ownPropertyDescriptor('length').to.have.property('enumerable', false);
|
|
1858
|
+
* expect('test').ownPropertyDescriptor('length').to.have.keys('value');
|
|
1859
|
+
*
|
|
1860
|
+
* @name ownPropertyDescriptor
|
|
1861
|
+
* @alias haveOwnPropertyDescriptor
|
|
1862
|
+
* @param {String} name
|
|
1863
|
+
* @param {Object} descriptor _optional_
|
|
1864
|
+
* @param {String} message _optional_
|
|
1865
|
+
* @api public
|
|
1866
|
+
*/
|
|
1867
|
+
|
|
1868
|
+
function assertOwnPropertyDescriptor (name, descriptor, msg) {
|
|
1869
|
+
if (typeof descriptor === 'string') {
|
|
1870
|
+
msg = descriptor;
|
|
1871
|
+
descriptor = null;
|
|
1872
|
+
}
|
|
1873
|
+
if (msg) flag(this, 'message', msg);
|
|
1874
|
+
var obj = flag(this, 'object');
|
|
1875
|
+
var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
|
1876
|
+
if (actualDescriptor && descriptor) {
|
|
1877
|
+
this.assert(
|
|
1878
|
+
_.eql(descriptor, actualDescriptor)
|
|
1879
|
+
, 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to match ' + _.inspect(descriptor) + ', got ' + _.inspect(actualDescriptor)
|
|
1880
|
+
, 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to not match ' + _.inspect(descriptor)
|
|
1881
|
+
, descriptor
|
|
1882
|
+
, actualDescriptor
|
|
1883
|
+
, true
|
|
1884
|
+
);
|
|
1885
|
+
} else {
|
|
1886
|
+
this.assert(
|
|
1887
|
+
actualDescriptor
|
|
1888
|
+
, 'expected #{this} to have an own property descriptor for ' + _.inspect(name)
|
|
1889
|
+
, 'expected #{this} to not have an own property descriptor for ' + _.inspect(name)
|
|
1890
|
+
);
|
|
1891
|
+
}
|
|
1892
|
+
flag(this, 'object', actualDescriptor);
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
Assertion.addMethod('ownPropertyDescriptor', assertOwnPropertyDescriptor);
|
|
1896
|
+
Assertion.addMethod('haveOwnPropertyDescriptor', assertOwnPropertyDescriptor);
|
|
1897
|
+
|
|
1849
1898
|
/**
|
|
1850
1899
|
* ### .length(value)
|
|
1851
1900
|
*
|
|
@@ -1947,30 +1996,30 @@ module.exports = function (chai, _) {
|
|
|
1947
1996
|
* ### .keys(key1, [key2], [...])
|
|
1948
1997
|
*
|
|
1949
1998
|
* Asserts that the target contains any or all of the passed-in keys.
|
|
1950
|
-
* Use in combination with `any`, `all`, `contains`, or `have` will affect
|
|
1999
|
+
* Use in combination with `any`, `all`, `contains`, or `have` will affect
|
|
1951
2000
|
* what will pass.
|
|
1952
|
-
*
|
|
1953
|
-
* When used in conjunction with `any`, at least one key that is passed
|
|
1954
|
-
* in must exist in the target object. This is regardless whether or not
|
|
2001
|
+
*
|
|
2002
|
+
* When used in conjunction with `any`, at least one key that is passed
|
|
2003
|
+
* in must exist in the target object. This is regardless whether or not
|
|
1955
2004
|
* the `have` or `contain` qualifiers are used. Note, either `any` or `all`
|
|
1956
2005
|
* should be used in the assertion. If neither are used, the assertion is
|
|
1957
2006
|
* defaulted to `all`.
|
|
1958
|
-
*
|
|
1959
|
-
* When both `all` and `contain` are used, the target object must have at
|
|
2007
|
+
*
|
|
2008
|
+
* When both `all` and `contain` are used, the target object must have at
|
|
1960
2009
|
* least all of the passed-in keys but may have more keys not listed.
|
|
1961
|
-
*
|
|
2010
|
+
*
|
|
1962
2011
|
* When both `all` and `have` are used, the target object must both contain
|
|
1963
2012
|
* all of the passed-in keys AND the number of keys in the target object must
|
|
1964
|
-
* match the number of keys passed in (in other words, a target object must
|
|
2013
|
+
* match the number of keys passed in (in other words, a target object must
|
|
1965
2014
|
* have all and only all of the passed-in keys).
|
|
1966
|
-
*
|
|
2015
|
+
*
|
|
1967
2016
|
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo', 'baz');
|
|
1968
2017
|
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo');
|
|
1969
2018
|
* expect({ foo: 1, bar: 2 }).to.contain.any.keys('bar', 'baz');
|
|
1970
2019
|
* expect({ foo: 1, bar: 2 }).to.contain.any.keys(['foo']);
|
|
1971
2020
|
* expect({ foo: 1, bar: 2 }).to.contain.any.keys({'foo': 6});
|
|
1972
2021
|
* expect({ foo: 1, bar: 2 }).to.have.all.keys(['bar', 'foo']);
|
|
1973
|
-
* expect({ foo: 1, bar: 2 }).to.have.all.keys({'bar': 6, 'foo'
|
|
2022
|
+
* expect({ foo: 1, bar: 2 }).to.have.all.keys({'bar': 6, 'foo': 7});
|
|
1974
2023
|
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys(['bar', 'foo']);
|
|
1975
2024
|
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys([{'bar': 6}}]);
|
|
1976
2025
|
*
|
|
@@ -93,7 +93,7 @@ module.exports = function (chai, _) {
|
|
|
93
93
|
* ### .any
|
|
94
94
|
*
|
|
95
95
|
* Sets the `any` flag, (opposite of the `all` flag)
|
|
96
|
-
* later used in the `keys` assertion.
|
|
96
|
+
* later used in the `keys` assertion.
|
|
97
97
|
*
|
|
98
98
|
* expect(foo).to.have.any.keys('bar', 'baz');
|
|
99
99
|
*
|
|
@@ -110,7 +110,7 @@ module.exports = function (chai, _) {
|
|
|
110
110
|
/**
|
|
111
111
|
* ### .all
|
|
112
112
|
*
|
|
113
|
-
* Sets the `all` flag (opposite of the `any` flag)
|
|
113
|
+
* Sets the `all` flag (opposite of the `any` flag)
|
|
114
114
|
* later used by the `keys` assertion.
|
|
115
115
|
*
|
|
116
116
|
* expect(foo).to.have.all.keys('bar', 'baz');
|
|
@@ -291,7 +291,7 @@ module.exports = function (chai, _) {
|
|
|
291
291
|
* Asserts that the target is `null`.
|
|
292
292
|
*
|
|
293
293
|
* expect(null).to.be.null;
|
|
294
|
-
* expect(undefined).not.
|
|
294
|
+
* expect(undefined).to.not.be.null;
|
|
295
295
|
*
|
|
296
296
|
* @name null
|
|
297
297
|
* @api public
|
|
@@ -767,7 +767,7 @@ module.exports = function (chai, _) {
|
|
|
767
767
|
* green: { tea: 'matcha' }
|
|
768
768
|
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
|
|
769
769
|
* };
|
|
770
|
-
*
|
|
770
|
+
*
|
|
771
771
|
* expect(deepObj).to.have.deep.property('green.tea', 'matcha');
|
|
772
772
|
* expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
|
|
773
773
|
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
|
|
@@ -888,6 +888,55 @@ module.exports = function (chai, _) {
|
|
|
888
888
|
Assertion.addMethod('ownProperty', assertOwnProperty);
|
|
889
889
|
Assertion.addMethod('haveOwnProperty', assertOwnProperty);
|
|
890
890
|
|
|
891
|
+
/**
|
|
892
|
+
* ### .ownPropertyDescriptor(name[, descriptor[, message]])
|
|
893
|
+
*
|
|
894
|
+
* Asserts that the target has an own property descriptor `name`, that optionally matches `descriptor`.
|
|
895
|
+
*
|
|
896
|
+
* expect('test').to.have.ownPropertyDescriptor('length');
|
|
897
|
+
* expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 });
|
|
898
|
+
* expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 });
|
|
899
|
+
* expect('test').ownPropertyDescriptor('length').to.have.property('enumerable', false);
|
|
900
|
+
* expect('test').ownPropertyDescriptor('length').to.have.keys('value');
|
|
901
|
+
*
|
|
902
|
+
* @name ownPropertyDescriptor
|
|
903
|
+
* @alias haveOwnPropertyDescriptor
|
|
904
|
+
* @param {String} name
|
|
905
|
+
* @param {Object} descriptor _optional_
|
|
906
|
+
* @param {String} message _optional_
|
|
907
|
+
* @api public
|
|
908
|
+
*/
|
|
909
|
+
|
|
910
|
+
function assertOwnPropertyDescriptor (name, descriptor, msg) {
|
|
911
|
+
if (typeof descriptor === 'string') {
|
|
912
|
+
msg = descriptor;
|
|
913
|
+
descriptor = null;
|
|
914
|
+
}
|
|
915
|
+
if (msg) flag(this, 'message', msg);
|
|
916
|
+
var obj = flag(this, 'object');
|
|
917
|
+
var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
|
918
|
+
if (actualDescriptor && descriptor) {
|
|
919
|
+
this.assert(
|
|
920
|
+
_.eql(descriptor, actualDescriptor)
|
|
921
|
+
, 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to match ' + _.inspect(descriptor) + ', got ' + _.inspect(actualDescriptor)
|
|
922
|
+
, 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to not match ' + _.inspect(descriptor)
|
|
923
|
+
, descriptor
|
|
924
|
+
, actualDescriptor
|
|
925
|
+
, true
|
|
926
|
+
);
|
|
927
|
+
} else {
|
|
928
|
+
this.assert(
|
|
929
|
+
actualDescriptor
|
|
930
|
+
, 'expected #{this} to have an own property descriptor for ' + _.inspect(name)
|
|
931
|
+
, 'expected #{this} to not have an own property descriptor for ' + _.inspect(name)
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
flag(this, 'object', actualDescriptor);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
Assertion.addMethod('ownPropertyDescriptor', assertOwnPropertyDescriptor);
|
|
938
|
+
Assertion.addMethod('haveOwnPropertyDescriptor', assertOwnPropertyDescriptor);
|
|
939
|
+
|
|
891
940
|
/**
|
|
892
941
|
* ### .length(value)
|
|
893
942
|
*
|
|
@@ -989,30 +1038,30 @@ module.exports = function (chai, _) {
|
|
|
989
1038
|
* ### .keys(key1, [key2], [...])
|
|
990
1039
|
*
|
|
991
1040
|
* Asserts that the target contains any or all of the passed-in keys.
|
|
992
|
-
* Use in combination with `any`, `all`, `contains`, or `have` will affect
|
|
1041
|
+
* Use in combination with `any`, `all`, `contains`, or `have` will affect
|
|
993
1042
|
* what will pass.
|
|
994
|
-
*
|
|
995
|
-
* When used in conjunction with `any`, at least one key that is passed
|
|
996
|
-
* in must exist in the target object. This is regardless whether or not
|
|
1043
|
+
*
|
|
1044
|
+
* When used in conjunction with `any`, at least one key that is passed
|
|
1045
|
+
* in must exist in the target object. This is regardless whether or not
|
|
997
1046
|
* the `have` or `contain` qualifiers are used. Note, either `any` or `all`
|
|
998
1047
|
* should be used in the assertion. If neither are used, the assertion is
|
|
999
1048
|
* defaulted to `all`.
|
|
1000
|
-
*
|
|
1001
|
-
* When both `all` and `contain` are used, the target object must have at
|
|
1049
|
+
*
|
|
1050
|
+
* When both `all` and `contain` are used, the target object must have at
|
|
1002
1051
|
* least all of the passed-in keys but may have more keys not listed.
|
|
1003
|
-
*
|
|
1052
|
+
*
|
|
1004
1053
|
* When both `all` and `have` are used, the target object must both contain
|
|
1005
1054
|
* all of the passed-in keys AND the number of keys in the target object must
|
|
1006
|
-
* match the number of keys passed in (in other words, a target object must
|
|
1055
|
+
* match the number of keys passed in (in other words, a target object must
|
|
1007
1056
|
* have all and only all of the passed-in keys).
|
|
1008
|
-
*
|
|
1057
|
+
*
|
|
1009
1058
|
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo', 'baz');
|
|
1010
1059
|
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo');
|
|
1011
1060
|
* expect({ foo: 1, bar: 2 }).to.contain.any.keys('bar', 'baz');
|
|
1012
1061
|
* expect({ foo: 1, bar: 2 }).to.contain.any.keys(['foo']);
|
|
1013
1062
|
* expect({ foo: 1, bar: 2 }).to.contain.any.keys({'foo': 6});
|
|
1014
1063
|
* expect({ foo: 1, bar: 2 }).to.have.all.keys(['bar', 'foo']);
|
|
1015
|
-
* expect({ foo: 1, bar: 2 }).to.have.all.keys({'bar': 6, 'foo'
|
|
1064
|
+
* expect({ foo: 1, bar: 2 }).to.have.all.keys({'bar': 6, 'foo': 7});
|
|
1016
1065
|
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys(['bar', 'foo']);
|
|
1017
1066
|
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys([{'bar': 6}}]);
|
|
1018
1067
|
*
|
package/lib/chai.js
CHANGED
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"Veselin Todorov <hi@vesln.com>",
|
|
18
18
|
"John Firebaugh <john.firebaugh@gmail.com>"
|
|
19
19
|
],
|
|
20
|
-
"version": "2.
|
|
20
|
+
"version": "2.3.0",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
23
|
"url": "https://github.com/chaijs/chai"
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"karma-mocha": "*",
|
|
43
43
|
"karma-sauce-launcher": "0.2.x",
|
|
44
44
|
"karma-phantomjs-launcher": "0.1.1",
|
|
45
|
+
"karma-firefox-launcher": "^0.1.4",
|
|
45
46
|
"mocha": "1.21.x",
|
|
46
47
|
"istanbul": "0.2.x"
|
|
47
48
|
}
|