chai 4.3.10 → 5.0.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/CONTRIBUTING.md +7 -1
- package/README.md +3 -43
- package/chai.js +3802 -11206
- package/index.js +1 -1
- package/{karma.conf.js → karma.conf.cjs} +4 -3
- package/lib/chai/assertion.js +153 -163
- package/lib/chai/config.js +28 -2
- package/lib/chai/core/assertions.js +3631 -3634
- package/lib/chai/interface/assert.js +3036 -3042
- package/lib/chai/interface/expect.js +40 -37
- package/lib/chai/interface/should.js +203 -204
- package/lib/chai/utils/addChainableMethod.js +8 -8
- package/lib/chai/utils/addLengthGuard.js +3 -3
- package/lib/chai/utils/addMethod.js +8 -8
- package/lib/chai/utils/addProperty.js +7 -7
- package/lib/chai/utils/compareByInspect.js +3 -3
- package/lib/chai/utils/expectTypes.js +5 -5
- package/lib/chai/utils/flag.js +2 -2
- package/lib/chai/utils/getActual.js +2 -2
- package/lib/chai/utils/getMessage.js +5 -5
- package/lib/chai/utils/getOperator.js +5 -6
- package/lib/chai/utils/getOwnEnumerableProperties.js +3 -3
- package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +2 -2
- package/lib/chai/utils/getProperties.js +2 -2
- package/lib/chai/utils/index.js +30 -34
- package/lib/chai/utils/inspect.js +4 -7
- package/lib/chai/utils/isNaN.js +2 -2
- package/lib/chai/utils/isProxyEnabled.js +3 -3
- package/lib/chai/utils/objDisplay.js +4 -4
- package/lib/chai/utils/overwriteChainableMethod.js +6 -6
- package/lib/chai/utils/overwriteMethod.js +8 -8
- package/lib/chai/utils/overwriteProperty.js +7 -7
- package/lib/chai/utils/proxify.js +7 -7
- package/lib/chai/utils/test.js +3 -3
- package/lib/chai/utils/transferFlags.js +2 -2
- package/lib/chai/utils/type-detect.js +16 -0
- package/lib/chai.js +27 -32
- package/package.json +24 -28
- package/register-assert.cjs +3 -0
- package/register-assert.js +3 -1
- package/register-expect.cjs +3 -0
- package/register-expect.js +3 -1
- package/register-should.cjs +3 -0
- package/register-should.js +3 -1
- package/web-test-runner.config.js +17 -0
- package/index.mjs +0 -14
|
@@ -4,44 +4,47 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
7
|
+
import * as chai from '../../../index.js';
|
|
8
|
+
import {Assertion} from '../assertion.js';
|
|
9
|
+
import {AssertionError} from 'assertion-error';
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* Throw a failure.
|
|
17
|
-
*
|
|
18
|
-
* expect.fail();
|
|
19
|
-
* expect.fail("custom error message");
|
|
20
|
-
* expect.fail(1, 2);
|
|
21
|
-
* expect.fail(1, 2, "custom error message");
|
|
22
|
-
* expect.fail(1, 2, "custom error message", ">");
|
|
23
|
-
* expect.fail(1, 2, undefined, ">");
|
|
24
|
-
*
|
|
25
|
-
* @name fail
|
|
26
|
-
* @param {Mixed} actual
|
|
27
|
-
* @param {Mixed} expected
|
|
28
|
-
* @param {String} message
|
|
29
|
-
* @param {String} operator
|
|
30
|
-
* @namespace BDD
|
|
31
|
-
* @api public
|
|
32
|
-
*/
|
|
11
|
+
function expect(val, message) {
|
|
12
|
+
return new Assertion(val, message);
|
|
13
|
+
}
|
|
33
14
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
15
|
+
export {expect};
|
|
16
|
+
/**
|
|
17
|
+
* ### .fail([message])
|
|
18
|
+
* ### .fail(actual, expected, [message], [operator])
|
|
19
|
+
*
|
|
20
|
+
* Throw a failure.
|
|
21
|
+
*
|
|
22
|
+
* expect.fail();
|
|
23
|
+
* expect.fail("custom error message");
|
|
24
|
+
* expect.fail(1, 2);
|
|
25
|
+
* expect.fail(1, 2, "custom error message");
|
|
26
|
+
* expect.fail(1, 2, "custom error message", ">");
|
|
27
|
+
* expect.fail(1, 2, undefined, ">");
|
|
28
|
+
*
|
|
29
|
+
* @name fail
|
|
30
|
+
* @param {Mixed} actual
|
|
31
|
+
* @param {Mixed} expected
|
|
32
|
+
* @param {String} message
|
|
33
|
+
* @param {String} operator
|
|
34
|
+
* @namespace BDD
|
|
35
|
+
* @api public
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
expect.fail = function (actual, expected, message, operator) {
|
|
39
|
+
if (arguments.length < 2) {
|
|
40
|
+
message = actual;
|
|
41
|
+
actual = undefined;
|
|
42
|
+
}
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
44
|
+
message = message || 'expect.fail()';
|
|
45
|
+
throw new AssertionError(message, {
|
|
46
|
+
actual: actual
|
|
47
|
+
, expected: expected
|
|
48
|
+
, operator: operator
|
|
49
|
+
}, chai.expect.fail);
|
|
47
50
|
};
|
|
@@ -4,216 +4,215 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return new Assertion(this, null, shouldGetter);
|
|
7
|
+
import {Assertion} from '../assertion.js';
|
|
8
|
+
import {AssertionError} from 'assertion-error';
|
|
9
|
+
|
|
10
|
+
function loadShould () {
|
|
11
|
+
// explicitly define this method as function as to have it's name to include as `ssfi`
|
|
12
|
+
function shouldGetter() {
|
|
13
|
+
if (this instanceof String
|
|
14
|
+
|| this instanceof Number
|
|
15
|
+
|| this instanceof Boolean
|
|
16
|
+
|| typeof Symbol === 'function' && this instanceof Symbol
|
|
17
|
+
|| typeof BigInt === 'function' && this instanceof BigInt) {
|
|
18
|
+
return new Assertion(this.valueOf(), null, shouldGetter);
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// modify Object.prototype to have `should`
|
|
37
|
-
Object.defineProperty(Object.prototype, 'should', {
|
|
38
|
-
set: shouldSetter
|
|
39
|
-
, get: shouldGetter
|
|
40
|
-
, configurable: true
|
|
20
|
+
return new Assertion(this, null, shouldGetter);
|
|
21
|
+
}
|
|
22
|
+
function shouldSetter(value) {
|
|
23
|
+
// See https://github.com/chaijs/chai/issues/86: this makes
|
|
24
|
+
// `whatever.should = someValue` actually set `someValue`, which is
|
|
25
|
+
// especially useful for `global.should = require('chai').should()`.
|
|
26
|
+
//
|
|
27
|
+
// Note that we have to use [[DefineProperty]] instead of [[Put]]
|
|
28
|
+
// since otherwise we would trigger this very setter!
|
|
29
|
+
Object.defineProperty(this, 'should', {
|
|
30
|
+
value: value,
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true
|
|
41
34
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, should.fail);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* ### .equal(actual, expected, [message])
|
|
84
|
-
*
|
|
85
|
-
* Asserts non-strict equality (`==`) of `actual` and `expected`.
|
|
86
|
-
*
|
|
87
|
-
* should.equal(3, '3', '== coerces values to strings');
|
|
88
|
-
*
|
|
89
|
-
* @name equal
|
|
90
|
-
* @param {Mixed} actual
|
|
91
|
-
* @param {Mixed} expected
|
|
92
|
-
* @param {String} message
|
|
93
|
-
* @namespace Should
|
|
94
|
-
* @api public
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
should.equal = function (val1, val2, msg) {
|
|
98
|
-
new Assertion(val1, msg).to.equal(val2);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* ### .throw(function, [constructor/string/regexp], [string/regexp], [message])
|
|
103
|
-
*
|
|
104
|
-
* Asserts that `function` will throw an error that is an instance of
|
|
105
|
-
* `constructor`, or alternately that it will throw an error with message
|
|
106
|
-
* matching `regexp`.
|
|
107
|
-
*
|
|
108
|
-
* should.throw(fn, 'function throws a reference error');
|
|
109
|
-
* should.throw(fn, /function throws a reference error/);
|
|
110
|
-
* should.throw(fn, ReferenceError);
|
|
111
|
-
* should.throw(fn, ReferenceError, 'function throws a reference error');
|
|
112
|
-
* should.throw(fn, ReferenceError, /function throws a reference error/);
|
|
113
|
-
*
|
|
114
|
-
* @name throw
|
|
115
|
-
* @alias Throw
|
|
116
|
-
* @param {Function} function
|
|
117
|
-
* @param {ErrorConstructor} constructor
|
|
118
|
-
* @param {RegExp} regexp
|
|
119
|
-
* @param {String} message
|
|
120
|
-
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
121
|
-
* @namespace Should
|
|
122
|
-
* @api public
|
|
123
|
-
*/
|
|
124
|
-
|
|
125
|
-
should.Throw = function (fn, errt, errs, msg) {
|
|
126
|
-
new Assertion(fn, msg).to.Throw(errt, errs);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* ### .exist
|
|
131
|
-
*
|
|
132
|
-
* Asserts that the target is neither `null` nor `undefined`.
|
|
133
|
-
*
|
|
134
|
-
* var foo = 'hi';
|
|
135
|
-
*
|
|
136
|
-
* should.exist(foo, 'foo exists');
|
|
137
|
-
*
|
|
138
|
-
* @name exist
|
|
139
|
-
* @namespace Should
|
|
140
|
-
* @api public
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
should.exist = function (val, msg) {
|
|
144
|
-
new Assertion(val, msg).to.exist;
|
|
35
|
+
}
|
|
36
|
+
// modify Object.prototype to have `should`
|
|
37
|
+
Object.defineProperty(Object.prototype, 'should', {
|
|
38
|
+
set: shouldSetter
|
|
39
|
+
, get: shouldGetter
|
|
40
|
+
, configurable: true
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
var should = {};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* ### .fail([message])
|
|
47
|
+
* ### .fail(actual, expected, [message], [operator])
|
|
48
|
+
*
|
|
49
|
+
* Throw a failure.
|
|
50
|
+
*
|
|
51
|
+
* should.fail();
|
|
52
|
+
* should.fail("custom error message");
|
|
53
|
+
* should.fail(1, 2);
|
|
54
|
+
* should.fail(1, 2, "custom error message");
|
|
55
|
+
* should.fail(1, 2, "custom error message", ">");
|
|
56
|
+
* should.fail(1, 2, undefined, ">");
|
|
57
|
+
*
|
|
58
|
+
*
|
|
59
|
+
* @name fail
|
|
60
|
+
* @param {Mixed} actual
|
|
61
|
+
* @param {Mixed} expected
|
|
62
|
+
* @param {String} message
|
|
63
|
+
* @param {String} operator
|
|
64
|
+
* @namespace BDD
|
|
65
|
+
* @api public
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
should.fail = function (actual, expected, message, operator) {
|
|
69
|
+
if (arguments.length < 2) {
|
|
70
|
+
message = actual;
|
|
71
|
+
actual = undefined;
|
|
145
72
|
}
|
|
146
73
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
* `constructor`, or alternately that it will not throw an error with message
|
|
174
|
-
* matching `regexp`.
|
|
175
|
-
*
|
|
176
|
-
* should.not.throw(fn, Error, 'function does not throw');
|
|
177
|
-
*
|
|
178
|
-
* @name not.throw
|
|
179
|
-
* @alias not.Throw
|
|
180
|
-
* @param {Function} function
|
|
181
|
-
* @param {ErrorConstructor} constructor
|
|
182
|
-
* @param {RegExp} regexp
|
|
183
|
-
* @param {String} message
|
|
184
|
-
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
185
|
-
* @namespace Should
|
|
186
|
-
* @api public
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
should.not.Throw = function (fn, errt, errs, msg) {
|
|
190
|
-
new Assertion(fn, msg).to.not.Throw(errt, errs);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* ### .not.exist
|
|
195
|
-
*
|
|
196
|
-
* Asserts that the target is neither `null` nor `undefined`.
|
|
197
|
-
*
|
|
198
|
-
* var bar = null;
|
|
199
|
-
*
|
|
200
|
-
* should.not.exist(bar, 'bar does not exist');
|
|
201
|
-
*
|
|
202
|
-
* @name not.exist
|
|
203
|
-
* @namespace Should
|
|
204
|
-
* @api public
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
should.not.exist = function (val, msg) {
|
|
208
|
-
new Assertion(val, msg).to.not.exist;
|
|
209
|
-
}
|
|
74
|
+
message = message || 'should.fail()';
|
|
75
|
+
throw new AssertionError(message, {
|
|
76
|
+
actual: actual
|
|
77
|
+
, expected: expected
|
|
78
|
+
, operator: operator
|
|
79
|
+
}, should.fail);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* ### .equal(actual, expected, [message])
|
|
84
|
+
*
|
|
85
|
+
* Asserts non-strict equality (`==`) of `actual` and `expected`.
|
|
86
|
+
*
|
|
87
|
+
* should.equal(3, '3', '== coerces values to strings');
|
|
88
|
+
*
|
|
89
|
+
* @name equal
|
|
90
|
+
* @param {Mixed} actual
|
|
91
|
+
* @param {Mixed} expected
|
|
92
|
+
* @param {String} message
|
|
93
|
+
* @namespace Should
|
|
94
|
+
* @api public
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
should.equal = function (val1, val2, msg) {
|
|
98
|
+
new Assertion(val1, msg).to.equal(val2);
|
|
99
|
+
};
|
|
210
100
|
|
|
211
|
-
|
|
212
|
-
|
|
101
|
+
/**
|
|
102
|
+
* ### .throw(function, [constructor/string/regexp], [string/regexp], [message])
|
|
103
|
+
*
|
|
104
|
+
* Asserts that `function` will throw an error that is an instance of
|
|
105
|
+
* `constructor`, or alternately that it will throw an error with message
|
|
106
|
+
* matching `regexp`.
|
|
107
|
+
*
|
|
108
|
+
* should.throw(fn, 'function throws a reference error');
|
|
109
|
+
* should.throw(fn, /function throws a reference error/);
|
|
110
|
+
* should.throw(fn, ReferenceError);
|
|
111
|
+
* should.throw(fn, ReferenceError, 'function throws a reference error');
|
|
112
|
+
* should.throw(fn, ReferenceError, /function throws a reference error/);
|
|
113
|
+
*
|
|
114
|
+
* @name throw
|
|
115
|
+
* @alias Throw
|
|
116
|
+
* @param {Function} function
|
|
117
|
+
* @param {ErrorConstructor} constructor
|
|
118
|
+
* @param {RegExp} regexp
|
|
119
|
+
* @param {String} message
|
|
120
|
+
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
121
|
+
* @namespace Should
|
|
122
|
+
* @api public
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
should.Throw = function (fn, errt, errs, msg) {
|
|
126
|
+
new Assertion(fn, msg).to.Throw(errt, errs);
|
|
127
|
+
};
|
|
213
128
|
|
|
214
|
-
|
|
129
|
+
/**
|
|
130
|
+
* ### .exist
|
|
131
|
+
*
|
|
132
|
+
* Asserts that the target is neither `null` nor `undefined`.
|
|
133
|
+
*
|
|
134
|
+
* var foo = 'hi';
|
|
135
|
+
*
|
|
136
|
+
* should.exist(foo, 'foo exists');
|
|
137
|
+
*
|
|
138
|
+
* @name exist
|
|
139
|
+
* @namespace Should
|
|
140
|
+
* @api public
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
should.exist = function (val, msg) {
|
|
144
|
+
new Assertion(val, msg).to.exist;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// negation
|
|
148
|
+
should.not = {}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* ### .not.equal(actual, expected, [message])
|
|
152
|
+
*
|
|
153
|
+
* Asserts non-strict inequality (`!=`) of `actual` and `expected`.
|
|
154
|
+
*
|
|
155
|
+
* should.not.equal(3, 4, 'these numbers are not equal');
|
|
156
|
+
*
|
|
157
|
+
* @name not.equal
|
|
158
|
+
* @param {Mixed} actual
|
|
159
|
+
* @param {Mixed} expected
|
|
160
|
+
* @param {String} message
|
|
161
|
+
* @namespace Should
|
|
162
|
+
* @api public
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
should.not.equal = function (val1, val2, msg) {
|
|
166
|
+
new Assertion(val1, msg).to.not.equal(val2);
|
|
215
167
|
};
|
|
216
168
|
|
|
217
|
-
|
|
218
|
-
|
|
169
|
+
/**
|
|
170
|
+
* ### .throw(function, [constructor/regexp], [message])
|
|
171
|
+
*
|
|
172
|
+
* Asserts that `function` will _not_ throw an error that is an instance of
|
|
173
|
+
* `constructor`, or alternately that it will not throw an error with message
|
|
174
|
+
* matching `regexp`.
|
|
175
|
+
*
|
|
176
|
+
* should.not.throw(fn, Error, 'function does not throw');
|
|
177
|
+
*
|
|
178
|
+
* @name not.throw
|
|
179
|
+
* @alias not.Throw
|
|
180
|
+
* @param {Function} function
|
|
181
|
+
* @param {ErrorConstructor} constructor
|
|
182
|
+
* @param {RegExp} regexp
|
|
183
|
+
* @param {String} message
|
|
184
|
+
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
185
|
+
* @namespace Should
|
|
186
|
+
* @api public
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
should.not.Throw = function (fn, errt, errs, msg) {
|
|
190
|
+
new Assertion(fn, msg).to.not.Throw(errt, errs);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* ### .not.exist
|
|
195
|
+
*
|
|
196
|
+
* Asserts that the target is neither `null` nor `undefined`.
|
|
197
|
+
*
|
|
198
|
+
* var bar = null;
|
|
199
|
+
*
|
|
200
|
+
* should.not.exist(bar, 'bar does not exist');
|
|
201
|
+
*
|
|
202
|
+
* @name not.exist
|
|
203
|
+
* @namespace Should
|
|
204
|
+
* @api public
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
should.not.exist = function (val, msg) {
|
|
208
|
+
new Assertion(val, msg).to.not.exist;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
should['throw'] = should['Throw'];
|
|
212
|
+
should.not['throw'] = should.not['Throw'];
|
|
213
|
+
|
|
214
|
+
return should;
|
|
219
215
|
};
|
|
216
|
+
|
|
217
|
+
export const should = loadShould;
|
|
218
|
+
export const Should = loadShould;
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
* Module dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
import {Assertion} from '../assertion.js';
|
|
12
|
+
import {addLengthGuard} from './addLengthGuard.js';
|
|
13
|
+
import {flag} from './flag.js';
|
|
14
|
+
import {proxify} from './proxify.js';
|
|
15
|
+
import {transferFlags} from './transferFlags.js';
|
|
16
16
|
|
|
17
17
|
/*!
|
|
18
18
|
* Module variables
|
|
@@ -70,7 +70,7 @@ var call = Function.prototype.call,
|
|
|
70
70
|
* @api public
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
export function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
74
74
|
if (typeof chainingBehavior !== 'function') {
|
|
75
75
|
chainingBehavior = function () { };
|
|
76
76
|
}
|
|
@@ -115,7 +115,7 @@ module.exports = function addChainableMethod(ctx, name, method, chainingBehavior
|
|
|
115
115
|
return result;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
var newAssertion = new
|
|
118
|
+
var newAssertion = new Assertion();
|
|
119
119
|
transferFlags(this, newAssertion);
|
|
120
120
|
return newAssertion;
|
|
121
121
|
};
|
|
@@ -149,4 +149,4 @@ module.exports = function addChainableMethod(ctx, name, method, chainingBehavior
|
|
|
149
149
|
}
|
|
150
150
|
, configurable: true
|
|
151
151
|
});
|
|
152
|
-
}
|
|
152
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
4
|
* Chai - addLengthGuard utility
|
|
@@ -40,7 +40,7 @@ var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
|
|
|
40
40
|
* @name addLengthGuard
|
|
41
41
|
*/
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
export function addLengthGuard(fn, assertionName, isChainable) {
|
|
44
44
|
if (!fnLengthDesc.configurable) return fn;
|
|
45
45
|
|
|
46
46
|
Object.defineProperty(fn, 'length', {
|
|
@@ -57,4 +57,4 @@ module.exports = function addLengthGuard (fn, assertionName, isChainable) {
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
return fn;
|
|
60
|
-
}
|
|
60
|
+
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import {addLengthGuard} from './addLengthGuard.js';
|
|
8
|
+
import {flag} from './flag.js';
|
|
9
|
+
import {proxify} from './proxify.js';
|
|
10
|
+
import {transferFlags} from './transferFlags.js';
|
|
11
|
+
import {Assertion} from '../assertion.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* ### .addMethod(ctx, name, method)
|
|
@@ -36,7 +36,7 @@ var transferFlags = require('./transferFlags');
|
|
|
36
36
|
* @api public
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
export function addMethod(ctx, name, method) {
|
|
40
40
|
var methodWrapper = function () {
|
|
41
41
|
// Setting the `ssfi` flag to `methodWrapper` causes this function to be the
|
|
42
42
|
// starting point for removing implementation frames from the stack trace of
|
|
@@ -58,11 +58,11 @@ module.exports = function addMethod(ctx, name, method) {
|
|
|
58
58
|
if (result !== undefined)
|
|
59
59
|
return result;
|
|
60
60
|
|
|
61
|
-
var newAssertion = new
|
|
61
|
+
var newAssertion = new Assertion();
|
|
62
62
|
transferFlags(this, newAssertion);
|
|
63
63
|
return newAssertion;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
addLengthGuard(methodWrapper, name, false);
|
|
67
67
|
ctx[name] = proxify(methodWrapper, name);
|
|
68
|
-
}
|
|
68
|
+
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import {Assertion} from '../assertion.js';
|
|
8
|
+
import {flag} from './flag.js';
|
|
9
|
+
import {isProxyEnabled} from './isProxyEnabled.js';
|
|
10
|
+
import {transferFlags} from './transferFlags.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* ### .addProperty(ctx, name, getter)
|
|
@@ -35,7 +35,7 @@ var transferFlags = require('./transferFlags');
|
|
|
35
35
|
* @api public
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
export function addProperty(ctx, name, getter) {
|
|
39
39
|
getter = getter === undefined ? function () {} : getter;
|
|
40
40
|
|
|
41
41
|
Object.defineProperty(ctx, name,
|
|
@@ -63,10 +63,10 @@ module.exports = function addProperty(ctx, name, getter) {
|
|
|
63
63
|
if (result !== undefined)
|
|
64
64
|
return result;
|
|
65
65
|
|
|
66
|
-
var newAssertion = new
|
|
66
|
+
var newAssertion = new Assertion();
|
|
67
67
|
transferFlags(this, newAssertion);
|
|
68
68
|
return newAssertion;
|
|
69
69
|
}
|
|
70
70
|
, configurable: true
|
|
71
71
|
});
|
|
72
|
-
}
|
|
72
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Module dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
import {inspect} from './inspect.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* ### .compareByInspect(mixed, mixed)
|
|
@@ -26,6 +26,6 @@ var inspect = require('./inspect');
|
|
|
26
26
|
* @api public
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
export function compareByInspect(a, b) {
|
|
30
30
|
return inspect(a) < inspect(b) ? -1 : 1;
|
|
31
|
-
}
|
|
31
|
+
}
|