chai 5.0.3 → 5.1.1
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/README.md +3 -3
- package/chai.js +94 -220
- package/eslint.config.js +12 -0
- package/lib/chai/assertion.js +30 -31
- package/lib/chai/config.js +18 -24
- package/lib/chai/core/assertions.js +253 -223
- package/lib/chai/interface/assert.js +574 -670
- package/lib/chai/interface/expect.js +12 -7
- package/lib/chai/interface/should.js +43 -40
- package/lib/chai/utils/addChainableMethod.js +6 -11
- package/lib/chai/utils/addLengthGuard.js +3 -3
- package/lib/chai/utils/addMethod.js +5 -6
- package/lib/chai/utils/addProperty.js +5 -6
- package/lib/chai/utils/compareByInspect.js +4 -9
- package/lib/chai/utils/expectTypes.js +7 -8
- package/lib/chai/utils/flag.js +5 -5
- package/lib/chai/utils/getActual.js +3 -3
- package/lib/chai/utils/getEnumerableProperties.js +2 -3
- package/lib/chai/utils/getMessage.js +4 -8
- package/lib/chai/utils/getOperator.js +8 -4
- package/lib/chai/utils/getOwnEnumerableProperties.js +2 -7
- package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +2 -3
- package/lib/chai/utils/getProperties.js +5 -3
- package/lib/chai/utils/index.js +42 -109
- package/lib/chai/utils/inspect.js +5 -4
- package/lib/chai/utils/isNaN.js +3 -3
- package/lib/chai/utils/isProxyEnabled.js +1 -1
- package/lib/chai/utils/objDisplay.js +2 -7
- package/lib/chai/utils/overwriteChainableMethod.js +7 -8
- package/lib/chai/utils/overwriteMethod.js +10 -11
- package/lib/chai/utils/overwriteProperty.js +10 -12
- package/lib/chai/utils/proxify.js +9 -9
- package/lib/chai/utils/test.js +3 -7
- package/lib/chai/utils/transferFlags.js +4 -6
- package/lib/chai/utils/type-detect.js +4 -0
- package/lib/chai.js +9 -31
- package/package.json +6 -3
- package/web-test-runner.config.js +4 -1
|
@@ -8,11 +8,17 @@ import * as chai from '../../../index.js';
|
|
|
8
8
|
import {Assertion} from '../assertion.js';
|
|
9
9
|
import {AssertionError} from 'assertion-error';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @param {unknown} val
|
|
13
|
+
* @param {string} message
|
|
14
|
+
* @returns {Assertion}
|
|
15
|
+
*/
|
|
11
16
|
function expect(val, message) {
|
|
12
17
|
return new Assertion(val, message);
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
export {expect};
|
|
21
|
+
|
|
16
22
|
/**
|
|
17
23
|
* ### .fail([message])
|
|
18
24
|
* ### .fail(actual, expected, [message], [operator])
|
|
@@ -27,14 +33,13 @@ export {expect};
|
|
|
27
33
|
* expect.fail(1, 2, undefined, ">");
|
|
28
34
|
*
|
|
29
35
|
* @name fail
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
34
|
-
* @namespace
|
|
35
|
-
* @
|
|
36
|
+
* @param {unknown} actual
|
|
37
|
+
* @param {unknown} expected
|
|
38
|
+
* @param {string} message
|
|
39
|
+
* @param {string} operator
|
|
40
|
+
* @namespace expect
|
|
41
|
+
* @public
|
|
36
42
|
*/
|
|
37
|
-
|
|
38
43
|
expect.fail = function (actual, expected, message, operator) {
|
|
39
44
|
if (arguments.length < 2) {
|
|
40
45
|
message = actual;
|
|
@@ -7,8 +7,14 @@
|
|
|
7
7
|
import {Assertion} from '../assertion.js';
|
|
8
8
|
import {AssertionError} from 'assertion-error';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @returns {void}
|
|
12
|
+
*/
|
|
10
13
|
function loadShould () {
|
|
11
14
|
// explicitly define this method as function as to have it's name to include as `ssfi`
|
|
15
|
+
/**
|
|
16
|
+
* @returns {Assertion}
|
|
17
|
+
*/
|
|
12
18
|
function shouldGetter() {
|
|
13
19
|
if (this instanceof String
|
|
14
20
|
|| this instanceof Number
|
|
@@ -19,6 +25,9 @@ function loadShould () {
|
|
|
19
25
|
}
|
|
20
26
|
return new Assertion(this, null, shouldGetter);
|
|
21
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @param {unknown} value
|
|
30
|
+
*/
|
|
22
31
|
function shouldSetter(value) {
|
|
23
32
|
// See https://github.com/chaijs/chai/issues/86: this makes
|
|
24
33
|
// `whatever.should = someValue` actually set `someValue`, which is
|
|
@@ -55,16 +64,14 @@ function loadShould () {
|
|
|
55
64
|
* should.fail(1, 2, "custom error message", ">");
|
|
56
65
|
* should.fail(1, 2, undefined, ">");
|
|
57
66
|
*
|
|
58
|
-
*
|
|
59
67
|
* @name fail
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
68
|
+
* @param {unknown} actual
|
|
69
|
+
* @param {unknown} expected
|
|
70
|
+
* @param {string} message
|
|
71
|
+
* @param {string} operator
|
|
64
72
|
* @namespace BDD
|
|
65
|
-
* @
|
|
73
|
+
* @public
|
|
66
74
|
*/
|
|
67
|
-
|
|
68
75
|
should.fail = function (actual, expected, message, operator) {
|
|
69
76
|
if (arguments.length < 2) {
|
|
70
77
|
message = actual;
|
|
@@ -87,15 +94,14 @@ function loadShould () {
|
|
|
87
94
|
* should.equal(3, '3', '== coerces values to strings');
|
|
88
95
|
*
|
|
89
96
|
* @name equal
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {
|
|
97
|
+
* @param {unknown} actual
|
|
98
|
+
* @param {unknown} expected
|
|
99
|
+
* @param {string} message
|
|
93
100
|
* @namespace Should
|
|
94
|
-
* @
|
|
101
|
+
* @public
|
|
95
102
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
new Assertion(val1, msg).to.equal(val2);
|
|
103
|
+
should.equal = function (actual, expected, message) {
|
|
104
|
+
new Assertion(actual, message).to.equal(expected);
|
|
99
105
|
};
|
|
100
106
|
|
|
101
107
|
/**
|
|
@@ -113,15 +119,14 @@ function loadShould () {
|
|
|
113
119
|
*
|
|
114
120
|
* @name throw
|
|
115
121
|
* @alias Throw
|
|
116
|
-
* @param {Function}
|
|
117
|
-
* @param {
|
|
118
|
-
* @param {RegExp}
|
|
119
|
-
* @param {
|
|
122
|
+
* @param {Function} fn
|
|
123
|
+
* @param {Error} errt
|
|
124
|
+
* @param {RegExp} errs
|
|
125
|
+
* @param {string} msg
|
|
120
126
|
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
121
127
|
* @namespace Should
|
|
122
|
-
* @
|
|
128
|
+
* @public
|
|
123
129
|
*/
|
|
124
|
-
|
|
125
130
|
should.Throw = function (fn, errt, errs, msg) {
|
|
126
131
|
new Assertion(fn, msg).to.Throw(errt, errs);
|
|
127
132
|
};
|
|
@@ -132,14 +137,14 @@ function loadShould () {
|
|
|
132
137
|
* Asserts that the target is neither `null` nor `undefined`.
|
|
133
138
|
*
|
|
134
139
|
* var foo = 'hi';
|
|
135
|
-
*
|
|
136
140
|
* should.exist(foo, 'foo exists');
|
|
137
141
|
*
|
|
142
|
+
* @param {unknown} val
|
|
143
|
+
* @param {string} msg
|
|
138
144
|
* @name exist
|
|
139
145
|
* @namespace Should
|
|
140
|
-
* @
|
|
146
|
+
* @public
|
|
141
147
|
*/
|
|
142
|
-
|
|
143
148
|
should.exist = function (val, msg) {
|
|
144
149
|
new Assertion(val, msg).to.exist;
|
|
145
150
|
}
|
|
@@ -155,15 +160,14 @@ function loadShould () {
|
|
|
155
160
|
* should.not.equal(3, 4, 'these numbers are not equal');
|
|
156
161
|
*
|
|
157
162
|
* @name not.equal
|
|
158
|
-
* @param {
|
|
159
|
-
* @param {
|
|
160
|
-
* @param {
|
|
163
|
+
* @param {unknown} actual
|
|
164
|
+
* @param {unknown} expected
|
|
165
|
+
* @param {string} msg
|
|
161
166
|
* @namespace Should
|
|
162
|
-
* @
|
|
167
|
+
* @public
|
|
163
168
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
new Assertion(val1, msg).to.not.equal(val2);
|
|
169
|
+
should.not.equal = function (actual, expected, msg) {
|
|
170
|
+
new Assertion(actual, msg).to.not.equal(expected);
|
|
167
171
|
};
|
|
168
172
|
|
|
169
173
|
/**
|
|
@@ -177,15 +181,14 @@ function loadShould () {
|
|
|
177
181
|
*
|
|
178
182
|
* @name not.throw
|
|
179
183
|
* @alias not.Throw
|
|
180
|
-
* @param {Function}
|
|
181
|
-
* @param {
|
|
182
|
-
* @param {RegExp}
|
|
183
|
-
* @param {
|
|
184
|
+
* @param {Function} fn
|
|
185
|
+
* @param {Error} errt
|
|
186
|
+
* @param {RegExp} errs
|
|
187
|
+
* @param {string} msg
|
|
184
188
|
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
185
189
|
* @namespace Should
|
|
186
|
-
* @
|
|
190
|
+
* @public
|
|
187
191
|
*/
|
|
188
|
-
|
|
189
192
|
should.not.Throw = function (fn, errt, errs, msg) {
|
|
190
193
|
new Assertion(fn, msg).to.not.Throw(errt, errs);
|
|
191
194
|
};
|
|
@@ -196,14 +199,14 @@ function loadShould () {
|
|
|
196
199
|
* Asserts that the target is neither `null` nor `undefined`.
|
|
197
200
|
*
|
|
198
201
|
* var bar = null;
|
|
199
|
-
*
|
|
200
202
|
* should.not.exist(bar, 'bar does not exist');
|
|
201
203
|
*
|
|
202
|
-
* @name not.exist
|
|
203
204
|
* @namespace Should
|
|
204
|
-
* @
|
|
205
|
+
* @name not.exist
|
|
206
|
+
* @param {unknown} val
|
|
207
|
+
* @param {string} msg
|
|
208
|
+
* @public
|
|
205
209
|
*/
|
|
206
|
-
|
|
207
210
|
should.not.exist = function (val, msg) {
|
|
208
211
|
new Assertion(val, msg).to.not.exist;
|
|
209
212
|
}
|
|
@@ -4,17 +4,13 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
/*!
|
|
8
|
-
* Module dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
7
|
import {Assertion} from '../assertion.js';
|
|
12
8
|
import {addLengthGuard} from './addLengthGuard.js';
|
|
13
9
|
import {flag} from './flag.js';
|
|
14
10
|
import {proxify} from './proxify.js';
|
|
15
11
|
import {transferFlags} from './transferFlags.js';
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
/**
|
|
18
14
|
* Module variables
|
|
19
15
|
*/
|
|
20
16
|
|
|
@@ -47,8 +43,8 @@ var call = Function.prototype.call,
|
|
|
47
43
|
* Adds a method to an object, such that the method can also be chained.
|
|
48
44
|
*
|
|
49
45
|
* utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
|
|
50
|
-
*
|
|
51
|
-
*
|
|
46
|
+
* var obj = utils.flag(this, 'object');
|
|
47
|
+
* new chai.Assertion(obj).to.be.equal(str);
|
|
52
48
|
* });
|
|
53
49
|
*
|
|
54
50
|
* Can also be accessed directly from `chai.Assertion`.
|
|
@@ -61,15 +57,14 @@ var call = Function.prototype.call,
|
|
|
61
57
|
* expect(fooStr).to.be.foo('bar');
|
|
62
58
|
* expect(fooStr).to.be.foo.equal('foo');
|
|
63
59
|
*
|
|
64
|
-
* @param {
|
|
65
|
-
* @param {
|
|
60
|
+
* @param {object} ctx object to which the method is added
|
|
61
|
+
* @param {string} name of method to add
|
|
66
62
|
* @param {Function} method function to be used for `name`, when called
|
|
67
63
|
* @param {Function} chainingBehavior function to be called every time the property is accessed
|
|
68
64
|
* @namespace Utils
|
|
69
65
|
* @name addChainableMethod
|
|
70
|
-
* @
|
|
66
|
+
* @public
|
|
71
67
|
*/
|
|
72
|
-
|
|
73
68
|
export function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
74
69
|
if (typeof chainingBehavior !== 'function') {
|
|
75
70
|
chainingBehavior = function () { };
|
|
@@ -34,12 +34,12 @@ const fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
|
|
|
34
34
|
* environments is the priority.
|
|
35
35
|
*
|
|
36
36
|
* @param {Function} fn
|
|
37
|
-
* @param {
|
|
38
|
-
* @param {
|
|
37
|
+
* @param {string} assertionName
|
|
38
|
+
* @param {boolean} isChainable
|
|
39
|
+
* @returns {unknown}
|
|
39
40
|
* @namespace Utils
|
|
40
41
|
* @name addLengthGuard
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
43
|
export function addLengthGuard(fn, assertionName, isChainable) {
|
|
44
44
|
if (!fnLengthDesc.configurable) return fn;
|
|
45
45
|
|
|
@@ -16,8 +16,8 @@ import {Assertion} from '../assertion.js';
|
|
|
16
16
|
* Adds a method to the prototype of an object.
|
|
17
17
|
*
|
|
18
18
|
* utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* var obj = utils.flag(this, 'object');
|
|
20
|
+
* new chai.Assertion(obj).to.be.equal(str);
|
|
21
21
|
* });
|
|
22
22
|
*
|
|
23
23
|
* Can also be accessed directly from `chai.Assertion`.
|
|
@@ -28,14 +28,13 @@ import {Assertion} from '../assertion.js';
|
|
|
28
28
|
*
|
|
29
29
|
* expect(fooStr).to.be.foo('bar');
|
|
30
30
|
*
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
31
|
+
* @param {object} ctx object to which the method is added
|
|
32
|
+
* @param {string} name of method to add
|
|
33
33
|
* @param {Function} method function to be used for name
|
|
34
34
|
* @namespace Utils
|
|
35
35
|
* @name addMethod
|
|
36
|
-
* @
|
|
36
|
+
* @public
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
38
|
export function addMethod(ctx, name, method) {
|
|
40
39
|
var methodWrapper = function () {
|
|
41
40
|
// Setting the `ssfi` flag to `methodWrapper` causes this function to be the
|
|
@@ -15,8 +15,8 @@ import {transferFlags} from './transferFlags.js';
|
|
|
15
15
|
* Adds a property to the prototype of an object.
|
|
16
16
|
*
|
|
17
17
|
* utils.addProperty(chai.Assertion.prototype, 'foo', function () {
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* var obj = utils.flag(this, 'object');
|
|
19
|
+
* new chai.Assertion(obj).to.be.instanceof(Foo);
|
|
20
20
|
* });
|
|
21
21
|
*
|
|
22
22
|
* Can also be accessed directly from `chai.Assertion`.
|
|
@@ -27,14 +27,13 @@ import {transferFlags} from './transferFlags.js';
|
|
|
27
27
|
*
|
|
28
28
|
* expect(myFoo).to.be.foo;
|
|
29
29
|
*
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
30
|
+
* @param {object} ctx object to which the property is added
|
|
31
|
+
* @param {string} name of property to add
|
|
32
32
|
* @param {Function} getter function to be used for name
|
|
33
33
|
* @namespace Utils
|
|
34
34
|
* @name addProperty
|
|
35
|
-
* @
|
|
35
|
+
* @public
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
37
|
export function addProperty(ctx, name, getter) {
|
|
39
38
|
getter = getter === undefined ? function () {} : getter;
|
|
40
39
|
|
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
/*!
|
|
8
|
-
* Module dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
7
|
import {inspect} from './inspect.js';
|
|
12
8
|
|
|
13
9
|
/**
|
|
@@ -18,14 +14,13 @@ import {inspect} from './inspect.js';
|
|
|
18
14
|
* and objects with irregular/missing toString can still be sorted without a
|
|
19
15
|
* TypeError.
|
|
20
16
|
*
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
23
|
-
* @returns {
|
|
17
|
+
* @param {unknown} a first element to compare
|
|
18
|
+
* @param {unknown} b second element to compare
|
|
19
|
+
* @returns {number} -1 if 'a' should come before 'b'; otherwise 1
|
|
24
20
|
* @name compareByInspect
|
|
25
21
|
* @namespace Utils
|
|
26
|
-
* @
|
|
22
|
+
* @public
|
|
27
23
|
*/
|
|
28
|
-
|
|
29
24
|
export function compareByInspect(a, b) {
|
|
30
25
|
return inspect(a) < inspect(b) ? -1 : 1;
|
|
31
26
|
}
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import {AssertionError} from 'assertion-error';
|
|
8
|
+
import {flag} from './flag.js';
|
|
9
|
+
import {type} from './type-detect.js';
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* ### .expectTypes(obj, types)
|
|
9
13
|
*
|
|
@@ -11,17 +15,12 @@
|
|
|
11
15
|
*
|
|
12
16
|
* utils.expectTypes(this, ['array', 'object', 'string']);
|
|
13
17
|
*
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {Array}
|
|
18
|
+
* @param {unknown} obj constructed Assertion
|
|
19
|
+
* @param {Array} types A list of allowed types for this assertion
|
|
16
20
|
* @namespace Utils
|
|
17
21
|
* @name expectTypes
|
|
18
|
-
* @
|
|
22
|
+
* @public
|
|
19
23
|
*/
|
|
20
|
-
|
|
21
|
-
import {AssertionError} from 'assertion-error';
|
|
22
|
-
import {flag} from './flag.js';
|
|
23
|
-
import {type} from './type-detect.js';
|
|
24
|
-
|
|
25
24
|
export function expectTypes(obj, types) {
|
|
26
25
|
var flagMsg = flag(obj, 'message');
|
|
27
26
|
var ssfi = flag(obj, 'ssfi');
|
package/lib/chai/utils/flag.js
CHANGED
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
* utils.flag(this, 'foo', 'bar'); // setter
|
|
16
16
|
* utils.flag(this, 'foo'); // getter, returns `bar`
|
|
17
17
|
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
18
|
+
* @param {object} obj object constructed Assertion
|
|
19
|
+
* @param {string} key
|
|
20
|
+
* @param {unknown} value (optional)
|
|
21
21
|
* @namespace Utils
|
|
22
22
|
* @name flag
|
|
23
|
-
* @
|
|
23
|
+
* @returns {unknown | undefined}
|
|
24
|
+
* @private
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
26
|
export function flag(obj, key, value) {
|
|
27
27
|
var flags = obj.__flags || (obj.__flags = Object.create(null));
|
|
28
28
|
if (arguments.length === 3) {
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Returns the `actual` value for an Assertion.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {object} obj object (constructed Assertion)
|
|
13
|
+
* @param {unknown} args chai.Assertion.prototype.assert arguments
|
|
14
|
+
* @returns {unknown}
|
|
14
15
|
* @namespace Utils
|
|
15
16
|
* @name getActual
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
18
|
export function getActual(obj, args) {
|
|
19
19
|
return args.length > 4 ? args[4] : obj._obj;
|
|
20
20
|
}
|
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
* This allows the retrieval of enumerable property names of an object,
|
|
11
11
|
* inherited or not.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {object} object
|
|
14
14
|
* @returns {Array}
|
|
15
15
|
* @namespace Utils
|
|
16
16
|
* @name getEnumerableProperties
|
|
17
|
-
* @
|
|
17
|
+
* @public
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
module.exports = function getEnumerableProperties(object) {
|
|
21
20
|
var result = [];
|
|
22
21
|
for (var name in object) {
|
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
/*!
|
|
8
|
-
* Module dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
7
|
import {flag} from './flag.js';
|
|
12
8
|
import {getActual} from './getActual.js';
|
|
13
9
|
import {objDisplay} from './objDisplay.js';
|
|
@@ -24,13 +20,13 @@ import {objDisplay} from './objDisplay.js';
|
|
|
24
20
|
* - `#{act}` actual value
|
|
25
21
|
* - `#{exp}` expected value
|
|
26
22
|
*
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
23
|
+
* @param {object} obj object (constructed Assertion)
|
|
24
|
+
* @param {unknown} args chai.Assertion.prototype.assert arguments
|
|
25
|
+
* @returns {unknown}
|
|
29
26
|
* @namespace Utils
|
|
30
27
|
* @name getMessage
|
|
31
|
-
* @
|
|
28
|
+
* @public
|
|
32
29
|
*/
|
|
33
|
-
|
|
34
30
|
export function getMessage(obj, args) {
|
|
35
31
|
var negate = flag(obj, 'negate')
|
|
36
32
|
, val = flag(obj, 'object')
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {flag} from './flag.js';
|
|
2
2
|
import {type} from './type-detect.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @param {unknown} obj
|
|
6
|
+
* @returns {boolean}
|
|
7
|
+
*/
|
|
4
8
|
function isObjectType(obj) {
|
|
5
9
|
var objectType = type(obj);
|
|
6
10
|
var objectTypes = ['Array', 'Object', 'Function'];
|
|
@@ -17,13 +21,13 @@ function isObjectType(obj) {
|
|
|
17
21
|
*
|
|
18
22
|
* Returns the `operator` or `undefined` value for an Assertion.
|
|
19
23
|
*
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
24
|
+
* @param {object} obj object (constructed Assertion)
|
|
25
|
+
* @param {unknown} args chai.Assertion.prototype.assert arguments
|
|
26
|
+
* @returns {unknown}
|
|
22
27
|
* @namespace Utils
|
|
23
28
|
* @name getOperator
|
|
24
|
-
* @
|
|
29
|
+
* @public
|
|
25
30
|
*/
|
|
26
|
-
|
|
27
31
|
export function getOperator(obj, args) {
|
|
28
32
|
var operator = flag(obj, 'operator');
|
|
29
33
|
var negate = flag(obj, 'negate');
|
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
/*!
|
|
8
|
-
* Module dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
7
|
import {getOwnEnumerablePropertySymbols} from './getOwnEnumerablePropertySymbols.js';
|
|
12
8
|
|
|
13
9
|
/**
|
|
@@ -17,13 +13,12 @@ import {getOwnEnumerablePropertySymbols} from './getOwnEnumerablePropertySymbols
|
|
|
17
13
|
* symbols of an object. This function is necessary because Object.keys only
|
|
18
14
|
* returns enumerable property names, not enumerable property symbols.
|
|
19
15
|
*
|
|
20
|
-
* @param {
|
|
16
|
+
* @param {object} obj
|
|
21
17
|
* @returns {Array}
|
|
22
18
|
* @namespace Utils
|
|
23
19
|
* @name getOwnEnumerableProperties
|
|
24
|
-
* @
|
|
20
|
+
* @public
|
|
25
21
|
*/
|
|
26
|
-
|
|
27
22
|
export function getOwnEnumerableProperties(obj) {
|
|
28
23
|
return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
|
|
29
24
|
}
|
|
@@ -11,13 +11,12 @@
|
|
|
11
11
|
* object. This function is necessary because Object.getOwnPropertySymbols
|
|
12
12
|
* returns both enumerable and non-enumerable property symbols.
|
|
13
13
|
*
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {object} obj
|
|
15
15
|
* @returns {Array}
|
|
16
16
|
* @namespace Utils
|
|
17
17
|
* @name getOwnEnumerablePropertySymbols
|
|
18
|
-
* @
|
|
18
|
+
* @public
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
20
|
export function getOwnEnumerablePropertySymbols(obj) {
|
|
22
21
|
if (typeof Object.getOwnPropertySymbols !== 'function') return [];
|
|
23
22
|
|
|
@@ -10,16 +10,18 @@
|
|
|
10
10
|
* This allows the retrieval of property names of an object, enumerable or not,
|
|
11
11
|
* inherited or not.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {object} object
|
|
14
14
|
* @returns {Array}
|
|
15
15
|
* @namespace Utils
|
|
16
16
|
* @name getProperties
|
|
17
|
-
* @
|
|
17
|
+
* @public
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
export function getProperties(object) {
|
|
21
20
|
var result = Object.getOwnPropertyNames(object);
|
|
22
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @param {unknown} property
|
|
24
|
+
*/
|
|
23
25
|
function addProperty(property) {
|
|
24
26
|
if (result.indexOf(property) === -1) {
|
|
25
27
|
result.push(property);
|