jasmine-core 3.4.0 → 3.5.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.
- checksums.yaml +4 -4
- data/lib/jasmine-core/jasmine-html.js +285 -88
- data/lib/jasmine-core/jasmine.css +1 -1
- data/lib/jasmine-core/jasmine.js +1747 -562
- data/lib/jasmine-core/version.rb +1 -1
- metadata +3 -45
@@ -1,7 +1,7 @@
|
|
1
1
|
@charset "UTF-8";
|
2
2
|
body { overflow-y: scroll; }
|
3
3
|
|
4
|
-
.jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; }
|
4
|
+
.jasmine_html-reporter { width: 100%; background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; }
|
5
5
|
|
6
6
|
.jasmine_html-reporter a { text-decoration: none; }
|
7
7
|
|
data/lib/jasmine-core/jasmine.js
CHANGED
@@ -20,11 +20,15 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
20
20
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
*/
|
23
|
-
|
24
|
-
|
23
|
+
// eslint-disable-next-line no-unused-vars
|
24
|
+
var getJasmineRequireObj = (function(jasmineGlobal) {
|
25
25
|
var jasmineRequire;
|
26
26
|
|
27
|
-
if (
|
27
|
+
if (
|
28
|
+
typeof module !== 'undefined' &&
|
29
|
+
module.exports &&
|
30
|
+
typeof exports !== 'undefined'
|
31
|
+
) {
|
28
32
|
if (typeof global !== 'undefined') {
|
29
33
|
jasmineGlobal = global;
|
30
34
|
} else {
|
@@ -32,7 +36,11 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
|
|
32
36
|
}
|
33
37
|
jasmineRequire = exports;
|
34
38
|
} else {
|
35
|
-
if (
|
39
|
+
if (
|
40
|
+
typeof window !== 'undefined' &&
|
41
|
+
typeof window.toString === 'function' &&
|
42
|
+
window.toString() === '[object GjsGlobal]'
|
43
|
+
) {
|
36
44
|
jasmineGlobal = window;
|
37
45
|
}
|
38
46
|
jasmineRequire = jasmineGlobal.jasmineRequire = {};
|
@@ -69,6 +77,8 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
|
|
69
77
|
j$.ObjectContaining = jRequire.ObjectContaining(j$);
|
70
78
|
j$.ArrayContaining = jRequire.ArrayContaining(j$);
|
71
79
|
j$.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$);
|
80
|
+
j$.MapContaining = jRequire.MapContaining(j$);
|
81
|
+
j$.SetContaining = jRequire.SetContaining(j$);
|
72
82
|
j$.pp = jRequire.pp(j$);
|
73
83
|
j$.QueueRunner = jRequire.QueueRunner(j$);
|
74
84
|
j$.ReportDispatcher = jRequire.ReportDispatcher(j$);
|
@@ -109,6 +119,8 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
|
109
119
|
'toBe',
|
110
120
|
'toBeCloseTo',
|
111
121
|
'toBeDefined',
|
122
|
+
'toBeInstanceOf',
|
123
|
+
'toBeFalse',
|
112
124
|
'toBeFalsy',
|
113
125
|
'toBeGreaterThan',
|
114
126
|
'toBeGreaterThanOrEqual',
|
@@ -118,6 +130,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
|
118
130
|
'toBeNegativeInfinity',
|
119
131
|
'toBeNull',
|
120
132
|
'toBePositiveInfinity',
|
133
|
+
'toBeTrue',
|
121
134
|
'toBeTruthy',
|
122
135
|
'toBeUndefined',
|
123
136
|
'toContain',
|
@@ -130,7 +143,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
|
130
143
|
'toMatch',
|
131
144
|
'toThrow',
|
132
145
|
'toThrowError',
|
133
|
-
'toThrowMatching'
|
146
|
+
'toThrowMatching'
|
134
147
|
],
|
135
148
|
matchers = {};
|
136
149
|
|
@@ -151,6 +164,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
151
164
|
* Maximum object depth the pretty printer will print to.
|
152
165
|
* Set this to a lower value to speed up pretty printing if you have large objects.
|
153
166
|
* @name jasmine.MAX_PRETTY_PRINT_DEPTH
|
167
|
+
* @since 1.3.0
|
154
168
|
*/
|
155
169
|
j$.MAX_PRETTY_PRINT_DEPTH = 8;
|
156
170
|
/**
|
@@ -158,17 +172,20 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
158
172
|
* This will also limit the number of keys and values displayed for an object.
|
159
173
|
* Elements past this number will be ellipised.
|
160
174
|
* @name jasmine.MAX_PRETTY_PRINT_ARRAY_LENGTH
|
175
|
+
* @since 2.7.0
|
161
176
|
*/
|
162
177
|
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 50;
|
163
178
|
/**
|
164
179
|
* Maximum number of characters to display when pretty printing objects.
|
165
180
|
* Characters past this number will be ellipised.
|
166
181
|
* @name jasmine.MAX_PRETTY_PRINT_CHARS
|
182
|
+
* @since 2.9.0
|
167
183
|
*/
|
168
184
|
j$.MAX_PRETTY_PRINT_CHARS = 1000;
|
169
185
|
/**
|
170
186
|
* Default number of milliseconds Jasmine will wait for an asynchronous spec to complete.
|
171
187
|
* @name jasmine.DEFAULT_TIMEOUT_INTERVAL
|
188
|
+
* @since 1.3.0
|
172
189
|
*/
|
173
190
|
j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
174
191
|
|
@@ -180,11 +197,12 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
180
197
|
* Get the currently booted Jasmine Environment.
|
181
198
|
*
|
182
199
|
* @name jasmine.getEnv
|
200
|
+
* @since 1.3.0
|
183
201
|
* @function
|
184
202
|
* @return {Env}
|
185
203
|
*/
|
186
204
|
j$.getEnv = function(options) {
|
187
|
-
var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
|
205
|
+
var env = (j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options));
|
188
206
|
//jasmine. singletons in here (setTimeout blah blah).
|
189
207
|
return env;
|
190
208
|
};
|
@@ -194,7 +212,9 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
194
212
|
};
|
195
213
|
|
196
214
|
j$.isObject_ = function(value) {
|
197
|
-
return
|
215
|
+
return (
|
216
|
+
!j$.util.isUndefined(value) && value !== null && j$.isA_('Object', value)
|
217
|
+
);
|
198
218
|
};
|
199
219
|
|
200
220
|
j$.isString_ = function(value) {
|
@@ -214,7 +234,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
214
234
|
};
|
215
235
|
|
216
236
|
j$.isTypedArray_ = function(value) {
|
217
|
-
return
|
237
|
+
return (
|
238
|
+
j$.isA_('Float32Array', value) ||
|
218
239
|
j$.isA_('Float64Array', value) ||
|
219
240
|
j$.isA_('Int16Array', value) ||
|
220
241
|
j$.isA_('Int32Array', value) ||
|
@@ -222,7 +243,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
222
243
|
j$.isA_('Uint16Array', value) ||
|
223
244
|
j$.isA_('Uint32Array', value) ||
|
224
245
|
j$.isA_('Uint8Array', value) ||
|
225
|
-
j$.isA_('Uint8ClampedArray', value)
|
246
|
+
j$.isA_('Uint8ClampedArray', value)
|
247
|
+
);
|
226
248
|
};
|
227
249
|
|
228
250
|
j$.isA_ = function(typeName, value) {
|
@@ -252,9 +274,9 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
252
274
|
|
253
275
|
j$.isDomNode = function(obj) {
|
254
276
|
// Node is a function, because constructors
|
255
|
-
return typeof jasmineGlobal.Node !== 'undefined'
|
256
|
-
obj instanceof jasmineGlobal.Node
|
257
|
-
|
277
|
+
return typeof jasmineGlobal.Node !== 'undefined'
|
278
|
+
? obj instanceof jasmineGlobal.Node
|
279
|
+
: obj !== null &&
|
258
280
|
typeof obj === 'object' &&
|
259
281
|
typeof obj.nodeType === 'number' &&
|
260
282
|
typeof obj.nodeName === 'string';
|
@@ -262,15 +284,29 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
262
284
|
};
|
263
285
|
|
264
286
|
j$.isMap = function(obj) {
|
265
|
-
return
|
287
|
+
return (
|
288
|
+
obj !== null &&
|
289
|
+
typeof obj !== 'undefined' &&
|
290
|
+
typeof jasmineGlobal.Map !== 'undefined' &&
|
291
|
+
obj.constructor === jasmineGlobal.Map
|
292
|
+
);
|
266
293
|
};
|
267
294
|
|
268
295
|
j$.isSet = function(obj) {
|
269
|
-
return
|
296
|
+
return (
|
297
|
+
obj !== null &&
|
298
|
+
typeof obj !== 'undefined' &&
|
299
|
+
typeof jasmineGlobal.Set !== 'undefined' &&
|
300
|
+
obj.constructor === jasmineGlobal.Set
|
301
|
+
);
|
270
302
|
};
|
271
303
|
|
272
304
|
j$.isPromise = function(obj) {
|
273
|
-
return
|
305
|
+
return (
|
306
|
+
typeof jasmineGlobal.Promise !== 'undefined' &&
|
307
|
+
!!obj &&
|
308
|
+
obj.constructor === jasmineGlobal.Promise
|
309
|
+
);
|
274
310
|
};
|
275
311
|
|
276
312
|
j$.isPromiseLike = function(obj) {
|
@@ -282,7 +318,8 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
282
318
|
return func.name;
|
283
319
|
}
|
284
320
|
|
285
|
-
var matches =
|
321
|
+
var matches =
|
322
|
+
func.toString().match(/^\s*function\s*(\w+)\s*\(/) ||
|
286
323
|
func.toString().match(/^\s*\[object\s*(\w+)Constructor\]/);
|
287
324
|
|
288
325
|
return matches ? matches[1] : '<anonymous>';
|
@@ -292,6 +329,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
292
329
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
293
330
|
* that will succeed if the actual value being compared is an instance of the specified class/constructor.
|
294
331
|
* @name jasmine.any
|
332
|
+
* @since 1.3.0
|
295
333
|
* @function
|
296
334
|
* @param {Constructor} clazz - The constructor to check against.
|
297
335
|
*/
|
@@ -303,6 +341,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
303
341
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
304
342
|
* that will succeed if the actual value being compared is not `null` and not `undefined`.
|
305
343
|
* @name jasmine.anything
|
344
|
+
* @since 2.2.0
|
306
345
|
* @function
|
307
346
|
*/
|
308
347
|
j$.anything = function() {
|
@@ -313,38 +352,51 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
313
352
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
314
353
|
* that will succeed if the actual value being compared is `true` or anything truthy.
|
315
354
|
* @name jasmine.truthy
|
355
|
+
* @since 3.1.0
|
316
356
|
* @function
|
317
357
|
*/
|
318
|
-
j$.truthy = function() {
|
358
|
+
j$.truthy = function() {
|
359
|
+
return new j$.Truthy();
|
360
|
+
};
|
319
361
|
|
320
362
|
/**
|
321
363
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
322
364
|
* that will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
323
365
|
* @name jasmine.falsy
|
366
|
+
* @since 3.1.0
|
324
367
|
* @function
|
325
368
|
*/
|
326
|
-
j$.falsy = function() {
|
369
|
+
j$.falsy = function() {
|
370
|
+
return new j$.Falsy();
|
371
|
+
};
|
327
372
|
|
328
373
|
/**
|
329
374
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
330
375
|
* that will succeed if the actual value being compared is empty.
|
331
376
|
* @name jasmine.empty
|
377
|
+
* @since 3.1.0
|
332
378
|
* @function
|
333
379
|
*/
|
334
|
-
j$.empty = function() {
|
380
|
+
j$.empty = function() {
|
381
|
+
return new j$.Empty();
|
382
|
+
};
|
335
383
|
|
336
384
|
/**
|
337
385
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
338
386
|
* that will succeed if the actual value being compared is not empty.
|
339
387
|
* @name jasmine.notEmpty
|
388
|
+
* @since 3.1.0
|
340
389
|
* @function
|
341
390
|
*/
|
342
|
-
j$.notEmpty = function() {
|
391
|
+
j$.notEmpty = function() {
|
392
|
+
return new j$.NotEmpty();
|
393
|
+
};
|
343
394
|
|
344
395
|
/**
|
345
396
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
346
397
|
* that will succeed if the actual value being compared contains at least the keys and values.
|
347
398
|
* @name jasmine.objectContaining
|
399
|
+
* @since 1.3.0
|
348
400
|
* @function
|
349
401
|
* @param {Object} sample - The subset of properties that _must_ be in the actual.
|
350
402
|
*/
|
@@ -356,6 +408,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
356
408
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
357
409
|
* that will succeed if the actual value is a `String` that matches the `RegExp` or `String`.
|
358
410
|
* @name jasmine.stringMatching
|
411
|
+
* @since 2.2.0
|
359
412
|
* @function
|
360
413
|
* @param {RegExp|String} expected
|
361
414
|
*/
|
@@ -367,6 +420,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
367
420
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
368
421
|
* that will succeed if the actual value is an `Array` that contains at least the elements in the sample.
|
369
422
|
* @name jasmine.arrayContaining
|
423
|
+
* @since 2.2.0
|
370
424
|
* @function
|
371
425
|
* @param {Array} sample
|
372
426
|
*/
|
@@ -378,6 +432,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
378
432
|
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
379
433
|
* that will succeed if the actual value is an `Array` that contains all of the elements in the sample in any order.
|
380
434
|
* @name jasmine.arrayWithExactContents
|
435
|
+
* @since 2.8.0
|
381
436
|
* @function
|
382
437
|
* @param {Array} sample
|
383
438
|
*/
|
@@ -385,22 +440,48 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
385
440
|
return new j$.ArrayWithExactContents(sample);
|
386
441
|
};
|
387
442
|
|
443
|
+
/**
|
444
|
+
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
445
|
+
* that will succeed if every key/value pair in the sample passes the deep equality comparison
|
446
|
+
* with at least one key/value pair in the actual value being compared
|
447
|
+
* @name jasmine.mapContaining
|
448
|
+
* @since 3.5.0
|
449
|
+
* @function
|
450
|
+
* @param {Map} sample - The subset of items that _must_ be in the actual.
|
451
|
+
*/
|
452
|
+
j$.mapContaining = function(sample) {
|
453
|
+
return new j$.MapContaining(sample);
|
454
|
+
};
|
455
|
+
|
456
|
+
/**
|
457
|
+
* Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
|
458
|
+
* that will succeed if every item in the sample passes the deep equality comparison
|
459
|
+
* with at least one item in the actual value being compared
|
460
|
+
* @name jasmine.setContaining
|
461
|
+
* @since 3.5.0
|
462
|
+
* @function
|
463
|
+
* @param {Set} sample - The subset of items that _must_ be in the actual.
|
464
|
+
*/
|
465
|
+
j$.setContaining = function(sample) {
|
466
|
+
return new j$.SetContaining(sample);
|
467
|
+
};
|
468
|
+
|
388
469
|
j$.isSpy = function(putativeSpy) {
|
389
470
|
if (!putativeSpy) {
|
390
471
|
return false;
|
391
472
|
}
|
392
|
-
return
|
393
|
-
putativeSpy.
|
473
|
+
return (
|
474
|
+
putativeSpy.and instanceof j$.SpyStrategy &&
|
475
|
+
putativeSpy.calls instanceof j$.CallTracker
|
476
|
+
);
|
394
477
|
};
|
395
478
|
};
|
396
479
|
|
397
480
|
getJasmineRequireObj().util = function(j$) {
|
398
|
-
|
399
481
|
var util = {};
|
400
482
|
|
401
483
|
util.inherit = function(childClass, parentClass) {
|
402
|
-
var Subclass = function() {
|
403
|
-
};
|
484
|
+
var Subclass = function() {};
|
404
485
|
Subclass.prototype = parentClass.prototype;
|
405
486
|
childClass.prototype = new Subclass();
|
406
487
|
};
|
@@ -409,7 +490,8 @@ getJasmineRequireObj().util = function(j$) {
|
|
409
490
|
if (!str) {
|
410
491
|
return str;
|
411
492
|
}
|
412
|
-
return str
|
493
|
+
return str
|
494
|
+
.replace(/&/g, '&')
|
413
495
|
.replace(/</g, '<')
|
414
496
|
.replace(/>/g, '>');
|
415
497
|
};
|
@@ -454,7 +536,7 @@ getJasmineRequireObj().util = function(j$) {
|
|
454
536
|
util.cloneArgs = function(args) {
|
455
537
|
var clonedArgs = [];
|
456
538
|
var argsAsArray = j$.util.argsToArray(args);
|
457
|
-
for(var i = 0; i < argsAsArray.length; i++) {
|
539
|
+
for (var i = 0; i < argsAsArray.length; i++) {
|
458
540
|
var str = Object.prototype.toString.apply(argsAsArray[i]),
|
459
541
|
primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
460
542
|
|
@@ -496,19 +578,7 @@ getJasmineRequireObj().util = function(j$) {
|
|
496
578
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
497
579
|
};
|
498
580
|
|
499
|
-
function
|
500
|
-
var i;
|
501
|
-
|
502
|
-
for (i = 0; i < lines.length; i++) {
|
503
|
-
if (lines[i].match(pattern)) {
|
504
|
-
return true;
|
505
|
-
}
|
506
|
-
}
|
507
|
-
|
508
|
-
return false;
|
509
|
-
}
|
510
|
-
|
511
|
-
util.errorWithStack = function errorWithStack () {
|
581
|
+
util.errorWithStack = function errorWithStack() {
|
512
582
|
// Don't throw and catch if we don't have to, because it makes it harder
|
513
583
|
// for users to debug their code with exception breakpoints.
|
514
584
|
var error = new Error();
|
@@ -534,15 +604,32 @@ getJasmineRequireObj().util = function(j$) {
|
|
534
604
|
var result;
|
535
605
|
|
536
606
|
return function() {
|
537
|
-
var trace;
|
538
|
-
|
539
607
|
if (!result) {
|
540
608
|
result = callerFile();
|
541
609
|
}
|
542
610
|
|
543
611
|
return result;
|
544
612
|
};
|
545
|
-
}()
|
613
|
+
})();
|
614
|
+
|
615
|
+
function StopIteration() {}
|
616
|
+
StopIteration.prototype = Object.create(Error.prototype);
|
617
|
+
StopIteration.prototype.constructor = StopIteration;
|
618
|
+
|
619
|
+
// useful for maps and sets since `forEach` is the only IE11-compatible way to iterate them
|
620
|
+
util.forEachBreakable = function(iterable, iteratee) {
|
621
|
+
function breakLoop() {
|
622
|
+
throw new StopIteration();
|
623
|
+
}
|
624
|
+
|
625
|
+
try {
|
626
|
+
iterable.forEach(function(value, key) {
|
627
|
+
iteratee(breakLoop, value, key, iterable);
|
628
|
+
});
|
629
|
+
} catch (error) {
|
630
|
+
if (!(error instanceof StopIteration)) throw error;
|
631
|
+
}
|
632
|
+
};
|
546
633
|
|
547
634
|
return util;
|
548
635
|
};
|
@@ -555,13 +642,30 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
555
642
|
this.id = attrs.id;
|
556
643
|
this.description = attrs.description || '';
|
557
644
|
this.queueableFn = attrs.queueableFn;
|
558
|
-
this.beforeAndAfterFns =
|
559
|
-
|
645
|
+
this.beforeAndAfterFns =
|
646
|
+
attrs.beforeAndAfterFns ||
|
647
|
+
function() {
|
648
|
+
return { befores: [], afters: [] };
|
649
|
+
};
|
650
|
+
this.userContext =
|
651
|
+
attrs.userContext ||
|
652
|
+
function() {
|
653
|
+
return {};
|
654
|
+
};
|
560
655
|
this.onStart = attrs.onStart || function() {};
|
561
|
-
this.getSpecName =
|
562
|
-
|
656
|
+
this.getSpecName =
|
657
|
+
attrs.getSpecName ||
|
658
|
+
function() {
|
659
|
+
return '';
|
660
|
+
};
|
661
|
+
this.expectationResultFactory =
|
662
|
+
attrs.expectationResultFactory || function() {};
|
563
663
|
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
564
|
-
this.catchingExceptions =
|
664
|
+
this.catchingExceptions =
|
665
|
+
attrs.catchingExceptions ||
|
666
|
+
function() {
|
667
|
+
return true;
|
668
|
+
};
|
565
669
|
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
566
670
|
this.timer = attrs.timer || j$.noopTimer;
|
567
671
|
|
@@ -589,7 +693,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
589
693
|
passedExpectations: [],
|
590
694
|
deprecationWarnings: [],
|
591
695
|
pendingReason: '',
|
592
|
-
duration: null
|
696
|
+
duration: null
|
593
697
|
};
|
594
698
|
}
|
595
699
|
|
@@ -614,7 +718,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
614
718
|
return this.asyncExpectationFactory(actual, this);
|
615
719
|
};
|
616
720
|
|
617
|
-
Spec.prototype.execute = function(onComplete, excluded) {
|
721
|
+
Spec.prototype.execute = function(onComplete, excluded, failSpecWithNoExp) {
|
618
722
|
var self = this;
|
619
723
|
|
620
724
|
var onStart = {
|
@@ -627,7 +731,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
627
731
|
var complete = {
|
628
732
|
fn: function(done) {
|
629
733
|
self.queueableFn.fn = null;
|
630
|
-
self.result.status = self.status(excluded);
|
734
|
+
self.result.status = self.status(excluded, failSpecWithNoExp);
|
631
735
|
self.resultCallback(self.result, done);
|
632
736
|
}
|
633
737
|
};
|
@@ -639,12 +743,15 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
639
743
|
isLeaf: true,
|
640
744
|
queueableFns: regularFns,
|
641
745
|
cleanupFns: fns.afters,
|
642
|
-
onException: function
|
746
|
+
onException: function() {
|
643
747
|
self.onException.apply(self, arguments);
|
644
748
|
},
|
645
749
|
onComplete: function() {
|
646
750
|
self.result.duration = self.timer.elapsed();
|
647
|
-
onComplete(
|
751
|
+
onComplete(
|
752
|
+
self.result.status === 'failed' &&
|
753
|
+
new j$.StopExecutionError('spec failed')
|
754
|
+
);
|
648
755
|
},
|
649
756
|
userContext: this.userContext()
|
650
757
|
};
|
@@ -670,13 +777,17 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
670
777
|
return;
|
671
778
|
}
|
672
779
|
|
673
|
-
this.addExpectationResult(
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
780
|
+
this.addExpectationResult(
|
781
|
+
false,
|
782
|
+
{
|
783
|
+
matcherName: '',
|
784
|
+
passed: false,
|
785
|
+
expected: '',
|
786
|
+
actual: '',
|
787
|
+
error: e
|
788
|
+
},
|
789
|
+
true
|
790
|
+
);
|
680
791
|
};
|
681
792
|
|
682
793
|
Spec.prototype.pend = function(message) {
|
@@ -691,7 +802,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
691
802
|
return this.result;
|
692
803
|
};
|
693
804
|
|
694
|
-
Spec.prototype.status = function(excluded) {
|
805
|
+
Spec.prototype.status = function(excluded, failSpecWithNoExpectations) {
|
695
806
|
if (excluded === true) {
|
696
807
|
return 'excluded';
|
697
808
|
}
|
@@ -700,11 +811,17 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
700
811
|
return 'pending';
|
701
812
|
}
|
702
813
|
|
703
|
-
if (
|
814
|
+
if (
|
815
|
+
this.result.failedExpectations.length > 0 ||
|
816
|
+
(failSpecWithNoExpectations &&
|
817
|
+
this.result.failedExpectations.length +
|
818
|
+
this.result.passedExpectations.length ===
|
819
|
+
0)
|
820
|
+
) {
|
704
821
|
return 'failed';
|
705
|
-
} else {
|
706
|
-
return 'passed';
|
707
822
|
}
|
823
|
+
|
824
|
+
return 'passed';
|
708
825
|
};
|
709
826
|
|
710
827
|
Spec.prototype.getFullName = function() {
|
@@ -715,13 +832,16 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
715
832
|
if (typeof deprecation === 'string') {
|
716
833
|
deprecation = { message: deprecation };
|
717
834
|
}
|
718
|
-
this.result.deprecationWarnings.push(
|
835
|
+
this.result.deprecationWarnings.push(
|
836
|
+
this.expectationResultFactory(deprecation)
|
837
|
+
);
|
719
838
|
};
|
720
839
|
|
721
840
|
var extractCustomPendingMessage = function(e) {
|
722
841
|
var fullMessage = e.toString(),
|
723
|
-
|
724
|
-
|
842
|
+
boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage),
|
843
|
+
boilerplateEnd =
|
844
|
+
boilerplateStart + Spec.pendingSpecExceptionMessage.length;
|
725
845
|
|
726
846
|
return fullMessage.substr(boilerplateEnd);
|
727
847
|
};
|
@@ -729,7 +849,11 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
729
849
|
Spec.pendingSpecExceptionMessage = '=> marked Pending';
|
730
850
|
|
731
851
|
Spec.isPendingSpecException = function(e) {
|
732
|
-
return !!(
|
852
|
+
return !!(
|
853
|
+
e &&
|
854
|
+
e.toString &&
|
855
|
+
e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1
|
856
|
+
);
|
733
857
|
};
|
734
858
|
|
735
859
|
return Spec;
|
@@ -745,7 +869,7 @@ if (typeof window == void 0 && typeof exports == 'object') {
|
|
745
869
|
getJasmineRequireObj().Order = function() {
|
746
870
|
function Order(options) {
|
747
871
|
this.random = 'random' in options ? options.random : true;
|
748
|
-
var seed = this.seed = options.seed || generateSeed();
|
872
|
+
var seed = (this.seed = options.seed || generateSeed());
|
749
873
|
this.sort = this.random ? randomOrder : naturalOrder;
|
750
874
|
|
751
875
|
function naturalOrder(items) {
|
@@ -771,17 +895,16 @@ getJasmineRequireObj().Order = function() {
|
|
771
895
|
|
772
896
|
function jenkinsHash(key) {
|
773
897
|
var hash, i;
|
774
|
-
for(hash = i = 0; i < key.length; ++i) {
|
898
|
+
for (hash = i = 0; i < key.length; ++i) {
|
775
899
|
hash += key.charCodeAt(i);
|
776
|
-
hash +=
|
777
|
-
hash ^=
|
900
|
+
hash += hash << 10;
|
901
|
+
hash ^= hash >> 6;
|
778
902
|
}
|
779
|
-
hash +=
|
780
|
-
hash ^=
|
781
|
-
hash +=
|
903
|
+
hash += hash << 3;
|
904
|
+
hash ^= hash >> 11;
|
905
|
+
hash += hash << 15;
|
782
906
|
return hash;
|
783
907
|
}
|
784
|
-
|
785
908
|
}
|
786
909
|
|
787
910
|
return Order;
|
@@ -791,6 +914,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
791
914
|
/**
|
792
915
|
* _Note:_ Do not construct this directly, Jasmine will make one during booting.
|
793
916
|
* @name Env
|
917
|
+
* @since 2.0.0
|
794
918
|
* @classdesc The Jasmine environment
|
795
919
|
* @constructor
|
796
920
|
*/
|
@@ -799,13 +923,20 @@ getJasmineRequireObj().Env = function(j$) {
|
|
799
923
|
|
800
924
|
var self = this;
|
801
925
|
var global = options.global || j$.getGlobal();
|
926
|
+
var customPromise;
|
802
927
|
|
803
928
|
var totalSpecsDefined = 0;
|
804
929
|
|
805
930
|
var realSetTimeout = global.setTimeout;
|
806
931
|
var realClearTimeout = global.clearTimeout;
|
807
932
|
var clearStack = j$.getClearStack(global);
|
808
|
-
this.clock = new j$.Clock(
|
933
|
+
this.clock = new j$.Clock(
|
934
|
+
global,
|
935
|
+
function() {
|
936
|
+
return new j$.DelayedFunctionScheduler();
|
937
|
+
},
|
938
|
+
new j$.MockDate(global)
|
939
|
+
);
|
809
940
|
|
810
941
|
var runnableResources = {};
|
811
942
|
|
@@ -818,11 +949,13 @@ getJasmineRequireObj().Env = function(j$) {
|
|
818
949
|
* This represents the available options to configure Jasmine.
|
819
950
|
* Options that are not provided will use their default values
|
820
951
|
* @interface Configuration
|
952
|
+
* @since 3.3.0
|
821
953
|
*/
|
822
954
|
var config = {
|
823
955
|
/**
|
824
956
|
* Whether to randomize spec execution order
|
825
957
|
* @name Configuration#random
|
958
|
+
* @since 3.3.0
|
826
959
|
* @type Boolean
|
827
960
|
* @default true
|
828
961
|
*/
|
@@ -831,6 +964,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
831
964
|
* Seed to use as the basis of randomization.
|
832
965
|
* Null causes the seed to be determined randomly at the start of execution.
|
833
966
|
* @name Configuration#seed
|
967
|
+
* @since 3.3.0
|
834
968
|
* @type function
|
835
969
|
* @default null
|
836
970
|
*/
|
@@ -838,13 +972,25 @@ getJasmineRequireObj().Env = function(j$) {
|
|
838
972
|
/**
|
839
973
|
* Whether to stop execution of the suite after the first spec failure
|
840
974
|
* @name Configuration#failFast
|
975
|
+
* @since 3.3.0
|
841
976
|
* @type Boolean
|
842
977
|
* @default false
|
843
978
|
*/
|
844
979
|
failFast: false,
|
980
|
+
/**
|
981
|
+
* Whether to fail the spec if it ran no expectations. By default
|
982
|
+
* a spec that ran no expectations is reported as passed. Setting this
|
983
|
+
* to true will report such spec as a failure.
|
984
|
+
* @name Configuration#failSpecWithNoExpectations
|
985
|
+
* @since 3.5.0
|
986
|
+
* @type Boolean
|
987
|
+
* @default false
|
988
|
+
*/
|
989
|
+
failSpecWithNoExpectations: false,
|
845
990
|
/**
|
846
991
|
* Whether to cause specs to only have one expectation failure.
|
847
992
|
* @name Configuration#oneFailurePerSpec
|
993
|
+
* @since 3.3.0
|
848
994
|
* @type Boolean
|
849
995
|
* @default false
|
850
996
|
*/
|
@@ -852,6 +998,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
852
998
|
/**
|
853
999
|
* Function to use to filter specs
|
854
1000
|
* @name Configuration#specFilter
|
1001
|
+
* @since 3.3.0
|
855
1002
|
* @type function
|
856
1003
|
* @default true
|
857
1004
|
*/
|
@@ -862,10 +1009,21 @@ getJasmineRequireObj().Env = function(j$) {
|
|
862
1009
|
* Whether or not reporters should hide disabled specs from their output.
|
863
1010
|
* Currently only supported by Jasmine's HTMLReporter
|
864
1011
|
* @name Configuration#hideDisabled
|
1012
|
+
* @since 3.3.0
|
865
1013
|
* @type Boolean
|
866
1014
|
* @default false
|
867
1015
|
*/
|
868
|
-
hideDisabled: false
|
1016
|
+
hideDisabled: false,
|
1017
|
+
/**
|
1018
|
+
* Set to provide a custom promise library that Jasmine will use if it needs
|
1019
|
+
* to create a promise. If not set, it will default to whatever global Promise
|
1020
|
+
* library is available (if any).
|
1021
|
+
* @name Configuration#Promise
|
1022
|
+
* @since 3.5.0
|
1023
|
+
* @type function
|
1024
|
+
* @default undefined
|
1025
|
+
*/
|
1026
|
+
Promise: undefined
|
869
1027
|
};
|
870
1028
|
|
871
1029
|
var currentSuite = function() {
|
@@ -889,7 +1047,13 @@ getJasmineRequireObj().Env = function(j$) {
|
|
889
1047
|
|
890
1048
|
if (!options.suppressLoadErrors) {
|
891
1049
|
installGlobalErrors();
|
892
|
-
globalErrors.pushListener(function(
|
1050
|
+
globalErrors.pushListener(function(
|
1051
|
+
message,
|
1052
|
+
filename,
|
1053
|
+
lineno,
|
1054
|
+
colNo,
|
1055
|
+
err
|
1056
|
+
) {
|
893
1057
|
topSuite.result.failedExpectations.push({
|
894
1058
|
passed: false,
|
895
1059
|
globalErrorType: 'load',
|
@@ -904,6 +1068,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
904
1068
|
/**
|
905
1069
|
* Configure your jasmine environment
|
906
1070
|
* @name Env#configure
|
1071
|
+
* @since 3.3.0
|
907
1072
|
* @argument {Configuration} configuration
|
908
1073
|
* @function
|
909
1074
|
*/
|
@@ -924,6 +1089,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|
924
1089
|
config.failFast = configuration.failFast;
|
925
1090
|
}
|
926
1091
|
|
1092
|
+
if (configuration.hasOwnProperty('failSpecWithNoExpectations')) {
|
1093
|
+
config.failSpecWithNoExpectations =
|
1094
|
+
configuration.failSpecWithNoExpectations;
|
1095
|
+
}
|
1096
|
+
|
927
1097
|
if (configuration.hasOwnProperty('oneFailurePerSpec')) {
|
928
1098
|
config.oneFailurePerSpec = configuration.oneFailurePerSpec;
|
929
1099
|
}
|
@@ -931,11 +1101,28 @@ getJasmineRequireObj().Env = function(j$) {
|
|
931
1101
|
if (configuration.hasOwnProperty('hideDisabled')) {
|
932
1102
|
config.hideDisabled = configuration.hideDisabled;
|
933
1103
|
}
|
1104
|
+
|
1105
|
+
// Don't use hasOwnProperty to check for Promise existence because Promise
|
1106
|
+
// can be initialized to undefined, either explicitly or by using the
|
1107
|
+
// object returned from Env#configuration. In particular, Karma does this.
|
1108
|
+
if (configuration.Promise) {
|
1109
|
+
if (
|
1110
|
+
typeof configuration.Promise.resolve === 'function' &&
|
1111
|
+
typeof configuration.Promise.reject === 'function'
|
1112
|
+
) {
|
1113
|
+
customPromise = configuration.Promise;
|
1114
|
+
} else {
|
1115
|
+
throw new Error(
|
1116
|
+
'Custom promise library missing `resolve`/`reject` functions'
|
1117
|
+
);
|
1118
|
+
}
|
1119
|
+
}
|
934
1120
|
};
|
935
1121
|
|
936
1122
|
/**
|
937
1123
|
* Get the current configuration for your jasmine environment
|
938
1124
|
* @name Env#configuration
|
1125
|
+
* @since 3.3.0
|
939
1126
|
* @function
|
940
1127
|
* @returns {Configuration}
|
941
1128
|
*/
|
@@ -949,39 +1136,76 @@ getJasmineRequireObj().Env = function(j$) {
|
|
949
1136
|
|
950
1137
|
Object.defineProperty(this, 'specFilter', {
|
951
1138
|
get: function() {
|
952
|
-
self.deprecated(
|
1139
|
+
self.deprecated(
|
1140
|
+
'Getting specFilter directly from Env is deprecated and will be removed in a future version of Jasmine, please check the specFilter option from `configuration`'
|
1141
|
+
);
|
953
1142
|
return config.specFilter;
|
954
1143
|
},
|
955
1144
|
set: function(val) {
|
956
|
-
self.deprecated(
|
1145
|
+
self.deprecated(
|
1146
|
+
'Setting specFilter directly on Env is deprecated and will be removed in a future version of Jasmine, please use the specFilter option in `configure`'
|
1147
|
+
);
|
957
1148
|
config.specFilter = val;
|
958
1149
|
}
|
959
1150
|
});
|
960
1151
|
|
1152
|
+
this.setDefaultSpyStrategy = function(defaultStrategyFn) {
|
1153
|
+
if (!currentRunnable()) {
|
1154
|
+
throw new Error(
|
1155
|
+
'Default spy strategy must be set in a before function or a spec'
|
1156
|
+
);
|
1157
|
+
}
|
1158
|
+
runnableResources[
|
1159
|
+
currentRunnable().id
|
1160
|
+
].defaultStrategyFn = defaultStrategyFn;
|
1161
|
+
};
|
1162
|
+
|
961
1163
|
this.addSpyStrategy = function(name, fn) {
|
962
|
-
if(!currentRunnable()) {
|
963
|
-
throw new Error(
|
1164
|
+
if (!currentRunnable()) {
|
1165
|
+
throw new Error(
|
1166
|
+
'Custom spy strategies must be added in a before function or a spec'
|
1167
|
+
);
|
964
1168
|
}
|
965
1169
|
runnableResources[currentRunnable().id].customSpyStrategies[name] = fn;
|
966
1170
|
};
|
967
1171
|
|
968
1172
|
this.addCustomEqualityTester = function(tester) {
|
969
|
-
if(!currentRunnable()) {
|
970
|
-
throw new Error(
|
1173
|
+
if (!currentRunnable()) {
|
1174
|
+
throw new Error(
|
1175
|
+
'Custom Equalities must be added in a before function or a spec'
|
1176
|
+
);
|
971
1177
|
}
|
972
|
-
runnableResources[currentRunnable().id].customEqualityTesters.push(
|
1178
|
+
runnableResources[currentRunnable().id].customEqualityTesters.push(
|
1179
|
+
tester
|
1180
|
+
);
|
973
1181
|
};
|
974
1182
|
|
975
1183
|
this.addMatchers = function(matchersToAdd) {
|
976
|
-
if(!currentRunnable()) {
|
977
|
-
throw new Error(
|
1184
|
+
if (!currentRunnable()) {
|
1185
|
+
throw new Error(
|
1186
|
+
'Matchers must be added in a before function or a spec'
|
1187
|
+
);
|
978
1188
|
}
|
979
|
-
var customMatchers =
|
1189
|
+
var customMatchers =
|
1190
|
+
runnableResources[currentRunnable().id].customMatchers;
|
980
1191
|
for (var matcherName in matchersToAdd) {
|
981
1192
|
customMatchers[matcherName] = matchersToAdd[matcherName];
|
982
1193
|
}
|
983
1194
|
};
|
984
1195
|
|
1196
|
+
this.addAsyncMatchers = function(matchersToAdd) {
|
1197
|
+
if (!currentRunnable()) {
|
1198
|
+
throw new Error(
|
1199
|
+
'Async Matchers must be added in a before function or a spec'
|
1200
|
+
);
|
1201
|
+
}
|
1202
|
+
var customAsyncMatchers =
|
1203
|
+
runnableResources[currentRunnable().id].customAsyncMatchers;
|
1204
|
+
for (var matcherName in matchersToAdd) {
|
1205
|
+
customAsyncMatchers[matcherName] = matchersToAdd[matcherName];
|
1206
|
+
}
|
1207
|
+
};
|
1208
|
+
|
985
1209
|
j$.Expectation.addCoreMatchers(j$.matchers);
|
986
1210
|
j$.Expectation.addAsyncCoreMatchers(j$.asyncMatchers);
|
987
1211
|
|
@@ -1013,6 +1237,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1013
1237
|
return j$.Expectation.asyncFactory({
|
1014
1238
|
util: j$.matchersUtil,
|
1015
1239
|
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
|
1240
|
+
customAsyncMatchers: runnableResources[spec.id].customAsyncMatchers,
|
1016
1241
|
actual: actual,
|
1017
1242
|
addExpectationResult: addExpectationResult
|
1018
1243
|
});
|
@@ -1023,19 +1248,35 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1023
1248
|
};
|
1024
1249
|
|
1025
1250
|
var defaultResourcesForRunnable = function(id, parentRunnableId) {
|
1026
|
-
var resources = {
|
1251
|
+
var resources = {
|
1252
|
+
spies: [],
|
1253
|
+
customEqualityTesters: [],
|
1254
|
+
customMatchers: {},
|
1255
|
+
customAsyncMatchers: {},
|
1256
|
+
customSpyStrategies: {},
|
1257
|
+
defaultStrategyFn: undefined
|
1258
|
+
};
|
1027
1259
|
|
1028
|
-
if(runnableResources[parentRunnableId]){
|
1029
|
-
resources.customEqualityTesters = j$.util.clone(
|
1030
|
-
|
1260
|
+
if (runnableResources[parentRunnableId]) {
|
1261
|
+
resources.customEqualityTesters = j$.util.clone(
|
1262
|
+
runnableResources[parentRunnableId].customEqualityTesters
|
1263
|
+
);
|
1264
|
+
resources.customMatchers = j$.util.clone(
|
1265
|
+
runnableResources[parentRunnableId].customMatchers
|
1266
|
+
);
|
1267
|
+
resources.customAsyncMatchers = j$.util.clone(
|
1268
|
+
runnableResources[parentRunnableId].customAsyncMatchers
|
1269
|
+
);
|
1270
|
+
resources.defaultStrategyFn =
|
1271
|
+
runnableResources[parentRunnableId].defaultStrategyFn;
|
1031
1272
|
}
|
1032
1273
|
|
1033
1274
|
runnableResources[id] = resources;
|
1034
1275
|
};
|
1035
1276
|
|
1036
1277
|
var clearResourcesForRunnable = function(id) {
|
1037
|
-
|
1038
|
-
|
1278
|
+
spyRegistry.clearSpies();
|
1279
|
+
delete runnableResources[id];
|
1039
1280
|
};
|
1040
1281
|
|
1041
1282
|
var beforeAndAfterFns = function(suite) {
|
@@ -1043,7 +1284,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1043
1284
|
var befores = [],
|
1044
1285
|
afters = [];
|
1045
1286
|
|
1046
|
-
while(suite) {
|
1287
|
+
while (suite) {
|
1047
1288
|
befores = befores.concat(suite.beforeFns);
|
1048
1289
|
afters = afters.concat(suite.afterFns);
|
1049
1290
|
|
@@ -1059,7 +1300,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1059
1300
|
|
1060
1301
|
var getSpecName = function(spec, suite) {
|
1061
1302
|
var fullName = [spec.description],
|
1062
|
-
|
1303
|
+
suiteFullName = suite.getFullName();
|
1063
1304
|
|
1064
1305
|
if (suiteFullName !== '') {
|
1065
1306
|
fullName.unshift(suiteFullName);
|
@@ -1069,78 +1310,93 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1069
1310
|
|
1070
1311
|
// TODO: we may just be able to pass in the fn instead of wrapping here
|
1071
1312
|
var buildExpectationResult = j$.buildExpectationResult,
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
return buildExpectationResult(attrs);
|
1078
|
-
};
|
1313
|
+
exceptionFormatter = new j$.ExceptionFormatter(),
|
1314
|
+
expectationResultFactory = function(attrs) {
|
1315
|
+
attrs.messageFormatter = exceptionFormatter.message;
|
1316
|
+
attrs.stackFormatter = exceptionFormatter.stack;
|
1079
1317
|
|
1080
|
-
|
1081
|
-
|
1318
|
+
return buildExpectationResult(attrs);
|
1319
|
+
};
|
1082
1320
|
|
1083
1321
|
/**
|
1084
1322
|
* Sets whether Jasmine should throw an Error when an expectation fails.
|
1085
1323
|
* This causes a spec to only have one expectation failure.
|
1086
1324
|
* @name Env#throwOnExpectationFailure
|
1325
|
+
* @since 2.3.0
|
1087
1326
|
* @function
|
1088
1327
|
* @param {Boolean} value Whether to throw when a expectation fails
|
1089
1328
|
* @deprecated Use the `oneFailurePerSpec` option with {@link Env#configure}
|
1090
1329
|
*/
|
1091
1330
|
this.throwOnExpectationFailure = function(value) {
|
1092
|
-
this.deprecated(
|
1093
|
-
|
1331
|
+
this.deprecated(
|
1332
|
+
'Setting throwOnExpectationFailure directly on Env is deprecated and will be removed in a future version of Jasmine, please use the oneFailurePerSpec option in `configure`'
|
1333
|
+
);
|
1334
|
+
this.configure({ oneFailurePerSpec: !!value });
|
1094
1335
|
};
|
1095
1336
|
|
1096
1337
|
this.throwingExpectationFailures = function() {
|
1097
|
-
this.deprecated(
|
1338
|
+
this.deprecated(
|
1339
|
+
'Getting throwingExpectationFailures directly from Env is deprecated and will be removed in a future version of Jasmine, please check the oneFailurePerSpec option from `configuration`'
|
1340
|
+
);
|
1098
1341
|
return config.oneFailurePerSpec;
|
1099
1342
|
};
|
1100
1343
|
|
1101
1344
|
/**
|
1102
1345
|
* Set whether to stop suite execution when a spec fails
|
1103
1346
|
* @name Env#stopOnSpecFailure
|
1347
|
+
* @since 2.7.0
|
1104
1348
|
* @function
|
1105
1349
|
* @param {Boolean} value Whether to stop suite execution when a spec fails
|
1106
1350
|
* @deprecated Use the `failFast` option with {@link Env#configure}
|
1107
1351
|
*/
|
1108
1352
|
this.stopOnSpecFailure = function(value) {
|
1109
|
-
this.deprecated(
|
1110
|
-
|
1353
|
+
this.deprecated(
|
1354
|
+
'Setting stopOnSpecFailure directly is deprecated and will be removed in a future version of Jasmine, please use the failFast option in `configure`'
|
1355
|
+
);
|
1356
|
+
this.configure({ failFast: !!value });
|
1111
1357
|
};
|
1112
1358
|
|
1113
1359
|
this.stoppingOnSpecFailure = function() {
|
1114
|
-
this.deprecated(
|
1360
|
+
this.deprecated(
|
1361
|
+
'Getting stoppingOnSpecFailure directly from Env is deprecated and will be removed in a future version of Jasmine, please check the failFast option from `configuration`'
|
1362
|
+
);
|
1115
1363
|
return config.failFast;
|
1116
1364
|
};
|
1117
1365
|
|
1118
1366
|
/**
|
1119
1367
|
* Set whether to randomize test execution order
|
1120
1368
|
* @name Env#randomizeTests
|
1369
|
+
* @since 2.4.0
|
1121
1370
|
* @function
|
1122
1371
|
* @param {Boolean} value Whether to randomize execution order
|
1123
1372
|
* @deprecated Use the `random` option with {@link Env#configure}
|
1124
1373
|
*/
|
1125
1374
|
this.randomizeTests = function(value) {
|
1126
|
-
this.deprecated(
|
1375
|
+
this.deprecated(
|
1376
|
+
'Setting randomizeTests directly is deprecated and will be removed in a future version of Jasmine, please use the random option in `configure`'
|
1377
|
+
);
|
1127
1378
|
config.random = !!value;
|
1128
1379
|
};
|
1129
1380
|
|
1130
1381
|
this.randomTests = function() {
|
1131
|
-
this.deprecated(
|
1382
|
+
this.deprecated(
|
1383
|
+
'Getting randomTests directly from Env is deprecated and will be removed in a future version of Jasmine, please check the random option from `configuration`'
|
1384
|
+
);
|
1132
1385
|
return config.random;
|
1133
1386
|
};
|
1134
1387
|
|
1135
1388
|
/**
|
1136
1389
|
* Set the random number seed for spec randomization
|
1137
1390
|
* @name Env#seed
|
1391
|
+
* @since 2.4.0
|
1138
1392
|
* @function
|
1139
1393
|
* @param {Number} value The seed value
|
1140
1394
|
* @deprecated Use the `seed` option with {@link Env#configure}
|
1141
1395
|
*/
|
1142
1396
|
this.seed = function(value) {
|
1143
|
-
this.deprecated(
|
1397
|
+
this.deprecated(
|
1398
|
+
'Setting seed directly is deprecated and will be removed in a future version of Jasmine, please use the seed option in `configure`'
|
1399
|
+
);
|
1144
1400
|
if (value) {
|
1145
1401
|
config.seed = value;
|
1146
1402
|
}
|
@@ -1148,23 +1404,31 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1148
1404
|
};
|
1149
1405
|
|
1150
1406
|
this.hidingDisabled = function(value) {
|
1151
|
-
this.deprecated(
|
1407
|
+
this.deprecated(
|
1408
|
+
'Getting hidingDisabled directly from Env is deprecated and will be removed in a future version of Jasmine, please check the hideDisabled option from `configuration`'
|
1409
|
+
);
|
1152
1410
|
return config.hideDisabled;
|
1153
1411
|
};
|
1154
1412
|
|
1155
1413
|
/**
|
1156
1414
|
* @name Env#hideDisabled
|
1415
|
+
* @since 3.2.0
|
1157
1416
|
* @function
|
1158
1417
|
*/
|
1159
1418
|
this.hideDisabled = function(value) {
|
1160
|
-
this.deprecated(
|
1419
|
+
this.deprecated(
|
1420
|
+
'Setting hideDisabled directly is deprecated and will be removed in a future version of Jasmine, please use the hideDisabled option in `configure`'
|
1421
|
+
);
|
1161
1422
|
config.hideDisabled = !!value;
|
1162
1423
|
};
|
1163
1424
|
|
1164
1425
|
this.deprecated = function(deprecation) {
|
1165
1426
|
var runnable = currentRunnable() || topSuite;
|
1166
1427
|
runnable.addDeprecationWarning(deprecation);
|
1167
|
-
if(
|
1428
|
+
if (
|
1429
|
+
typeof console !== 'undefined' &&
|
1430
|
+
typeof console.error === 'function'
|
1431
|
+
) {
|
1168
1432
|
console.error('DEPRECATION:', deprecation);
|
1169
1433
|
}
|
1170
1434
|
};
|
@@ -1177,13 +1441,18 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1177
1441
|
failFast = config.failFast;
|
1178
1442
|
}
|
1179
1443
|
options.clearStack = options.clearStack || clearStack;
|
1180
|
-
options.timeout = {
|
1444
|
+
options.timeout = {
|
1445
|
+
setTimeout: realSetTimeout,
|
1446
|
+
clearTimeout: realClearTimeout
|
1447
|
+
};
|
1181
1448
|
options.fail = self.fail;
|
1182
1449
|
options.globalErrors = globalErrors;
|
1183
1450
|
options.completeOnFirstError = failFast;
|
1184
|
-
options.onException =
|
1185
|
-
|
1186
|
-
|
1451
|
+
options.onException =
|
1452
|
+
options.onException ||
|
1453
|
+
function(e) {
|
1454
|
+
(currentRunnable() || topSuite).onException(e);
|
1455
|
+
};
|
1187
1456
|
options.deprecated = self.deprecated;
|
1188
1457
|
|
1189
1458
|
new j$.QueueRunner(options).execute(args);
|
@@ -1209,78 +1478,80 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1209
1478
|
* @interface Reporter
|
1210
1479
|
* @see custom_reporter
|
1211
1480
|
*/
|
1212
|
-
var reporter = new j$.ReportDispatcher(
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1481
|
+
var reporter = new j$.ReportDispatcher(
|
1482
|
+
[
|
1483
|
+
/**
|
1484
|
+
* `jasmineStarted` is called after all of the specs have been loaded, but just before execution starts.
|
1485
|
+
* @function
|
1486
|
+
* @name Reporter#jasmineStarted
|
1487
|
+
* @param {JasmineStartedInfo} suiteInfo Information about the full Jasmine suite that is being run
|
1488
|
+
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
1489
|
+
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
1490
|
+
* @see async
|
1491
|
+
*/
|
1492
|
+
'jasmineStarted',
|
1493
|
+
/**
|
1494
|
+
* When the entire suite has finished execution `jasmineDone` is called
|
1495
|
+
* @function
|
1496
|
+
* @name Reporter#jasmineDone
|
1497
|
+
* @param {JasmineDoneInfo} suiteInfo Information about the full Jasmine suite that just finished running.
|
1498
|
+
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
1499
|
+
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
1500
|
+
* @see async
|
1501
|
+
*/
|
1502
|
+
'jasmineDone',
|
1503
|
+
/**
|
1504
|
+
* `suiteStarted` is invoked when a `describe` starts to run
|
1505
|
+
* @function
|
1506
|
+
* @name Reporter#suiteStarted
|
1507
|
+
* @param {SuiteResult} result Information about the individual {@link describe} being run
|
1508
|
+
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
1509
|
+
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
1510
|
+
* @see async
|
1511
|
+
*/
|
1512
|
+
'suiteStarted',
|
1513
|
+
/**
|
1514
|
+
* `suiteDone` is invoked when all of the child specs and suites for a given suite have been run
|
1515
|
+
*
|
1516
|
+
* While jasmine doesn't require any specific functions, not defining a `suiteDone` will make it impossible for a reporter to know when a suite has failures in an `afterAll`.
|
1517
|
+
* @function
|
1518
|
+
* @name Reporter#suiteDone
|
1519
|
+
* @param {SuiteResult} result
|
1520
|
+
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
1521
|
+
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
1522
|
+
* @see async
|
1523
|
+
*/
|
1524
|
+
'suiteDone',
|
1525
|
+
/**
|
1526
|
+
* `specStarted` is invoked when an `it` starts to run (including associated `beforeEach` functions)
|
1527
|
+
* @function
|
1528
|
+
* @name Reporter#specStarted
|
1529
|
+
* @param {SpecResult} result Information about the individual {@link it} being run
|
1530
|
+
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
1531
|
+
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
1532
|
+
* @see async
|
1533
|
+
*/
|
1534
|
+
'specStarted',
|
1535
|
+
/**
|
1536
|
+
* `specDone` is invoked when an `it` and its associated `beforeEach` and `afterEach` functions have been run.
|
1537
|
+
*
|
1538
|
+
* While jasmine doesn't require any specific functions, not defining a `specDone` will make it impossible for a reporter to know when a spec has failed.
|
1539
|
+
* @function
|
1540
|
+
* @name Reporter#specDone
|
1541
|
+
* @param {SpecResult} result
|
1542
|
+
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
1543
|
+
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
1544
|
+
* @see async
|
1545
|
+
*/
|
1546
|
+
'specDone'
|
1547
|
+
],
|
1548
|
+
queueRunnerFactory
|
1549
|
+
);
|
1278
1550
|
|
1279
1551
|
this.execute = function(runnablesToRun) {
|
1280
|
-
var self = this;
|
1281
1552
|
installGlobalErrors();
|
1282
1553
|
|
1283
|
-
if(!runnablesToRun) {
|
1554
|
+
if (!runnablesToRun) {
|
1284
1555
|
if (focusedRunnables.length) {
|
1285
1556
|
runnablesToRun = focusedRunnables;
|
1286
1557
|
} else {
|
@@ -1297,6 +1568,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1297
1568
|
tree: topSuite,
|
1298
1569
|
runnableIds: runnablesToRun,
|
1299
1570
|
queueRunnerFactory: queueRunnerFactory,
|
1571
|
+
failSpecWithNoExpectations: config.failSpecWithNoExpectations,
|
1300
1572
|
nodeStart: function(suite, next) {
|
1301
1573
|
currentlyExecutingSuites.push(suite);
|
1302
1574
|
defaultResourcesForRunnable(suite.id, suite.parentSuite.id);
|
@@ -1325,62 +1597,76 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1325
1597
|
}
|
1326
1598
|
});
|
1327
1599
|
|
1328
|
-
if(!processor.processTree().valid) {
|
1329
|
-
throw new Error(
|
1600
|
+
if (!processor.processTree().valid) {
|
1601
|
+
throw new Error(
|
1602
|
+
'Invalid order: would cause a beforeAll or afterAll to be run multiple times'
|
1603
|
+
);
|
1330
1604
|
}
|
1331
1605
|
|
1606
|
+
var jasmineTimer = new j$.Timer();
|
1607
|
+
jasmineTimer.start();
|
1608
|
+
|
1332
1609
|
/**
|
1333
1610
|
* Information passed to the {@link Reporter#jasmineStarted} event.
|
1334
1611
|
* @typedef JasmineStartedInfo
|
1335
1612
|
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
|
1336
1613
|
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
1337
1614
|
*/
|
1338
|
-
reporter.jasmineStarted(
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1615
|
+
reporter.jasmineStarted(
|
1616
|
+
{
|
1617
|
+
totalSpecsDefined: totalSpecsDefined,
|
1618
|
+
order: order
|
1619
|
+
},
|
1620
|
+
function() {
|
1621
|
+
currentlyExecutingSuites.push(topSuite);
|
1622
|
+
|
1623
|
+
processor.execute(function() {
|
1624
|
+
clearResourcesForRunnable(topSuite.id);
|
1625
|
+
currentlyExecutingSuites.pop();
|
1626
|
+
var overallStatus, incompleteReason;
|
1627
|
+
|
1628
|
+
if (hasFailures || topSuite.result.failedExpectations.length > 0) {
|
1629
|
+
overallStatus = 'failed';
|
1630
|
+
} else if (focusedRunnables.length > 0) {
|
1631
|
+
overallStatus = 'incomplete';
|
1632
|
+
incompleteReason = 'fit() or fdescribe() was found';
|
1633
|
+
} else if (totalSpecsDefined === 0) {
|
1634
|
+
overallStatus = 'incomplete';
|
1635
|
+
incompleteReason = 'No specs found';
|
1636
|
+
} else {
|
1637
|
+
overallStatus = 'passed';
|
1638
|
+
}
|
1360
1639
|
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1640
|
+
/**
|
1641
|
+
* Information passed to the {@link Reporter#jasmineDone} event.
|
1642
|
+
* @typedef JasmineDoneInfo
|
1643
|
+
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
|
1644
|
+
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
|
1645
|
+
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
|
1646
|
+
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
1647
|
+
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
1648
|
+
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
|
1649
|
+
*/
|
1650
|
+
reporter.jasmineDone(
|
1651
|
+
{
|
1652
|
+
overallStatus: overallStatus,
|
1653
|
+
totalTime: jasmineTimer.elapsed(),
|
1654
|
+
incompleteReason: incompleteReason,
|
1655
|
+
order: order,
|
1656
|
+
failedExpectations: topSuite.result.failedExpectations,
|
1657
|
+
deprecationWarnings: topSuite.result.deprecationWarnings
|
1658
|
+
},
|
1659
|
+
function() {}
|
1660
|
+
);
|
1661
|
+
});
|
1662
|
+
}
|
1663
|
+
);
|
1379
1664
|
};
|
1380
1665
|
|
1381
1666
|
/**
|
1382
1667
|
* Add a custom reporter to the Jasmine environment.
|
1383
1668
|
* @name Env#addReporter
|
1669
|
+
* @since 2.0.0
|
1384
1670
|
* @function
|
1385
1671
|
* @param {Reporter} reporterToAdd The reporter to be added.
|
1386
1672
|
* @see custom_reporter
|
@@ -1392,6 +1678,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1392
1678
|
/**
|
1393
1679
|
* Provide a fallback reporter if no other reporters have been specified.
|
1394
1680
|
* @name Env#provideFallbackReporter
|
1681
|
+
* @since 2.5.0
|
1395
1682
|
* @function
|
1396
1683
|
* @param {Reporter} reporterToAdd The reporter
|
1397
1684
|
* @see custom_reporter
|
@@ -1403,26 +1690,43 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1403
1690
|
/**
|
1404
1691
|
* Clear all registered reporters
|
1405
1692
|
* @name Env#clearReporters
|
1693
|
+
* @since 2.5.2
|
1406
1694
|
* @function
|
1407
1695
|
*/
|
1408
1696
|
this.clearReporters = function() {
|
1409
1697
|
reporter.clearReporters();
|
1410
1698
|
};
|
1411
1699
|
|
1412
|
-
var spyFactory = new j$.SpyFactory(
|
1413
|
-
|
1700
|
+
var spyFactory = new j$.SpyFactory(
|
1701
|
+
function getCustomStrategies() {
|
1702
|
+
var runnable = currentRunnable();
|
1414
1703
|
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1704
|
+
if (runnable) {
|
1705
|
+
return runnableResources[runnable.id].customSpyStrategies;
|
1706
|
+
}
|
1418
1707
|
|
1419
|
-
|
1420
|
-
|
1708
|
+
return {};
|
1709
|
+
},
|
1710
|
+
function getDefaultStrategyFn() {
|
1711
|
+
var runnable = currentRunnable();
|
1712
|
+
|
1713
|
+
if (runnable) {
|
1714
|
+
return runnableResources[runnable.id].defaultStrategyFn;
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
return undefined;
|
1718
|
+
},
|
1719
|
+
function getPromise() {
|
1720
|
+
return customPromise || global.Promise;
|
1721
|
+
}
|
1722
|
+
);
|
1421
1723
|
|
1422
1724
|
var spyRegistry = new j$.SpyRegistry({
|
1423
1725
|
currentSpies: function() {
|
1424
|
-
if(!currentRunnable()) {
|
1425
|
-
throw new Error(
|
1726
|
+
if (!currentRunnable()) {
|
1727
|
+
throw new Error(
|
1728
|
+
'Spies must be created in a before function or a spec'
|
1729
|
+
);
|
1426
1730
|
}
|
1427
1731
|
return runnableResources[currentRunnable().id].spies;
|
1428
1732
|
},
|
@@ -1431,7 +1735,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1431
1735
|
}
|
1432
1736
|
});
|
1433
1737
|
|
1434
|
-
this.allowRespy = function(allow){
|
1738
|
+
this.allowRespy = function(allow) {
|
1435
1739
|
spyRegistry.allowRespy(allow);
|
1436
1740
|
};
|
1437
1741
|
|
@@ -1456,26 +1760,32 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1456
1760
|
return spyFactory.createSpy(name, originalFn);
|
1457
1761
|
};
|
1458
1762
|
|
1459
|
-
this.createSpyObj = function(baseName, methodNames) {
|
1460
|
-
return spyFactory.createSpyObj(baseName, methodNames);
|
1763
|
+
this.createSpyObj = function(baseName, methodNames, propertyNames) {
|
1764
|
+
return spyFactory.createSpyObj(baseName, methodNames, propertyNames);
|
1461
1765
|
};
|
1462
1766
|
|
1463
1767
|
var ensureIsFunction = function(fn, caller) {
|
1464
1768
|
if (!j$.isFunction_(fn)) {
|
1465
|
-
throw new Error(
|
1769
|
+
throw new Error(
|
1770
|
+
caller + ' expects a function argument; received ' + j$.getType_(fn)
|
1771
|
+
);
|
1466
1772
|
}
|
1467
1773
|
};
|
1468
1774
|
|
1469
1775
|
var ensureIsFunctionOrAsync = function(fn, caller) {
|
1470
1776
|
if (!j$.isFunction_(fn) && !j$.isAsyncFunction_(fn)) {
|
1471
|
-
throw new Error(
|
1777
|
+
throw new Error(
|
1778
|
+
caller + ' expects a function argument; received ' + j$.getType_(fn)
|
1779
|
+
);
|
1472
1780
|
}
|
1473
1781
|
};
|
1474
1782
|
|
1475
1783
|
function ensureIsNotNested(method) {
|
1476
1784
|
var runnable = currentRunnable();
|
1477
1785
|
if (runnable !== null && runnable !== undefined) {
|
1478
|
-
throw new Error(
|
1786
|
+
throw new Error(
|
1787
|
+
"'" + method + "' should only be used in 'describe' function"
|
1788
|
+
);
|
1479
1789
|
}
|
1480
1790
|
}
|
1481
1791
|
|
@@ -1589,13 +1899,15 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1589
1899
|
description: description,
|
1590
1900
|
expectationResultFactory: expectationResultFactory,
|
1591
1901
|
queueRunnerFactory: queueRunnerFactory,
|
1592
|
-
userContext: function() {
|
1902
|
+
userContext: function() {
|
1903
|
+
return suite.clonedSharedUserContext();
|
1904
|
+
},
|
1593
1905
|
queueableFn: {
|
1594
1906
|
fn: fn,
|
1595
1907
|
timeout: timeout || 0
|
1596
1908
|
},
|
1597
1909
|
throwOnExpectationFailure: config.oneFailurePerSpec,
|
1598
|
-
timer: new j$.Timer()
|
1910
|
+
timer: new j$.Timer()
|
1599
1911
|
});
|
1600
1912
|
return spec;
|
1601
1913
|
|
@@ -1644,7 +1956,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1644
1956
|
return spec;
|
1645
1957
|
};
|
1646
1958
|
|
1647
|
-
this.fit = function(description, fn, timeout){
|
1959
|
+
this.fit = function(description, fn, timeout) {
|
1648
1960
|
ensureIsNotNested('fit');
|
1649
1961
|
ensureIsFunctionOrAsync(fn, 'fit');
|
1650
1962
|
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
|
@@ -1656,7 +1968,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1656
1968
|
|
1657
1969
|
this.expect = function(actual) {
|
1658
1970
|
if (!currentRunnable()) {
|
1659
|
-
throw new Error(
|
1971
|
+
throw new Error(
|
1972
|
+
"'expect' was used when there was no current spec, this could be because an asynchronous test timed out"
|
1973
|
+
);
|
1660
1974
|
}
|
1661
1975
|
|
1662
1976
|
return currentRunnable().expect(actual);
|
@@ -1664,7 +1978,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1664
1978
|
|
1665
1979
|
this.expectAsync = function(actual) {
|
1666
1980
|
if (!currentRunnable()) {
|
1667
|
-
throw new Error(
|
1981
|
+
throw new Error(
|
1982
|
+
"'expectAsync' was used when there was no current spec, this could be because an asynchronous test timed out"
|
1983
|
+
);
|
1668
1984
|
}
|
1669
1985
|
|
1670
1986
|
return currentRunnable().expectAsync(actual);
|
@@ -1709,7 +2025,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1709
2025
|
|
1710
2026
|
this.pending = function(message) {
|
1711
2027
|
var fullMessage = j$.Spec.pendingSpecExceptionMessage;
|
1712
|
-
if(message) {
|
2028
|
+
if (message) {
|
1713
2029
|
fullMessage += message;
|
1714
2030
|
}
|
1715
2031
|
throw fullMessage;
|
@@ -1717,7 +2033,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1717
2033
|
|
1718
2034
|
this.fail = function(error) {
|
1719
2035
|
if (!currentRunnable()) {
|
1720
|
-
throw new Error(
|
2036
|
+
throw new Error(
|
2037
|
+
"'fail' was used when there was no current spec, this could be because an asynchronous test timed out"
|
2038
|
+
);
|
1721
2039
|
}
|
1722
2040
|
|
1723
2041
|
var message = 'Failed';
|
@@ -1760,7 +2078,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
|
1760
2078
|
*/
|
1761
2079
|
function JsApiReporter(options) {
|
1762
2080
|
var timer = options.timer || j$.noopTimer,
|
1763
|
-
|
2081
|
+
status = 'loaded';
|
1764
2082
|
|
1765
2083
|
this.started = false;
|
1766
2084
|
this.finished = false;
|
@@ -1784,6 +2102,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
|
1784
2102
|
/**
|
1785
2103
|
* Get the current status for the Jasmine environment.
|
1786
2104
|
* @name jsApiReporter#status
|
2105
|
+
* @since 2.0.0
|
1787
2106
|
* @function
|
1788
2107
|
* @return {String} - One of `loaded`, `started`, or `done`
|
1789
2108
|
*/
|
@@ -1807,6 +2126,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
|
1807
2126
|
*
|
1808
2127
|
* Retrievable in slices for easier serialization.
|
1809
2128
|
* @name jsApiReporter#suiteResults
|
2129
|
+
* @since 2.1.0
|
1810
2130
|
* @function
|
1811
2131
|
* @param {Number} index - The position in the suites list to start from.
|
1812
2132
|
* @param {Number} length - Maximum number of suite results to return.
|
@@ -1824,6 +2144,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
|
1824
2144
|
/**
|
1825
2145
|
* Get all of the suites in a single object, with their `id` as the key.
|
1826
2146
|
* @name jsApiReporter#suites
|
2147
|
+
* @since 2.0.0
|
1827
2148
|
* @function
|
1828
2149
|
* @return {Object} - Map of suite id to {@link SuiteResult}
|
1829
2150
|
*/
|
@@ -1842,6 +2163,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
|
1842
2163
|
*
|
1843
2164
|
* Retrievable in slices for easier serialization.
|
1844
2165
|
* @name jsApiReporter#specResults
|
2166
|
+
* @since 2.0.0
|
1845
2167
|
* @function
|
1846
2168
|
* @param {Number} index - The position in the specs list to start from.
|
1847
2169
|
* @param {Number} length - Maximum number of specs results to return.
|
@@ -1854,6 +2176,7 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
|
1854
2176
|
/**
|
1855
2177
|
* Get all spec results.
|
1856
2178
|
* @name jsApiReporter#specs
|
2179
|
+
* @since 2.0.0
|
1857
2180
|
* @function
|
1858
2181
|
* @return {SpecResult[]}
|
1859
2182
|
*/
|
@@ -1864,13 +2187,13 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
|
1864
2187
|
/**
|
1865
2188
|
* Get the number of milliseconds it took for the full Jasmine suite to run.
|
1866
2189
|
* @name jsApiReporter#executionTime
|
2190
|
+
* @since 2.0.0
|
1867
2191
|
* @function
|
1868
2192
|
* @return {Number}
|
1869
2193
|
*/
|
1870
2194
|
this.executionTime = function() {
|
1871
2195
|
return executionTime;
|
1872
2196
|
};
|
1873
|
-
|
1874
2197
|
}
|
1875
2198
|
|
1876
2199
|
return JsApiReporter;
|
@@ -1951,6 +2274,13 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
|
|
1951
2274
|
throw new Error('You must provide an array to arrayContaining, not ' + j$.pp(this.sample) + '.');
|
1952
2275
|
}
|
1953
2276
|
|
2277
|
+
// If the actual parameter is not an array, we can fail immediately, since it couldn't
|
2278
|
+
// possibly be an "array containing" anything. However, we also want an empty sample
|
2279
|
+
// array to match anything, so we need to double-check we aren't in that case
|
2280
|
+
if (!j$.isArray_(other) && this.sample.length > 0) {
|
2281
|
+
return false;
|
2282
|
+
}
|
2283
|
+
|
1954
2284
|
for (var i = 0; i < this.sample.length; i++) {
|
1955
2285
|
var item = this.sample[i];
|
1956
2286
|
if (!j$.matchersUtil.contains(other, item, customTesters)) {
|
@@ -2041,6 +2371,48 @@ getJasmineRequireObj().Falsy = function(j$) {
|
|
2041
2371
|
return Falsy;
|
2042
2372
|
};
|
2043
2373
|
|
2374
|
+
getJasmineRequireObj().MapContaining = function(j$) {
|
2375
|
+
function MapContaining(sample) {
|
2376
|
+
if (!j$.isMap(sample)) {
|
2377
|
+
throw new Error('You must provide a map to `mapContaining`, not ' + j$.pp(sample));
|
2378
|
+
}
|
2379
|
+
|
2380
|
+
this.sample = sample;
|
2381
|
+
}
|
2382
|
+
|
2383
|
+
MapContaining.prototype.asymmetricMatch = function(other, customTesters) {
|
2384
|
+
if (!j$.isMap(other)) return false;
|
2385
|
+
|
2386
|
+
var hasAllMatches = true;
|
2387
|
+
j$.util.forEachBreakable(this.sample, function(breakLoop, value, key) {
|
2388
|
+
// for each key/value pair in `sample`
|
2389
|
+
// there should be at least one pair in `other` whose key and value both match
|
2390
|
+
var hasMatch = false;
|
2391
|
+
j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) {
|
2392
|
+
if (
|
2393
|
+
j$.matchersUtil.equals(oKey, key, customTesters)
|
2394
|
+
&& j$.matchersUtil.equals(oValue, value, customTesters)
|
2395
|
+
) {
|
2396
|
+
hasMatch = true;
|
2397
|
+
oBreakLoop();
|
2398
|
+
}
|
2399
|
+
});
|
2400
|
+
if (!hasMatch) {
|
2401
|
+
hasAllMatches = false;
|
2402
|
+
breakLoop();
|
2403
|
+
}
|
2404
|
+
});
|
2405
|
+
|
2406
|
+
return hasAllMatches;
|
2407
|
+
};
|
2408
|
+
|
2409
|
+
MapContaining.prototype.jasmineToString = function() {
|
2410
|
+
return '<jasmine.mapContaining(' + j$.pp(this.sample) + ')>';
|
2411
|
+
};
|
2412
|
+
|
2413
|
+
return MapContaining;
|
2414
|
+
};
|
2415
|
+
|
2044
2416
|
getJasmineRequireObj().NotEmpty = function (j$) {
|
2045
2417
|
|
2046
2418
|
function NotEmpty() {}
|
@@ -2118,6 +2490,46 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
|
2118
2490
|
return ObjectContaining;
|
2119
2491
|
};
|
2120
2492
|
|
2493
|
+
getJasmineRequireObj().SetContaining = function(j$) {
|
2494
|
+
function SetContaining(sample) {
|
2495
|
+
if (!j$.isSet(sample)) {
|
2496
|
+
throw new Error('You must provide a set to `setContaining`, not ' + j$.pp(sample));
|
2497
|
+
}
|
2498
|
+
|
2499
|
+
this.sample = sample;
|
2500
|
+
}
|
2501
|
+
|
2502
|
+
SetContaining.prototype.asymmetricMatch = function(other, customTesters) {
|
2503
|
+
if (!j$.isSet(other)) return false;
|
2504
|
+
|
2505
|
+
var hasAllMatches = true;
|
2506
|
+
j$.util.forEachBreakable(this.sample, function(breakLoop, item) {
|
2507
|
+
// for each item in `sample` there should be at least one matching item in `other`
|
2508
|
+
// (not using `j$.matchersUtil.contains` because it compares set members by reference,
|
2509
|
+
// not by deep value equality)
|
2510
|
+
var hasMatch = false;
|
2511
|
+
j$.util.forEachBreakable(other, function(oBreakLoop, oItem) {
|
2512
|
+
if (j$.matchersUtil.equals(oItem, item, customTesters)) {
|
2513
|
+
hasMatch = true;
|
2514
|
+
oBreakLoop();
|
2515
|
+
}
|
2516
|
+
});
|
2517
|
+
if (!hasMatch) {
|
2518
|
+
hasAllMatches = false;
|
2519
|
+
breakLoop();
|
2520
|
+
}
|
2521
|
+
});
|
2522
|
+
|
2523
|
+
return hasAllMatches;
|
2524
|
+
};
|
2525
|
+
|
2526
|
+
SetContaining.prototype.jasmineToString = function() {
|
2527
|
+
return '<jasmine.setContaining(' + j$.pp(this.sample) + ')>';
|
2528
|
+
};
|
2529
|
+
|
2530
|
+
return SetContaining;
|
2531
|
+
};
|
2532
|
+
|
2121
2533
|
getJasmineRequireObj().StringMatching = function(j$) {
|
2122
2534
|
|
2123
2535
|
function StringMatching(expected) {
|
@@ -2155,16 +2567,16 @@ getJasmineRequireObj().Truthy = function(j$) {
|
|
2155
2567
|
};
|
2156
2568
|
|
2157
2569
|
getJasmineRequireObj().CallTracker = function(j$) {
|
2158
|
-
|
2159
2570
|
/**
|
2160
2571
|
* @namespace Spy#calls
|
2572
|
+
* @since 2.0.0
|
2161
2573
|
*/
|
2162
2574
|
function CallTracker() {
|
2163
2575
|
var calls = [];
|
2164
2576
|
var opts = {};
|
2165
2577
|
|
2166
2578
|
this.track = function(context) {
|
2167
|
-
if(opts.cloneArgs) {
|
2579
|
+
if (opts.cloneArgs) {
|
2168
2580
|
context.args = j$.util.cloneArgs(context.args);
|
2169
2581
|
}
|
2170
2582
|
calls.push(context);
|
@@ -2173,6 +2585,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
2173
2585
|
/**
|
2174
2586
|
* Check whether this spy has been invoked.
|
2175
2587
|
* @name Spy#calls#any
|
2588
|
+
* @since 2.0.0
|
2176
2589
|
* @function
|
2177
2590
|
* @return {Boolean}
|
2178
2591
|
*/
|
@@ -2183,6 +2596,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
2183
2596
|
/**
|
2184
2597
|
* Get the number of invocations of this spy.
|
2185
2598
|
* @name Spy#calls#count
|
2599
|
+
* @since 2.0.0
|
2186
2600
|
* @function
|
2187
2601
|
* @return {Integer}
|
2188
2602
|
*/
|
@@ -2193,6 +2607,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
2193
2607
|
/**
|
2194
2608
|
* Get the arguments that were passed to a specific invocation of this spy.
|
2195
2609
|
* @name Spy#calls#argsFor
|
2610
|
+
* @since 2.0.0
|
2196
2611
|
* @function
|
2197
2612
|
* @param {Integer} index The 0-based invocation index.
|
2198
2613
|
* @return {Array}
|
@@ -2205,6 +2620,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
2205
2620
|
/**
|
2206
2621
|
* Get the raw calls array for this spy.
|
2207
2622
|
* @name Spy#calls#all
|
2623
|
+
* @since 2.0.0
|
2208
2624
|
* @function
|
2209
2625
|
* @return {Spy.callData[]}
|
2210
2626
|
*/
|
@@ -2215,12 +2631,13 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
2215
2631
|
/**
|
2216
2632
|
* Get all of the arguments for each invocation of this spy in the order they were received.
|
2217
2633
|
* @name Spy#calls#allArgs
|
2634
|
+
* @since 2.0.0
|
2218
2635
|
* @function
|
2219
2636
|
* @return {Array}
|
2220
2637
|
*/
|
2221
2638
|
this.allArgs = function() {
|
2222
2639
|
var callArgs = [];
|
2223
|
-
for(var i = 0; i < calls.length; i++){
|
2640
|
+
for (var i = 0; i < calls.length; i++) {
|
2224
2641
|
callArgs.push(calls[i].args);
|
2225
2642
|
}
|
2226
2643
|
|
@@ -2230,6 +2647,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
2230
2647
|
/**
|
2231
2648
|
* Get the first invocation of this spy.
|
2232
2649
|
* @name Spy#calls#first
|
2650
|
+
* @since 2.0.0
|
2233
2651
|
* @function
|
2234
2652
|
* @return {ObjecSpy.callData}
|
2235
2653
|
*/
|
@@ -2240,6 +2658,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
2240
2658
|
/**
|
2241
2659
|
* Get the most recent invocation of this spy.
|
2242
2660
|
* @name Spy#calls#mostRecent
|
2661
|
+
* @since 2.0.0
|
2243
2662
|
* @function
|
2244
2663
|
* @return {ObjecSpy.callData}
|
2245
2664
|
*/
|
@@ -2250,6 +2669,7 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
2250
2669
|
/**
|
2251
2670
|
* Reset this spy as if it has never been called.
|
2252
2671
|
* @name Spy#calls#reset
|
2672
|
+
* @since 2.0.0
|
2253
2673
|
* @function
|
2254
2674
|
*/
|
2255
2675
|
this.reset = function() {
|
@@ -2259,12 +2679,12 @@ getJasmineRequireObj().CallTracker = function(j$) {
|
|
2259
2679
|
/**
|
2260
2680
|
* Set this spy to do a shallow clone of arguments passed to each invocation.
|
2261
2681
|
* @name Spy#calls#saveArgumentsByValue
|
2682
|
+
* @since 2.5.0
|
2262
2683
|
* @function
|
2263
2684
|
*/
|
2264
2685
|
this.saveArgumentsByValue = function() {
|
2265
2686
|
opts.cloneArgs = true;
|
2266
2687
|
};
|
2267
|
-
|
2268
2688
|
}
|
2269
2689
|
|
2270
2690
|
return CallTracker;
|
@@ -2275,8 +2695,8 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|
2275
2695
|
|
2276
2696
|
function messageChannelImpl(global, setTimeout) {
|
2277
2697
|
var channel = new global.MessageChannel(),
|
2278
|
-
|
2279
|
-
|
2698
|
+
head = {},
|
2699
|
+
tail = head;
|
2280
2700
|
|
2281
2701
|
var taskRunning = false;
|
2282
2702
|
channel.port1.onmessage = function() {
|
@@ -2314,7 +2734,7 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|
2314
2734
|
var currentCallCount = 0;
|
2315
2735
|
var realSetTimeout = global.setTimeout;
|
2316
2736
|
var setTimeoutImpl = function clearStack(fn) {
|
2317
|
-
|
2737
|
+
Function.prototype.apply.apply(realSetTimeout, [global, [fn, 0]]);
|
2318
2738
|
};
|
2319
2739
|
|
2320
2740
|
if (j$.isFunction_(global.setImmediate)) {
|
@@ -2341,9 +2761,11 @@ getJasmineRequireObj().clearStack = function(j$) {
|
|
2341
2761
|
};
|
2342
2762
|
|
2343
2763
|
getJasmineRequireObj().Clock = function() {
|
2344
|
-
|
2345
2764
|
/* global process */
|
2346
|
-
var NODE_JS =
|
2765
|
+
var NODE_JS =
|
2766
|
+
typeof process !== 'undefined' &&
|
2767
|
+
process.versions &&
|
2768
|
+
typeof process.versions.node === 'string';
|
2347
2769
|
|
2348
2770
|
/**
|
2349
2771
|
* _Note:_ Do not construct this directly, Jasmine will make one during booting. You can get the current clock with {@link jasmine.clock}.
|
@@ -2373,12 +2795,15 @@ getJasmineRequireObj().Clock = function() {
|
|
2373
2795
|
/**
|
2374
2796
|
* Install the mock clock over the built-in methods.
|
2375
2797
|
* @name Clock#install
|
2798
|
+
* @since 2.0.0
|
2376
2799
|
* @function
|
2377
2800
|
* @return {Clock}
|
2378
2801
|
*/
|
2379
2802
|
self.install = function() {
|
2380
|
-
if(!originalTimingFunctionsIntact()) {
|
2381
|
-
throw new Error(
|
2803
|
+
if (!originalTimingFunctionsIntact()) {
|
2804
|
+
throw new Error(
|
2805
|
+
'Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?'
|
2806
|
+
);
|
2382
2807
|
}
|
2383
2808
|
replace(global, fakeTimingFunctions);
|
2384
2809
|
timer = fakeTimingFunctions;
|
@@ -2391,6 +2816,7 @@ getJasmineRequireObj().Clock = function() {
|
|
2391
2816
|
/**
|
2392
2817
|
* Uninstall the mock clock, returning the built-in methods to their places.
|
2393
2818
|
* @name Clock#uninstall
|
2819
|
+
* @since 2.0.0
|
2394
2820
|
* @function
|
2395
2821
|
*/
|
2396
2822
|
self.uninstall = function() {
|
@@ -2407,6 +2833,7 @@ getJasmineRequireObj().Clock = function() {
|
|
2407
2833
|
*
|
2408
2834
|
* The clock will be {@link Clock#install|install}ed before the function is called and {@link Clock#uninstall|uninstall}ed in a `finally` after the function completes.
|
2409
2835
|
* @name Clock#withMock
|
2836
|
+
* @since 2.3.0
|
2410
2837
|
* @function
|
2411
2838
|
* @param {Function} closure The function to be called.
|
2412
2839
|
*/
|
@@ -2422,6 +2849,7 @@ getJasmineRequireObj().Clock = function() {
|
|
2422
2849
|
/**
|
2423
2850
|
* Instruct the installed Clock to also mock the date returned by `new Date()`
|
2424
2851
|
* @name Clock#mockDate
|
2852
|
+
* @since 2.1.0
|
2425
2853
|
* @function
|
2426
2854
|
* @param {Date} [initialDate=now] The `Date` to provide.
|
2427
2855
|
*/
|
@@ -2430,11 +2858,17 @@ getJasmineRequireObj().Clock = function() {
|
|
2430
2858
|
};
|
2431
2859
|
|
2432
2860
|
self.setTimeout = function(fn, delay, params) {
|
2433
|
-
return Function.prototype.apply.apply(timer.setTimeout, [
|
2861
|
+
return Function.prototype.apply.apply(timer.setTimeout, [
|
2862
|
+
global,
|
2863
|
+
arguments
|
2864
|
+
]);
|
2434
2865
|
};
|
2435
2866
|
|
2436
2867
|
self.setInterval = function(fn, delay, params) {
|
2437
|
-
return Function.prototype.apply.apply(timer.setInterval, [
|
2868
|
+
return Function.prototype.apply.apply(timer.setInterval, [
|
2869
|
+
global,
|
2870
|
+
arguments
|
2871
|
+
]);
|
2438
2872
|
};
|
2439
2873
|
|
2440
2874
|
self.clearTimeout = function(id) {
|
@@ -2448,24 +2882,31 @@ getJasmineRequireObj().Clock = function() {
|
|
2448
2882
|
/**
|
2449
2883
|
* Tick the Clock forward, running any enqueued timeouts along the way
|
2450
2884
|
* @name Clock#tick
|
2885
|
+
* @since 1.3.0
|
2451
2886
|
* @function
|
2452
2887
|
* @param {int} millis The number of milliseconds to tick.
|
2453
2888
|
*/
|
2454
2889
|
self.tick = function(millis) {
|
2455
2890
|
if (installed) {
|
2456
|
-
delayedFunctionScheduler.tick(millis, function(millis) {
|
2891
|
+
delayedFunctionScheduler.tick(millis, function(millis) {
|
2892
|
+
mockDate.tick(millis);
|
2893
|
+
});
|
2457
2894
|
} else {
|
2458
|
-
throw new Error(
|
2895
|
+
throw new Error(
|
2896
|
+
'Mock clock is not installed, use jasmine.clock().install()'
|
2897
|
+
);
|
2459
2898
|
}
|
2460
2899
|
};
|
2461
2900
|
|
2462
2901
|
return self;
|
2463
2902
|
|
2464
2903
|
function originalTimingFunctionsIntact() {
|
2465
|
-
return
|
2904
|
+
return (
|
2905
|
+
global.setTimeout === realTimingFunctions.setTimeout &&
|
2466
2906
|
global.clearTimeout === realTimingFunctions.clearTimeout &&
|
2467
2907
|
global.setInterval === realTimingFunctions.setInterval &&
|
2468
|
-
global.clearInterval === realTimingFunctions.clearInterval
|
2908
|
+
global.clearInterval === realTimingFunctions.clearInterval
|
2909
|
+
);
|
2469
2910
|
}
|
2470
2911
|
|
2471
2912
|
function replace(dest, source) {
|
@@ -2476,12 +2917,22 @@ getJasmineRequireObj().Clock = function() {
|
|
2476
2917
|
|
2477
2918
|
function setTimeout(fn, delay) {
|
2478
2919
|
if (!NODE_JS) {
|
2479
|
-
return delayedFunctionScheduler.scheduleFunction(
|
2920
|
+
return delayedFunctionScheduler.scheduleFunction(
|
2921
|
+
fn,
|
2922
|
+
delay,
|
2923
|
+
argSlice(arguments, 2)
|
2924
|
+
);
|
2480
2925
|
}
|
2481
2926
|
|
2482
2927
|
var timeout = new FakeTimeout();
|
2483
2928
|
|
2484
|
-
delayedFunctionScheduler.scheduleFunction(
|
2929
|
+
delayedFunctionScheduler.scheduleFunction(
|
2930
|
+
fn,
|
2931
|
+
delay,
|
2932
|
+
argSlice(arguments, 2),
|
2933
|
+
false,
|
2934
|
+
timeout
|
2935
|
+
);
|
2485
2936
|
|
2486
2937
|
return timeout;
|
2487
2938
|
}
|
@@ -2492,12 +2943,23 @@ getJasmineRequireObj().Clock = function() {
|
|
2492
2943
|
|
2493
2944
|
function setInterval(fn, interval) {
|
2494
2945
|
if (!NODE_JS) {
|
2495
|
-
return delayedFunctionScheduler.scheduleFunction(
|
2946
|
+
return delayedFunctionScheduler.scheduleFunction(
|
2947
|
+
fn,
|
2948
|
+
interval,
|
2949
|
+
argSlice(arguments, 2),
|
2950
|
+
true
|
2951
|
+
);
|
2496
2952
|
}
|
2497
2953
|
|
2498
2954
|
var timeout = new FakeTimeout();
|
2499
2955
|
|
2500
|
-
delayedFunctionScheduler.scheduleFunction(
|
2956
|
+
delayedFunctionScheduler.scheduleFunction(
|
2957
|
+
fn,
|
2958
|
+
interval,
|
2959
|
+
argSlice(arguments, 2),
|
2960
|
+
true,
|
2961
|
+
timeout
|
2962
|
+
);
|
2501
2963
|
|
2502
2964
|
return timeout;
|
2503
2965
|
}
|
@@ -2516,11 +2978,11 @@ getJasmineRequireObj().Clock = function() {
|
|
2516
2978
|
*/
|
2517
2979
|
function FakeTimeout() {}
|
2518
2980
|
|
2519
|
-
FakeTimeout.prototype.ref = function
|
2981
|
+
FakeTimeout.prototype.ref = function() {
|
2520
2982
|
return this;
|
2521
2983
|
};
|
2522
2984
|
|
2523
|
-
FakeTimeout.prototype.unref = function
|
2985
|
+
FakeTimeout.prototype.unref = function() {
|
2524
2986
|
return this;
|
2525
2987
|
};
|
2526
2988
|
|
@@ -2544,11 +3006,20 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|
2544
3006
|
currentTime = endTime;
|
2545
3007
|
};
|
2546
3008
|
|
2547
|
-
self.scheduleFunction = function(
|
3009
|
+
self.scheduleFunction = function(
|
3010
|
+
funcToCall,
|
3011
|
+
millis,
|
3012
|
+
params,
|
3013
|
+
recurring,
|
3014
|
+
timeoutKey,
|
3015
|
+
runAtMillis
|
3016
|
+
) {
|
2548
3017
|
var f;
|
2549
|
-
if (typeof
|
3018
|
+
if (typeof funcToCall === 'string') {
|
2550
3019
|
/* jshint evil: true */
|
2551
|
-
f = function() {
|
3020
|
+
f = function() {
|
3021
|
+
return eval(funcToCall);
|
3022
|
+
};
|
2552
3023
|
/* jshint evil: false */
|
2553
3024
|
} else {
|
2554
3025
|
f = funcToCall;
|
@@ -2556,7 +3027,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|
2556
3027
|
|
2557
3028
|
millis = millis || 0;
|
2558
3029
|
timeoutKey = timeoutKey || ++delayedFnCount;
|
2559
|
-
runAtMillis = runAtMillis ||
|
3030
|
+
runAtMillis = runAtMillis || currentTime + millis;
|
2560
3031
|
|
2561
3032
|
var funcToSchedule = {
|
2562
3033
|
runAtMillis: runAtMillis,
|
@@ -2572,7 +3043,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|
2572
3043
|
} else {
|
2573
3044
|
scheduledFunctions[runAtMillis] = [funcToSchedule];
|
2574
3045
|
scheduledLookup.push(runAtMillis);
|
2575
|
-
scheduledLookup.sort(function
|
3046
|
+
scheduledLookup.sort(function(a, b) {
|
2576
3047
|
return a - b;
|
2577
3048
|
});
|
2578
3049
|
}
|
@@ -2585,7 +3056,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|
2585
3056
|
|
2586
3057
|
for (var runAtMillis in scheduledFunctions) {
|
2587
3058
|
var funcs = scheduledFunctions[runAtMillis];
|
2588
|
-
var i = indexOfFirstToPass(funcs, function
|
3059
|
+
var i = indexOfFirstToPass(funcs, function(func) {
|
2589
3060
|
return func.timeoutKey === timeoutKey;
|
2590
3061
|
});
|
2591
3062
|
|
@@ -2621,7 +3092,7 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|
2621
3092
|
|
2622
3093
|
function deleteFromLookup(key) {
|
2623
3094
|
var value = Number(key);
|
2624
|
-
var i = indexOfFirstToPass(scheduledLookup, function
|
3095
|
+
var i = indexOfFirstToPass(scheduledLookup, function(millis) {
|
2625
3096
|
return millis === value;
|
2626
3097
|
});
|
2627
3098
|
|
@@ -2631,12 +3102,14 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|
2631
3102
|
}
|
2632
3103
|
|
2633
3104
|
function reschedule(scheduledFn) {
|
2634
|
-
self.scheduleFunction(
|
3105
|
+
self.scheduleFunction(
|
3106
|
+
scheduledFn.funcToCall,
|
2635
3107
|
scheduledFn.millis,
|
2636
3108
|
scheduledFn.params,
|
2637
3109
|
true,
|
2638
3110
|
scheduledFn.timeoutKey,
|
2639
|
-
scheduledFn.runAtMillis + scheduledFn.millis
|
3111
|
+
scheduledFn.runAtMillis + scheduledFn.millis
|
3112
|
+
);
|
2640
3113
|
}
|
2641
3114
|
|
2642
3115
|
function forEachFunction(funcsToRun, callback) {
|
@@ -2677,11 +3150,13 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|
2677
3150
|
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
2678
3151
|
});
|
2679
3152
|
deletedKeys = [];
|
2680
|
-
} while (
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
3153
|
+
} while (
|
3154
|
+
scheduledLookup.length > 0 &&
|
3155
|
+
// checking first if we're out of time prevents setTimeout(0)
|
3156
|
+
// scheduled in a funcToRun from forcing an extra iteration
|
3157
|
+
currentTime !== endTime &&
|
3158
|
+
scheduledLookup[0] <= endTime
|
3159
|
+
);
|
2685
3160
|
|
2686
3161
|
// ran out of functions to call, but still time left on the clock
|
2687
3162
|
if (currentTime !== endTime) {
|
@@ -2703,9 +3178,20 @@ getJasmineRequireObj().errors = function() {
|
|
2703
3178
|
ExpectationFailed: ExpectationFailed
|
2704
3179
|
};
|
2705
3180
|
};
|
2706
|
-
getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
2707
3181
|
|
2708
|
-
|
3182
|
+
getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
3183
|
+
var ignoredProperties = [
|
3184
|
+
'name',
|
3185
|
+
'message',
|
3186
|
+
'stack',
|
3187
|
+
'fileName',
|
3188
|
+
'sourceURL',
|
3189
|
+
'line',
|
3190
|
+
'lineNumber',
|
3191
|
+
'column',
|
3192
|
+
'description',
|
3193
|
+
'jasmineMessage'
|
3194
|
+
];
|
2709
3195
|
|
2710
3196
|
function ExceptionFormatter(options) {
|
2711
3197
|
var jasmineFile = (options && options.jasmineFile) || j$.util.jasmineFile();
|
@@ -2754,7 +3240,8 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
|
2754
3240
|
|
2755
3241
|
function filterJasmine(stackTrace) {
|
2756
3242
|
var result = [],
|
2757
|
-
jasmineMarker =
|
3243
|
+
jasmineMarker =
|
3244
|
+
stackTrace.style === 'webkit' ? '<Jasmine>' : ' at <Jasmine>';
|
2758
3245
|
|
2759
3246
|
stackTrace.frames.forEach(function(frame) {
|
2760
3247
|
if (frame.file && frame.file !== jasmineFile) {
|
@@ -2795,10 +3282,6 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
|
2795
3282
|
};
|
2796
3283
|
|
2797
3284
|
getJasmineRequireObj().Expectation = function(j$) {
|
2798
|
-
var promiseForMessage = {
|
2799
|
-
jasmineToString: function() { return 'a promise'; }
|
2800
|
-
};
|
2801
|
-
|
2802
3285
|
/**
|
2803
3286
|
* Matchers that come with Jasmine out of the box.
|
2804
3287
|
* @namespace matchers
|
@@ -2808,7 +3291,10 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|
2808
3291
|
|
2809
3292
|
var customMatchers = options.customMatchers || {};
|
2810
3293
|
for (var matcherName in customMatchers) {
|
2811
|
-
this[matcherName] = wrapSyncCompare(
|
3294
|
+
this[matcherName] = wrapSyncCompare(
|
3295
|
+
matcherName,
|
3296
|
+
customMatchers[matcherName]
|
3297
|
+
);
|
2812
3298
|
}
|
2813
3299
|
}
|
2814
3300
|
|
@@ -2816,6 +3302,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|
2816
3302
|
* Add some context for an {@link expect}
|
2817
3303
|
* @function
|
2818
3304
|
* @name matchers#withContext
|
3305
|
+
* @since 3.3.0
|
2819
3306
|
* @param {String} message - Additional context to show when the matcher fails
|
2820
3307
|
* @return {matchers}
|
2821
3308
|
*/
|
@@ -2827,6 +3314,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|
2827
3314
|
* Invert the matcher following this {@link expect}
|
2828
3315
|
* @member
|
2829
3316
|
* @name matchers#not
|
3317
|
+
* @since 1.3.0
|
2830
3318
|
* @type {matchers}
|
2831
3319
|
* @example
|
2832
3320
|
* expect(something).not.toBe(true);
|
@@ -2846,11 +3334,17 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|
2846
3334
|
this.expector = new j$.Expector(options);
|
2847
3335
|
|
2848
3336
|
if (!global.Promise) {
|
2849
|
-
throw new Error(
|
3337
|
+
throw new Error(
|
3338
|
+
'expectAsync is unavailable because the environment does not support promises.'
|
3339
|
+
);
|
2850
3340
|
}
|
2851
3341
|
|
2852
|
-
|
2853
|
-
|
3342
|
+
var customAsyncMatchers = options.customAsyncMatchers || {};
|
3343
|
+
for (var matcherName in customAsyncMatchers) {
|
3344
|
+
this[matcherName] = wrapAsyncCompare(
|
3345
|
+
matcherName,
|
3346
|
+
customAsyncMatchers[matcherName]
|
3347
|
+
);
|
2854
3348
|
}
|
2855
3349
|
}
|
2856
3350
|
|
@@ -2858,6 +3352,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|
2858
3352
|
* Add some context for an {@link expectAsync}
|
2859
3353
|
* @function
|
2860
3354
|
* @name async-matchers#withContext
|
3355
|
+
* @since 3.3.0
|
2861
3356
|
* @param {String} message - Additional context to show when the async matcher fails
|
2862
3357
|
* @return {async-matchers}
|
2863
3358
|
*/
|
@@ -2896,9 +3391,11 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|
2896
3391
|
// frames that are relevant to the user instead of just parts of Jasmine.
|
2897
3392
|
var errorForStack = j$.util.errorWithStack();
|
2898
3393
|
|
2899
|
-
return this.expector
|
2900
|
-
|
2901
|
-
|
3394
|
+
return this.expector
|
3395
|
+
.compare(name, matcherFactory, arguments)
|
3396
|
+
.then(function(result) {
|
3397
|
+
self.expector.processResult(result, errorForStack);
|
3398
|
+
});
|
2902
3399
|
};
|
2903
3400
|
}
|
2904
3401
|
|
@@ -2952,7 +3449,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|
2952
3449
|
return matcher.compare.apply(this, arguments).then(negate);
|
2953
3450
|
}
|
2954
3451
|
|
2955
|
-
return defaultNegativeCompare;
|
3452
|
+
return matcher.negativeCompare || defaultNegativeCompare;
|
2956
3453
|
},
|
2957
3454
|
buildFailureMessage: negatedFailureMessage
|
2958
3455
|
};
|
@@ -2995,7 +3492,12 @@ getJasmineRequireObj().ExpectationFilterChain = function() {
|
|
2995
3492
|
return this.callFirst_('selectComparisonFunc', arguments).result;
|
2996
3493
|
};
|
2997
3494
|
|
2998
|
-
ExpectationFilterChain.prototype.buildFailureMessage = function(
|
3495
|
+
ExpectationFilterChain.prototype.buildFailureMessage = function(
|
3496
|
+
result,
|
3497
|
+
matcherName,
|
3498
|
+
args,
|
3499
|
+
util
|
3500
|
+
) {
|
2999
3501
|
return this.callFirst_('buildFailureMessage', arguments).result;
|
3000
3502
|
};
|
3001
3503
|
|
@@ -3022,7 +3524,7 @@ getJasmineRequireObj().ExpectationFilterChain = function() {
|
|
3022
3524
|
};
|
3023
3525
|
}
|
3024
3526
|
|
3025
|
-
return {found: false};
|
3527
|
+
return { found: false };
|
3026
3528
|
};
|
3027
3529
|
|
3028
3530
|
return ExpectationFilterChain;
|
@@ -3050,7 +3552,7 @@ getJasmineRequireObj().buildExpectationResult = function() {
|
|
3050
3552
|
passed: options.passed
|
3051
3553
|
};
|
3052
3554
|
|
3053
|
-
if(!result.passed) {
|
3555
|
+
if (!result.passed) {
|
3054
3556
|
result.expected = options.expected;
|
3055
3557
|
result.actual = options.actual;
|
3056
3558
|
}
|
@@ -3099,11 +3601,15 @@ getJasmineRequireObj().Expector = function(j$) {
|
|
3099
3601
|
this.util = options.util || { buildFailureMessage: function() {} };
|
3100
3602
|
this.customEqualityTesters = options.customEqualityTesters || [];
|
3101
3603
|
this.actual = options.actual;
|
3102
|
-
this.addExpectationResult = options.addExpectationResult || function(){};
|
3604
|
+
this.addExpectationResult = options.addExpectationResult || function() {};
|
3103
3605
|
this.filters = new j$.ExpectationFilterChain();
|
3104
3606
|
}
|
3105
3607
|
|
3106
|
-
Expector.prototype.instantiateMatcher = function(
|
3608
|
+
Expector.prototype.instantiateMatcher = function(
|
3609
|
+
matcherName,
|
3610
|
+
matcherFactory,
|
3611
|
+
args
|
3612
|
+
) {
|
3107
3613
|
this.matcherName = matcherName;
|
3108
3614
|
this.args = Array.prototype.slice.call(args, 0);
|
3109
3615
|
this.expected = this.args.slice(0);
|
@@ -3122,7 +3628,13 @@ getJasmineRequireObj().Expector = function(j$) {
|
|
3122
3628
|
return '';
|
3123
3629
|
}
|
3124
3630
|
|
3125
|
-
var msg = this.filters.buildFailureMessage(
|
3631
|
+
var msg = this.filters.buildFailureMessage(
|
3632
|
+
result,
|
3633
|
+
this.matcherName,
|
3634
|
+
this.args,
|
3635
|
+
this.util,
|
3636
|
+
defaultMessage
|
3637
|
+
);
|
3126
3638
|
return this.filters.modifyFailureMessage(msg || defaultMessage());
|
3127
3639
|
|
3128
3640
|
function defaultMessage() {
|
@@ -3140,7 +3652,11 @@ getJasmineRequireObj().Expector = function(j$) {
|
|
3140
3652
|
};
|
3141
3653
|
|
3142
3654
|
Expector.prototype.compare = function(matcherName, matcherFactory, args) {
|
3143
|
-
var matcherCompare = this.instantiateMatcher(
|
3655
|
+
var matcherCompare = this.instantiateMatcher(
|
3656
|
+
matcherName,
|
3657
|
+
matcherFactory,
|
3658
|
+
args
|
3659
|
+
);
|
3144
3660
|
return matcherCompare.apply(null, this.args);
|
3145
3661
|
};
|
3146
3662
|
|
@@ -3150,26 +3666,22 @@ getJasmineRequireObj().Expector = function(j$) {
|
|
3150
3666
|
return result;
|
3151
3667
|
};
|
3152
3668
|
|
3153
|
-
Expector.prototype.processResult = function(result, errorForStack
|
3154
|
-
this.args[0] = actualOverride || this.args[0];
|
3669
|
+
Expector.prototype.processResult = function(result, errorForStack) {
|
3155
3670
|
var message = this.buildMessage(result);
|
3156
3671
|
|
3157
3672
|
if (this.expected.length === 1) {
|
3158
3673
|
this.expected = this.expected[0];
|
3159
3674
|
}
|
3160
3675
|
|
3161
|
-
this.addExpectationResult(
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
expected: this.expected // TODO: this may need to be arrayified/sliced
|
3171
|
-
}
|
3172
|
-
);
|
3676
|
+
this.addExpectationResult(result.pass, {
|
3677
|
+
matcherName: this.matcherName,
|
3678
|
+
passed: result.pass,
|
3679
|
+
message: message,
|
3680
|
+
error: errorForStack ? undefined : result.error,
|
3681
|
+
errorForStack: errorForStack || undefined,
|
3682
|
+
actual: this.actual,
|
3683
|
+
expected: this.expected // TODO: this may need to be arrayified/sliced
|
3684
|
+
});
|
3173
3685
|
};
|
3174
3686
|
|
3175
3687
|
return Expector;
|
@@ -3227,7 +3739,10 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
|
3227
3739
|
var errorTypes = Object.keys(this.originalHandlers);
|
3228
3740
|
for (var iType = 0; iType < errorTypes.length; iType++) {
|
3229
3741
|
var errorType = errorTypes[iType];
|
3230
|
-
global.process.removeListener(
|
3742
|
+
global.process.removeListener(
|
3743
|
+
errorType,
|
3744
|
+
this.jasmineHandlers[errorType]
|
3745
|
+
);
|
3231
3746
|
for (var i = 0; i < this.originalHandlers[errorType].length; i++) {
|
3232
3747
|
global.process.on(errorType, this.originalHandlers[errorType][i]);
|
3233
3748
|
}
|
@@ -3238,7 +3753,11 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
|
3238
3753
|
};
|
3239
3754
|
|
3240
3755
|
this.install = function install() {
|
3241
|
-
if (
|
3756
|
+
if (
|
3757
|
+
global.process &&
|
3758
|
+
global.process.listeners &&
|
3759
|
+
j$.isFunction_(global.process.on)
|
3760
|
+
) {
|
3242
3761
|
this.installOne_('uncaughtException', 'Uncaught exception');
|
3243
3762
|
this.installOne_('unhandledRejection', 'Unhandled promise rejection');
|
3244
3763
|
} else {
|
@@ -3269,14 +3788,18 @@ getJasmineRequireObj().toBeRejected = function(j$) {
|
|
3269
3788
|
* @function
|
3270
3789
|
* @async
|
3271
3790
|
* @name async-matchers#toBeRejected
|
3791
|
+
* @since 3.1.0
|
3272
3792
|
* @example
|
3273
3793
|
* await expectAsync(aPromise).toBeRejected();
|
3274
3794
|
* @example
|
3275
3795
|
* return expectAsync(aPromise).toBeRejected();
|
3276
3796
|
*/
|
3277
|
-
return function
|
3797
|
+
return function toBeRejected(util) {
|
3278
3798
|
return {
|
3279
3799
|
compare: function(actual) {
|
3800
|
+
if (!j$.isPromiseLike(actual)) {
|
3801
|
+
throw new Error('Expected toBeRejected to be called on a promise.');
|
3802
|
+
}
|
3280
3803
|
return actual.then(
|
3281
3804
|
function() { return {pass: false}; },
|
3282
3805
|
function() { return {pass: true}; }
|
@@ -3292,6 +3815,7 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) {
|
|
3292
3815
|
* @function
|
3293
3816
|
* @async
|
3294
3817
|
* @name async-matchers#toBeRejectedWith
|
3818
|
+
* @since 3.3.0
|
3295
3819
|
* @param {Object} expected - Value that the promise is expected to be rejected with
|
3296
3820
|
* @example
|
3297
3821
|
* await expectAsync(aPromise).toBeRejectedWith({prop: 'value'});
|
@@ -3301,6 +3825,10 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) {
|
|
3301
3825
|
return function toBeRejectedWith(util, customEqualityTesters) {
|
3302
3826
|
return {
|
3303
3827
|
compare: function(actualPromise, expectedValue) {
|
3828
|
+
if (!j$.isPromiseLike(actualPromise)) {
|
3829
|
+
throw new Error('Expected toBeRejectedWith to be called on a promise.');
|
3830
|
+
}
|
3831
|
+
|
3304
3832
|
function prefix(passed) {
|
3305
3833
|
return 'Expected a promise ' +
|
3306
3834
|
(passed ? 'not ' : '') +
|
@@ -3330,7 +3858,105 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) {
|
|
3330
3858
|
);
|
3331
3859
|
}
|
3332
3860
|
};
|
3333
|
-
};
|
3861
|
+
};
|
3862
|
+
};
|
3863
|
+
|
3864
|
+
getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
3865
|
+
/**
|
3866
|
+
* Expect a promise to be rejected with a value matched to the expected
|
3867
|
+
* @function
|
3868
|
+
* @async
|
3869
|
+
* @name async-matchers#toBeRejectedWithError
|
3870
|
+
* @since 3.5.0
|
3871
|
+
* @param {Error} [expected] - `Error` constructor the object that was thrown needs to be an instance of. If not provided, `Error` will be used.
|
3872
|
+
* @param {RegExp|String} [message] - The message that should be set on the thrown `Error`
|
3873
|
+
* @example
|
3874
|
+
* await expectAsync(aPromise).toBeRejectedWithError(MyCustomError, 'Error message');
|
3875
|
+
* await expectAsync(aPromise).toBeRejectedWithError(MyCustomError, /Error message/);
|
3876
|
+
* await expectAsync(aPromise).toBeRejectedWithError(MyCustomError);
|
3877
|
+
* await expectAsync(aPromise).toBeRejectedWithError('Error message');
|
3878
|
+
* return expectAsync(aPromise).toBeRejectedWithError(/Error message/);
|
3879
|
+
*/
|
3880
|
+
return function toBeRejectedWithError() {
|
3881
|
+
return {
|
3882
|
+
compare: function(actualPromise, arg1, arg2) {
|
3883
|
+
if (!j$.isPromiseLike(actualPromise)) {
|
3884
|
+
throw new Error('Expected toBeRejectedWithError to be called on a promise.');
|
3885
|
+
}
|
3886
|
+
|
3887
|
+
var expected = getExpectedFromArgs(arg1, arg2);
|
3888
|
+
|
3889
|
+
return actualPromise.then(
|
3890
|
+
function() {
|
3891
|
+
return {
|
3892
|
+
pass: false,
|
3893
|
+
message: 'Expected a promise to be rejected but it was resolved.'
|
3894
|
+
};
|
3895
|
+
},
|
3896
|
+
function(actualValue) { return matchError(actualValue, expected); }
|
3897
|
+
);
|
3898
|
+
}
|
3899
|
+
};
|
3900
|
+
};
|
3901
|
+
|
3902
|
+
function matchError(actual, expected) {
|
3903
|
+
if (!j$.isError_(actual)) {
|
3904
|
+
return fail(expected, 'rejected with ' + j$.pp(actual));
|
3905
|
+
}
|
3906
|
+
|
3907
|
+
if (!(actual instanceof expected.error)) {
|
3908
|
+
return fail(expected, 'rejected with type ' + j$.fnNameFor(actual.constructor));
|
3909
|
+
}
|
3910
|
+
|
3911
|
+
var actualMessage = actual.message;
|
3912
|
+
|
3913
|
+
if (actualMessage === expected.message || typeof expected.message === 'undefined') {
|
3914
|
+
return pass(expected);
|
3915
|
+
}
|
3916
|
+
|
3917
|
+
if (expected.message instanceof RegExp && expected.message.test(actualMessage)) {
|
3918
|
+
return pass(expected);
|
3919
|
+
}
|
3920
|
+
|
3921
|
+
return fail(expected, 'rejected with ' + j$.pp(actual));
|
3922
|
+
}
|
3923
|
+
|
3924
|
+
function pass(expected) {
|
3925
|
+
return {
|
3926
|
+
pass: true,
|
3927
|
+
message: 'Expected a promise not to be rejected with ' + expected.printValue + ', but it was.'
|
3928
|
+
};
|
3929
|
+
}
|
3930
|
+
|
3931
|
+
function fail(expected, message) {
|
3932
|
+
return {
|
3933
|
+
pass: false,
|
3934
|
+
message: 'Expected a promise to be rejected with ' + expected.printValue + ' but it was ' + message + '.'
|
3935
|
+
};
|
3936
|
+
}
|
3937
|
+
|
3938
|
+
|
3939
|
+
function getExpectedFromArgs(arg1, arg2) {
|
3940
|
+
var error, message;
|
3941
|
+
|
3942
|
+
if (isErrorConstructor(arg1)) {
|
3943
|
+
error = arg1;
|
3944
|
+
message = arg2;
|
3945
|
+
} else {
|
3946
|
+
error = Error;
|
3947
|
+
message = arg1;
|
3948
|
+
}
|
3949
|
+
|
3950
|
+
return {
|
3951
|
+
error: error,
|
3952
|
+
message: message,
|
3953
|
+
printValue: j$.fnNameFor(error) + (typeof message === 'undefined' ? '' : ': ' + j$.pp(message))
|
3954
|
+
};
|
3955
|
+
}
|
3956
|
+
|
3957
|
+
function isErrorConstructor(value) {
|
3958
|
+
return typeof value === 'function' && (value === Error || j$.isError_(value.prototype));
|
3959
|
+
}
|
3334
3960
|
};
|
3335
3961
|
|
3336
3962
|
getJasmineRequireObj().toBeResolved = function(j$) {
|
@@ -3339,6 +3965,7 @@ getJasmineRequireObj().toBeResolved = function(j$) {
|
|
3339
3965
|
* @function
|
3340
3966
|
* @async
|
3341
3967
|
* @name async-matchers#toBeResolved
|
3968
|
+
* @since 3.1.0
|
3342
3969
|
* @example
|
3343
3970
|
* await expectAsync(aPromise).toBeResolved();
|
3344
3971
|
* @example
|
@@ -3347,6 +3974,10 @@ getJasmineRequireObj().toBeResolved = function(j$) {
|
|
3347
3974
|
return function toBeResolved(util) {
|
3348
3975
|
return {
|
3349
3976
|
compare: function(actual) {
|
3977
|
+
if (!j$.isPromiseLike(actual)) {
|
3978
|
+
throw new Error('Expected toBeResolved to be called on a promise.');
|
3979
|
+
}
|
3980
|
+
|
3350
3981
|
return actual.then(
|
3351
3982
|
function() { return {pass: true}; },
|
3352
3983
|
function() { return {pass: false}; }
|
@@ -3362,6 +3993,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
|
|
3362
3993
|
* @function
|
3363
3994
|
* @async
|
3364
3995
|
* @name async-matchers#toBeResolvedTo
|
3996
|
+
* @since 3.1.0
|
3365
3997
|
* @param {Object} expected - Value that the promise is expected to resolve to
|
3366
3998
|
* @example
|
3367
3999
|
* await expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
|
@@ -3371,6 +4003,10 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
|
|
3371
4003
|
return function toBeResolvedTo(util, customEqualityTesters) {
|
3372
4004
|
return {
|
3373
4005
|
compare: function(actualPromise, expectedValue) {
|
4006
|
+
if (!j$.isPromiseLike(actualPromise)) {
|
4007
|
+
throw new Error('Expected toBeResolvedTo to be called on a promise.');
|
4008
|
+
}
|
4009
|
+
|
3374
4010
|
function prefix(passed) {
|
3375
4011
|
return 'Expected a promise ' +
|
3376
4012
|
(passed ? 'not ' : '') +
|
@@ -3379,24 +4015,24 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
|
|
3379
4015
|
|
3380
4016
|
return actualPromise.then(
|
3381
4017
|
function(actualValue) {
|
3382
|
-
|
3383
|
-
|
3384
|
-
|
3385
|
-
|
3386
|
-
|
3387
|
-
|
4018
|
+
if (util.equals(actualValue, expectedValue, customEqualityTesters)) {
|
4019
|
+
return {
|
4020
|
+
pass: true,
|
4021
|
+
message: prefix(true) + '.'
|
4022
|
+
};
|
4023
|
+
} else {
|
4024
|
+
return {
|
4025
|
+
pass: false,
|
4026
|
+
message: prefix(false) + ' but it was resolved to ' + j$.pp(actualValue) + '.'
|
4027
|
+
};
|
4028
|
+
}
|
4029
|
+
},
|
4030
|
+
function() {
|
3388
4031
|
return {
|
3389
4032
|
pass: false,
|
3390
|
-
message: prefix(false) + ' but it was
|
4033
|
+
message: prefix(false) + ' but it was rejected.'
|
3391
4034
|
};
|
3392
4035
|
}
|
3393
|
-
},
|
3394
|
-
function() {
|
3395
|
-
return {
|
3396
|
-
pass: false,
|
3397
|
-
message: prefix(false) + ' but it was rejected.'
|
3398
|
-
};
|
3399
|
-
}
|
3400
4036
|
);
|
3401
4037
|
}
|
3402
4038
|
};
|
@@ -3446,7 +4082,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
|
3446
4082
|
contains: function(haystack, needle, customTesters) {
|
3447
4083
|
customTesters = customTesters || [];
|
3448
4084
|
|
3449
|
-
if ((
|
4085
|
+
if (j$.isSet(haystack)) {
|
3450
4086
|
return haystack.has(needle);
|
3451
4087
|
}
|
3452
4088
|
|
@@ -3664,7 +4300,6 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
|
3664
4300
|
});
|
3665
4301
|
|
3666
4302
|
for (i = 0; i < aLength || i < bLength; i++) {
|
3667
|
-
var formatter = false;
|
3668
4303
|
diffBuilder.withPath(i, function() {
|
3669
4304
|
if (i >= bLength) {
|
3670
4305
|
diffBuilder.record(a[i], void 0, actualArrayIsLongerFormatter);
|
@@ -3856,10 +4491,6 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
|
3856
4491
|
return extraKeys;
|
3857
4492
|
}
|
3858
4493
|
|
3859
|
-
function has(obj, key) {
|
3860
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
3861
|
-
}
|
3862
|
-
|
3863
4494
|
function isFunction(obj) {
|
3864
4495
|
return typeof obj === 'function';
|
3865
4496
|
}
|
@@ -3918,6 +4549,7 @@ getJasmineRequireObj().nothing = function() {
|
|
3918
4549
|
* {@link expect} nothing explicitly.
|
3919
4550
|
* @function
|
3920
4551
|
* @name matchers#nothing
|
4552
|
+
* @since 2.8.0
|
3921
4553
|
* @example
|
3922
4554
|
* expect().nothing();
|
3923
4555
|
*/
|
@@ -3998,7 +4630,8 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) {
|
|
3998
4630
|
'toBeResolved',
|
3999
4631
|
'toBeRejected',
|
4000
4632
|
'toBeResolvedTo',
|
4001
|
-
'toBeRejectedWith'
|
4633
|
+
'toBeRejectedWith',
|
4634
|
+
'toBeRejectedWithError'
|
4002
4635
|
],
|
4003
4636
|
matchers = {};
|
4004
4637
|
|
@@ -4015,6 +4648,7 @@ getJasmineRequireObj().toBe = function(j$) {
|
|
4015
4648
|
* {@link expect} the actual value to be `===` to the expected value.
|
4016
4649
|
* @function
|
4017
4650
|
* @name matchers#toBe
|
4651
|
+
* @since 1.3.0
|
4018
4652
|
* @param {Object} expected - The expected value to compare against.
|
4019
4653
|
* @example
|
4020
4654
|
* expect(thing).toBe(realThing);
|
@@ -4025,7 +4659,7 @@ getJasmineRequireObj().toBe = function(j$) {
|
|
4025
4659
|
return {
|
4026
4660
|
compare: function(actual, expected) {
|
4027
4661
|
var result = {
|
4028
|
-
pass: actual === expected
|
4662
|
+
pass: actual === expected
|
4029
4663
|
};
|
4030
4664
|
|
4031
4665
|
if (typeof expected === 'object') {
|
@@ -4045,6 +4679,7 @@ getJasmineRequireObj().toBeCloseTo = function() {
|
|
4045
4679
|
* {@link expect} the actual value to be within a specified precision of the expected value.
|
4046
4680
|
* @function
|
4047
4681
|
* @name matchers#toBeCloseTo
|
4682
|
+
* @since 1.3.0
|
4048
4683
|
* @param {Object} expected - The expected value to compare against.
|
4049
4684
|
* @param {Number} [precision=2] - The number of decimal points to check.
|
4050
4685
|
* @example
|
@@ -4068,7 +4703,7 @@ getJasmineRequireObj().toBeCloseTo = function() {
|
|
4068
4703
|
var maxDelta = Math.pow(10, -precision) / 2;
|
4069
4704
|
|
4070
4705
|
return {
|
4071
|
-
pass: Math.round(delta * pow)
|
4706
|
+
pass: Math.round(delta * pow) <= maxDelta * pow
|
4072
4707
|
};
|
4073
4708
|
}
|
4074
4709
|
};
|
@@ -4082,6 +4717,7 @@ getJasmineRequireObj().toBeDefined = function() {
|
|
4082
4717
|
* {@link expect} the actual value to be defined. (Not `undefined`)
|
4083
4718
|
* @function
|
4084
4719
|
* @name matchers#toBeDefined
|
4720
|
+
* @since 1.3.0
|
4085
4721
|
* @example
|
4086
4722
|
* expect(result).toBeDefined();
|
4087
4723
|
*/
|
@@ -4098,11 +4734,34 @@ getJasmineRequireObj().toBeDefined = function() {
|
|
4098
4734
|
return toBeDefined;
|
4099
4735
|
};
|
4100
4736
|
|
4737
|
+
getJasmineRequireObj().toBeFalse = function() {
|
4738
|
+
/**
|
4739
|
+
* {@link expect} the actual value to be `false`.
|
4740
|
+
* @function
|
4741
|
+
* @name matchers#toBeFalse
|
4742
|
+
* @since 3.5.0
|
4743
|
+
* @example
|
4744
|
+
* expect(result).toBeFalse();
|
4745
|
+
*/
|
4746
|
+
function toBeFalse() {
|
4747
|
+
return {
|
4748
|
+
compare: function(actual) {
|
4749
|
+
return {
|
4750
|
+
pass: actual === false
|
4751
|
+
};
|
4752
|
+
}
|
4753
|
+
};
|
4754
|
+
}
|
4755
|
+
|
4756
|
+
return toBeFalse;
|
4757
|
+
};
|
4758
|
+
|
4101
4759
|
getJasmineRequireObj().toBeFalsy = function() {
|
4102
4760
|
/**
|
4103
4761
|
* {@link expect} the actual value to be falsy
|
4104
4762
|
* @function
|
4105
4763
|
* @name matchers#toBeFalsy
|
4764
|
+
* @since 2.0.0
|
4106
4765
|
* @example
|
4107
4766
|
* expect(result).toBeFalsy();
|
4108
4767
|
*/
|
@@ -4110,7 +4769,7 @@ getJasmineRequireObj().toBeFalsy = function() {
|
|
4110
4769
|
return {
|
4111
4770
|
compare: function(actual) {
|
4112
4771
|
return {
|
4113
|
-
pass:
|
4772
|
+
pass: !actual
|
4114
4773
|
};
|
4115
4774
|
}
|
4116
4775
|
};
|
@@ -4124,6 +4783,7 @@ getJasmineRequireObj().toBeGreaterThan = function() {
|
|
4124
4783
|
* {@link expect} the actual value to be greater than the expected value.
|
4125
4784
|
* @function
|
4126
4785
|
* @name matchers#toBeGreaterThan
|
4786
|
+
* @since 2.0.0
|
4127
4787
|
* @param {Number} expected - The value to compare against.
|
4128
4788
|
* @example
|
4129
4789
|
* expect(result).toBeGreaterThan(3);
|
@@ -4147,6 +4807,7 @@ getJasmineRequireObj().toBeGreaterThanOrEqual = function() {
|
|
4147
4807
|
* {@link expect} the actual value to be greater than or equal to the expected value.
|
4148
4808
|
* @function
|
4149
4809
|
* @name matchers#toBeGreaterThanOrEqual
|
4810
|
+
* @since 2.0.0
|
4150
4811
|
* @param {Number} expected - The expected value to compare against.
|
4151
4812
|
* @example
|
4152
4813
|
* expect(result).toBeGreaterThanOrEqual(25);
|
@@ -4164,11 +4825,59 @@ getJasmineRequireObj().toBeGreaterThanOrEqual = function() {
|
|
4164
4825
|
return toBeGreaterThanOrEqual;
|
4165
4826
|
};
|
4166
4827
|
|
4828
|
+
getJasmineRequireObj().toBeInstanceOf = function(j$) {
|
4829
|
+
var usageError = j$.formatErrorMsg('<toBeInstanceOf>', 'expect(value).toBeInstanceOf(<ConstructorFunction>)');
|
4830
|
+
|
4831
|
+
/**
|
4832
|
+
* {@link expect} the actual to be an instance of the expected class
|
4833
|
+
* @function
|
4834
|
+
* @name matchers#toBeInstanceOf
|
4835
|
+
* @since 3.5.0
|
4836
|
+
* @param {Object} expected - The class or constructor function to check for
|
4837
|
+
* @example
|
4838
|
+
* expect('foo').toBeInstanceOf(String);
|
4839
|
+
* expect(3).toBeInstanceOf(Number);
|
4840
|
+
* expect(new Error()).toBeInstanceOf(Error);
|
4841
|
+
*/
|
4842
|
+
function toBeInstanceOf(util, customEqualityTesters) {
|
4843
|
+
return {
|
4844
|
+
compare: function(actual, expected) {
|
4845
|
+
var actualType = actual && actual.constructor ? j$.fnNameFor(actual.constructor) : j$.pp(actual),
|
4846
|
+
expectedType = expected ? j$.fnNameFor(expected) : j$.pp(expected),
|
4847
|
+
expectedMatcher,
|
4848
|
+
pass;
|
4849
|
+
|
4850
|
+
try {
|
4851
|
+
expectedMatcher = new j$.Any(expected);
|
4852
|
+
pass = expectedMatcher.asymmetricMatch(actual);
|
4853
|
+
} catch (error) {
|
4854
|
+
throw new Error(usageError('Expected value is not a constructor function'));
|
4855
|
+
}
|
4856
|
+
|
4857
|
+
if (pass) {
|
4858
|
+
return {
|
4859
|
+
pass: true,
|
4860
|
+
message: 'Expected instance of ' + actualType + ' not to be an instance of ' + expectedType
|
4861
|
+
};
|
4862
|
+
} else {
|
4863
|
+
return {
|
4864
|
+
pass: false,
|
4865
|
+
message: 'Expected instance of ' + actualType + ' to be an instance of ' + expectedType
|
4866
|
+
};
|
4867
|
+
}
|
4868
|
+
}
|
4869
|
+
};
|
4870
|
+
}
|
4871
|
+
|
4872
|
+
return toBeInstanceOf;
|
4873
|
+
};
|
4874
|
+
|
4167
4875
|
getJasmineRequireObj().toBeLessThan = function() {
|
4168
4876
|
/**
|
4169
4877
|
* {@link expect} the actual value to be less than the expected value.
|
4170
4878
|
* @function
|
4171
4879
|
* @name matchers#toBeLessThan
|
4880
|
+
* @since 2.0.0
|
4172
4881
|
* @param {Number} expected - The expected value to compare against.
|
4173
4882
|
* @example
|
4174
4883
|
* expect(result).toBeLessThan(0);
|
@@ -4192,6 +4901,7 @@ getJasmineRequireObj().toBeLessThanOrEqual = function() {
|
|
4192
4901
|
* {@link expect} the actual value to be less than or equal to the expected value.
|
4193
4902
|
* @function
|
4194
4903
|
* @name matchers#toBeLessThanOrEqual
|
4904
|
+
* @since 2.0.0
|
4195
4905
|
* @param {Number} expected - The expected value to compare against.
|
4196
4906
|
* @example
|
4197
4907
|
* expect(result).toBeLessThanOrEqual(123);
|
@@ -4215,6 +4925,7 @@ getJasmineRequireObj().toBeNaN = function(j$) {
|
|
4215
4925
|
* {@link expect} the actual value to be `NaN` (Not a Number).
|
4216
4926
|
* @function
|
4217
4927
|
* @name matchers#toBeNaN
|
4928
|
+
* @since 1.3.0
|
4218
4929
|
* @example
|
4219
4930
|
* expect(thing).toBeNaN();
|
4220
4931
|
*/
|
@@ -4244,6 +4955,7 @@ getJasmineRequireObj().toBeNegativeInfinity = function(j$) {
|
|
4244
4955
|
* {@link expect} the actual value to be `-Infinity` (-infinity).
|
4245
4956
|
* @function
|
4246
4957
|
* @name matchers#toBeNegativeInfinity
|
4958
|
+
* @since 2.6.0
|
4247
4959
|
* @example
|
4248
4960
|
* expect(thing).toBeNegativeInfinity();
|
4249
4961
|
*/
|
@@ -4255,9 +4967,9 @@ getJasmineRequireObj().toBeNegativeInfinity = function(j$) {
|
|
4255
4967
|
};
|
4256
4968
|
|
4257
4969
|
if (result.pass) {
|
4258
|
-
result.message = 'Expected actual to be -Infinity.';
|
4970
|
+
result.message = 'Expected actual not to be -Infinity.';
|
4259
4971
|
} else {
|
4260
|
-
result.message = function() { return 'Expected ' + j$.pp(actual) + '
|
4972
|
+
result.message = function() { return 'Expected ' + j$.pp(actual) + ' to be -Infinity.'; };
|
4261
4973
|
}
|
4262
4974
|
|
4263
4975
|
return result;
|
@@ -4273,6 +4985,7 @@ getJasmineRequireObj().toBeNull = function() {
|
|
4273
4985
|
* {@link expect} the actual value to be `null`.
|
4274
4986
|
* @function
|
4275
4987
|
* @name matchers#toBeNull
|
4988
|
+
* @since 1.3.0
|
4276
4989
|
* @example
|
4277
4990
|
* expect(result).toBeNull();
|
4278
4991
|
*/
|
@@ -4294,6 +5007,7 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) {
|
|
4294
5007
|
* {@link expect} the actual value to be `Infinity` (infinity).
|
4295
5008
|
* @function
|
4296
5009
|
* @name matchers#toBePositiveInfinity
|
5010
|
+
* @since 2.6.0
|
4297
5011
|
* @example
|
4298
5012
|
* expect(thing).toBePositiveInfinity();
|
4299
5013
|
*/
|
@@ -4305,9 +5019,9 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) {
|
|
4305
5019
|
};
|
4306
5020
|
|
4307
5021
|
if (result.pass) {
|
4308
|
-
result.message = 'Expected actual to be Infinity.';
|
5022
|
+
result.message = 'Expected actual not to be Infinity.';
|
4309
5023
|
} else {
|
4310
|
-
result.message = function() { return 'Expected ' + j$.pp(actual) + '
|
5024
|
+
result.message = function() { return 'Expected ' + j$.pp(actual) + ' to be Infinity.'; };
|
4311
5025
|
}
|
4312
5026
|
|
4313
5027
|
return result;
|
@@ -4318,11 +5032,34 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) {
|
|
4318
5032
|
return toBePositiveInfinity;
|
4319
5033
|
};
|
4320
5034
|
|
5035
|
+
getJasmineRequireObj().toBeTrue = function() {
|
5036
|
+
/**
|
5037
|
+
* {@link expect} the actual value to be `true`.
|
5038
|
+
* @function
|
5039
|
+
* @name matchers#toBeTrue
|
5040
|
+
* @since 3.5.0
|
5041
|
+
* @example
|
5042
|
+
* expect(result).toBeTrue();
|
5043
|
+
*/
|
5044
|
+
function toBeTrue() {
|
5045
|
+
return {
|
5046
|
+
compare: function(actual) {
|
5047
|
+
return {
|
5048
|
+
pass: actual === true
|
5049
|
+
};
|
5050
|
+
}
|
5051
|
+
};
|
5052
|
+
}
|
5053
|
+
|
5054
|
+
return toBeTrue;
|
5055
|
+
};
|
5056
|
+
|
4321
5057
|
getJasmineRequireObj().toBeTruthy = function() {
|
4322
5058
|
/**
|
4323
5059
|
* {@link expect} the actual value to be truthy.
|
4324
5060
|
* @function
|
4325
5061
|
* @name matchers#toBeTruthy
|
5062
|
+
* @since 2.0.0
|
4326
5063
|
* @example
|
4327
5064
|
* expect(thing).toBeTruthy();
|
4328
5065
|
*/
|
@@ -4344,6 +5081,7 @@ getJasmineRequireObj().toBeUndefined = function() {
|
|
4344
5081
|
* {@link expect} the actual value to be `undefined`.
|
4345
5082
|
* @function
|
4346
5083
|
* @name matchers#toBeUndefined
|
5084
|
+
* @since 1.3.0
|
4347
5085
|
* @example
|
4348
5086
|
* expect(result).toBeUndefined():
|
4349
5087
|
*/
|
@@ -4365,6 +5103,7 @@ getJasmineRequireObj().toContain = function() {
|
|
4365
5103
|
* {@link expect} the actual value to contain a specific value.
|
4366
5104
|
* @function
|
4367
5105
|
* @name matchers#toContain
|
5106
|
+
* @since 2.0.0
|
4368
5107
|
* @param {Object} expected - The value to look for.
|
4369
5108
|
* @example
|
4370
5109
|
* expect(array).toContain(anElement);
|
@@ -4391,6 +5130,7 @@ getJasmineRequireObj().toEqual = function(j$) {
|
|
4391
5130
|
* {@link expect} the actual value to be equal to the expected, using deep equality comparison.
|
4392
5131
|
* @function
|
4393
5132
|
* @name matchers#toEqual
|
5133
|
+
* @since 1.3.0
|
4394
5134
|
* @param {Object} expected - Expected value
|
4395
5135
|
* @example
|
4396
5136
|
* expect(bigObject).toEqual({"foo": ['bar', 'baz']});
|
@@ -4426,6 +5166,7 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
|
4426
5166
|
* {@link expect} the actual (a {@link Spy}) to have been called.
|
4427
5167
|
* @function
|
4428
5168
|
* @name matchers#toHaveBeenCalled
|
5169
|
+
* @since 1.3.0
|
4429
5170
|
* @example
|
4430
5171
|
* expect(mySpy).toHaveBeenCalled();
|
4431
5172
|
* expect(mySpy).not.toHaveBeenCalled();
|
@@ -4465,6 +5206,7 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
|
4465
5206
|
* {@link expect} the actual value (a {@link Spy}) to have been called before another {@link Spy}.
|
4466
5207
|
* @function
|
4467
5208
|
* @name matchers#toHaveBeenCalledBefore
|
5209
|
+
* @since 2.6.0
|
4468
5210
|
* @param {Spy} expected - {@link Spy} that should have been called after the `actual` {@link Spy}.
|
4469
5211
|
* @example
|
4470
5212
|
* expect(mySpy).toHaveBeenCalledBefore(otherSpy);
|
@@ -4526,6 +5268,7 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
|
4526
5268
|
* {@link expect} the actual (a {@link Spy}) to have been called the specified number of times.
|
4527
5269
|
* @function
|
4528
5270
|
* @name matchers#toHaveBeenCalledTimes
|
5271
|
+
* @since 2.4.0
|
4529
5272
|
* @param {Number} expected - The number of invocations to look for.
|
4530
5273
|
* @example
|
4531
5274
|
* expect(mySpy).toHaveBeenCalledTimes(3);
|
@@ -4540,7 +5283,7 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
|
4540
5283
|
var args = Array.prototype.slice.call(arguments, 0),
|
4541
5284
|
result = { pass: false };
|
4542
5285
|
|
4543
|
-
if (!j$.isNumber_(expected)){
|
5286
|
+
if (!j$.isNumber_(expected)) {
|
4544
5287
|
throw new Error(getErrorMsg('The expected times failed is a required argument and must be a number.'));
|
4545
5288
|
}
|
4546
5289
|
|
@@ -4567,6 +5310,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
|
4567
5310
|
* {@link expect} the actual (a {@link Spy}) to have been called with particular arguments at least once.
|
4568
5311
|
* @function
|
4569
5312
|
* @name matchers#toHaveBeenCalledWith
|
5313
|
+
* @since 1.3.0
|
4570
5314
|
* @param {...Object} - The arguments to look for
|
4571
5315
|
* @example
|
4572
5316
|
* expect(mySpy).toHaveBeenCalledWith('foo', 'bar', 2);
|
@@ -4584,15 +5328,40 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
|
4584
5328
|
}
|
4585
5329
|
|
4586
5330
|
if (!actual.calls.any()) {
|
4587
|
-
result.message = function() {
|
5331
|
+
result.message = function() {
|
5332
|
+
return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' +
|
5333
|
+
' ' + j$.pp(expectedArgs) +
|
5334
|
+
'\nbut it was never called.';
|
5335
|
+
};
|
4588
5336
|
return result;
|
4589
5337
|
}
|
4590
5338
|
|
4591
5339
|
if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) {
|
4592
5340
|
result.pass = true;
|
4593
|
-
result.message = function() {
|
5341
|
+
result.message = function() {
|
5342
|
+
return 'Expected spy ' + actual.and.identity + ' not to have been called with:\n' +
|
5343
|
+
' ' + j$.pp(expectedArgs) +
|
5344
|
+
'\nbut it was.';
|
5345
|
+
};
|
4594
5346
|
} else {
|
4595
|
-
result.message = function() {
|
5347
|
+
result.message = function() {
|
5348
|
+
var prettyPrintedCalls = actual.calls.allArgs().map(function(argsForCall) {
|
5349
|
+
return ' ' + j$.pp(argsForCall);
|
5350
|
+
});
|
5351
|
+
|
5352
|
+
var diffs = actual.calls.allArgs().map(function(argsForCall, callIx) {
|
5353
|
+
var diffBuilder = new j$.DiffBuilder();
|
5354
|
+
util.equals(argsForCall, expectedArgs, customEqualityTesters, diffBuilder);
|
5355
|
+
return 'Call ' + callIx + ':\n' +
|
5356
|
+
diffBuilder.getMessage().replace(/^/mg, ' ');
|
5357
|
+
});
|
5358
|
+
|
5359
|
+
return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' +
|
5360
|
+
' ' + j$.pp(expectedArgs) + '\n' + '' +
|
5361
|
+
'but actual calls were:\n' +
|
5362
|
+
prettyPrintedCalls.join(',\n') + '.\n\n' +
|
5363
|
+
diffs.join('\n');
|
5364
|
+
};
|
4596
5365
|
}
|
4597
5366
|
|
4598
5367
|
return result;
|
@@ -4608,6 +5377,7 @@ getJasmineRequireObj().toHaveClass = function(j$) {
|
|
4608
5377
|
* {@link expect} the actual value to be a DOM element that has the expected class
|
4609
5378
|
* @function
|
4610
5379
|
* @name matchers#toHaveClass
|
5380
|
+
* @since 3.0.0
|
4611
5381
|
* @param {Object} expected - The class name to test for
|
4612
5382
|
* @example
|
4613
5383
|
* var el = document.createElement('div');
|
@@ -4645,6 +5415,7 @@ getJasmineRequireObj().toMatch = function(j$) {
|
|
4645
5415
|
* {@link expect} the actual value to match a regular expression
|
4646
5416
|
* @function
|
4647
5417
|
* @name matchers#toMatch
|
5418
|
+
* @since 1.3.0
|
4648
5419
|
* @param {RegExp|String} expected - Value to look for in the string.
|
4649
5420
|
* @example
|
4650
5421
|
* expect("my string").toMatch(/string$/);
|
@@ -4677,6 +5448,7 @@ getJasmineRequireObj().toThrow = function(j$) {
|
|
4677
5448
|
* {@link expect} a function to `throw` something.
|
4678
5449
|
* @function
|
4679
5450
|
* @name matchers#toThrow
|
5451
|
+
* @since 2.0.0
|
4680
5452
|
* @param {Object} [expected] - Value that should be thrown. If not provided, simply the fact that something was thrown will be checked.
|
4681
5453
|
* @example
|
4682
5454
|
* expect(function() { return 'things'; }).toThrow('foo');
|
@@ -4735,6 +5507,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
|
4735
5507
|
* {@link expect} a function to `throw` an `Error`.
|
4736
5508
|
* @function
|
4737
5509
|
* @name matchers#toThrowError
|
5510
|
+
* @since 2.0.0
|
4738
5511
|
* @param {Error} [expected] - `Error` constructor the object that was thrown needs to be an instance of. If not provided, `Error` will be used.
|
4739
5512
|
* @param {RegExp|String} [message] - The message that should be set on the thrown `Error`
|
4740
5513
|
* @example
|
@@ -4901,6 +5674,7 @@ getJasmineRequireObj().toThrowMatching = function(j$) {
|
|
4901
5674
|
* {@link expect} a function to `throw` something matching a predicate.
|
4902
5675
|
* @function
|
4903
5676
|
* @name matchers#toThrowMatching
|
5677
|
+
* @since 3.0.0
|
4904
5678
|
* @param {Function} predicate - A function that takes the thrown exception as its parameter and returns true if it matches.
|
4905
5679
|
* @example
|
4906
5680
|
* expect(function() { throw new Error('nope'); }).toThrowMatching(function(thrown) { return thrown.message === 'nope'; });
|
@@ -5002,7 +5776,7 @@ getJasmineRequireObj().MockDate = function() {
|
|
5002
5776
|
return self;
|
5003
5777
|
|
5004
5778
|
function FakeDate() {
|
5005
|
-
switch(arguments.length) {
|
5779
|
+
switch (arguments.length) {
|
5006
5780
|
case 0:
|
5007
5781
|
return new GlobalDate(currentTime);
|
5008
5782
|
case 1:
|
@@ -5012,16 +5786,39 @@ getJasmineRequireObj().MockDate = function() {
|
|
5012
5786
|
case 3:
|
5013
5787
|
return new GlobalDate(arguments[0], arguments[1], arguments[2]);
|
5014
5788
|
case 4:
|
5015
|
-
return new GlobalDate(
|
5789
|
+
return new GlobalDate(
|
5790
|
+
arguments[0],
|
5791
|
+
arguments[1],
|
5792
|
+
arguments[2],
|
5793
|
+
arguments[3]
|
5794
|
+
);
|
5016
5795
|
case 5:
|
5017
|
-
return new GlobalDate(
|
5018
|
-
|
5796
|
+
return new GlobalDate(
|
5797
|
+
arguments[0],
|
5798
|
+
arguments[1],
|
5799
|
+
arguments[2],
|
5800
|
+
arguments[3],
|
5801
|
+
arguments[4]
|
5802
|
+
);
|
5019
5803
|
case 6:
|
5020
|
-
return new GlobalDate(
|
5021
|
-
|
5804
|
+
return new GlobalDate(
|
5805
|
+
arguments[0],
|
5806
|
+
arguments[1],
|
5807
|
+
arguments[2],
|
5808
|
+
arguments[3],
|
5809
|
+
arguments[4],
|
5810
|
+
arguments[5]
|
5811
|
+
);
|
5022
5812
|
default:
|
5023
|
-
return new GlobalDate(
|
5024
|
-
|
5813
|
+
return new GlobalDate(
|
5814
|
+
arguments[0],
|
5815
|
+
arguments[1],
|
5816
|
+
arguments[2],
|
5817
|
+
arguments[3],
|
5818
|
+
arguments[4],
|
5819
|
+
arguments[5],
|
5820
|
+
arguments[6]
|
5821
|
+
);
|
5025
5822
|
}
|
5026
5823
|
}
|
5027
5824
|
|
@@ -5041,13 +5838,12 @@ getJasmineRequireObj().MockDate = function() {
|
|
5041
5838
|
FakeDate.parse = GlobalDate.parse;
|
5042
5839
|
FakeDate.UTC = GlobalDate.UTC;
|
5043
5840
|
}
|
5044
|
-
|
5841
|
+
}
|
5045
5842
|
|
5046
5843
|
return MockDate;
|
5047
5844
|
};
|
5048
5845
|
|
5049
5846
|
getJasmineRequireObj().pp = function(j$) {
|
5050
|
-
|
5051
5847
|
function PrettyPrinter() {
|
5052
5848
|
this.ppNestLevel_ = 0;
|
5053
5849
|
this.seen = [];
|
@@ -5058,7 +5854,16 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5058
5854
|
function hasCustomToString(value) {
|
5059
5855
|
// value.toString !== Object.prototype.toString if value has no custom toString but is from another context (e.g.
|
5060
5856
|
// iframe, web worker)
|
5061
|
-
|
5857
|
+
try {
|
5858
|
+
return (
|
5859
|
+
j$.isFunction_(value.toString) &&
|
5860
|
+
value.toString !== Object.prototype.toString &&
|
5861
|
+
value.toString() !== Object.prototype.toString.call(value)
|
5862
|
+
);
|
5863
|
+
} catch (e) {
|
5864
|
+
// The custom toString() threw.
|
5865
|
+
return true;
|
5866
|
+
}
|
5062
5867
|
}
|
5063
5868
|
|
5064
5869
|
PrettyPrinter.prototype.format = function(value) {
|
@@ -5068,7 +5873,7 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5068
5873
|
this.emitScalar('undefined');
|
5069
5874
|
} else if (value === null) {
|
5070
5875
|
this.emitScalar('null');
|
5071
|
-
} else if (value === 0 && 1/value === -Infinity) {
|
5876
|
+
} else if (value === 0 && 1 / value === -Infinity) {
|
5072
5877
|
this.emitScalar('-0');
|
5073
5878
|
} else if (value === j$.getGlobal()) {
|
5074
5879
|
this.emitScalar('<global>');
|
@@ -5078,6 +5883,8 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5078
5883
|
this.emitString(value);
|
5079
5884
|
} else if (j$.isSpy(value)) {
|
5080
5885
|
this.emitScalar('spy on ' + value.and.identity);
|
5886
|
+
} else if (j$.isSpy(value.toString)) {
|
5887
|
+
this.emitScalar('spy on ' + value.toString.and.identity);
|
5081
5888
|
} else if (value instanceof RegExp) {
|
5082
5889
|
this.emitScalar(value.toString());
|
5083
5890
|
} else if (typeof value === 'function') {
|
@@ -5096,10 +5903,23 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5096
5903
|
this.emitMap(value);
|
5097
5904
|
} else if (j$.isTypedArray_(value)) {
|
5098
5905
|
this.emitTypedArray(value);
|
5099
|
-
} else if (
|
5100
|
-
|
5906
|
+
} else if (
|
5907
|
+
value.toString &&
|
5908
|
+
typeof value === 'object' &&
|
5909
|
+
!j$.isArray_(value) &&
|
5910
|
+
hasCustomToString(value)
|
5911
|
+
) {
|
5912
|
+
try {
|
5913
|
+
this.emitScalar(value.toString());
|
5914
|
+
} catch (e) {
|
5915
|
+
this.emitScalar('has-invalid-toString-method');
|
5916
|
+
}
|
5101
5917
|
} else if (j$.util.arrayContains(this.seen, value)) {
|
5102
|
-
this.emitScalar(
|
5918
|
+
this.emitScalar(
|
5919
|
+
'<circular reference: ' +
|
5920
|
+
(j$.isArray_(value) ? 'Array' : 'Object') +
|
5921
|
+
'>'
|
5922
|
+
);
|
5103
5923
|
} else if (j$.isArray_(value) || j$.isA_('Object', value)) {
|
5104
5924
|
this.seen.push(value);
|
5105
5925
|
if (j$.isArray_(value)) {
|
@@ -5129,7 +5949,6 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5129
5949
|
var getter = obj.__lookupGetter__(prop);
|
5130
5950
|
return !j$.util.isUndefined(getter) && getter !== null;
|
5131
5951
|
};
|
5132
|
-
|
5133
5952
|
}
|
5134
5953
|
var length = Math.min(objKeys.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
|
5135
5954
|
for (var i = 0; i < length; i++) {
|
@@ -5145,7 +5964,7 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5145
5964
|
};
|
5146
5965
|
|
5147
5966
|
PrettyPrinter.prototype.emitString = function(value) {
|
5148
|
-
this.append('
|
5967
|
+
this.append("'" + value + "'");
|
5149
5968
|
};
|
5150
5969
|
|
5151
5970
|
PrettyPrinter.prototype.emitArray = function(array) {
|
@@ -5161,7 +5980,7 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5161
5980
|
}
|
5162
5981
|
this.format(array[i]);
|
5163
5982
|
}
|
5164
|
-
if(array.length > length){
|
5983
|
+
if (array.length > length) {
|
5165
5984
|
this.append(', ...');
|
5166
5985
|
}
|
5167
5986
|
|
@@ -5177,7 +5996,9 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5177
5996
|
self.formatProperty(array, property, isGetter);
|
5178
5997
|
});
|
5179
5998
|
|
5180
|
-
if (truncated) {
|
5999
|
+
if (truncated) {
|
6000
|
+
this.append(', ...');
|
6001
|
+
}
|
5181
6002
|
|
5182
6003
|
this.append(' ]');
|
5183
6004
|
};
|
@@ -5190,7 +6011,7 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5190
6011
|
this.append('Set( ');
|
5191
6012
|
var size = Math.min(set.size, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
|
5192
6013
|
var i = 0;
|
5193
|
-
set.forEach(
|
6014
|
+
set.forEach(function(value, key) {
|
5194
6015
|
if (i >= size) {
|
5195
6016
|
return;
|
5196
6017
|
}
|
@@ -5200,8 +6021,8 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5200
6021
|
this.format(value);
|
5201
6022
|
|
5202
6023
|
i++;
|
5203
|
-
}, this
|
5204
|
-
if (set.size > size){
|
6024
|
+
}, this);
|
6025
|
+
if (set.size > size) {
|
5205
6026
|
this.append(', ...');
|
5206
6027
|
}
|
5207
6028
|
this.append(' )');
|
@@ -5215,18 +6036,18 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5215
6036
|
this.append('Map( ');
|
5216
6037
|
var size = Math.min(map.size, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
|
5217
6038
|
var i = 0;
|
5218
|
-
map.forEach(
|
6039
|
+
map.forEach(function(value, key) {
|
5219
6040
|
if (i >= size) {
|
5220
6041
|
return;
|
5221
6042
|
}
|
5222
6043
|
if (i > 0) {
|
5223
6044
|
this.append(', ');
|
5224
6045
|
}
|
5225
|
-
this.format([key,value]);
|
6046
|
+
this.format([key, value]);
|
5226
6047
|
|
5227
6048
|
i++;
|
5228
|
-
}, this
|
5229
|
-
if (map.size > size){
|
6049
|
+
}, this);
|
6050
|
+
if (map.size > size) {
|
5230
6051
|
this.append(', ...');
|
5231
6052
|
}
|
5232
6053
|
this.append(' )');
|
@@ -5234,11 +6055,12 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5234
6055
|
|
5235
6056
|
PrettyPrinter.prototype.emitObject = function(obj) {
|
5236
6057
|
var ctor = obj.constructor,
|
5237
|
-
|
6058
|
+
constructorName;
|
5238
6059
|
|
5239
|
-
constructorName =
|
5240
|
-
|
5241
|
-
|
6060
|
+
constructorName =
|
6061
|
+
typeof ctor === 'function' && obj instanceof ctor
|
6062
|
+
? j$.fnNameFor(obj.constructor)
|
6063
|
+
: 'null';
|
5242
6064
|
|
5243
6065
|
this.append(constructorName);
|
5244
6066
|
|
@@ -5260,14 +6082,20 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5260
6082
|
self.formatProperty(obj, property, isGetter);
|
5261
6083
|
});
|
5262
6084
|
|
5263
|
-
if (truncated) {
|
6085
|
+
if (truncated) {
|
6086
|
+
this.append(', ...');
|
6087
|
+
}
|
5264
6088
|
|
5265
6089
|
this.append(' })');
|
5266
6090
|
};
|
5267
6091
|
|
5268
6092
|
PrettyPrinter.prototype.emitTypedArray = function(arr) {
|
5269
6093
|
var constructorName = j$.fnNameFor(arr.constructor),
|
5270
|
-
limitedArray = Array.prototype.slice.call(
|
6094
|
+
limitedArray = Array.prototype.slice.call(
|
6095
|
+
arr,
|
6096
|
+
0,
|
6097
|
+
j$.MAX_PRETTY_PRINT_ARRAY_LENGTH
|
6098
|
+
),
|
5271
6099
|
itemsString = Array.prototype.join.call(limitedArray, ', ');
|
5272
6100
|
|
5273
6101
|
if (limitedArray.length !== arr.length) {
|
@@ -5304,16 +6132,22 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5304
6132
|
};
|
5305
6133
|
|
5306
6134
|
PrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
|
5307
|
-
|
5308
|
-
|
5309
|
-
|
5310
|
-
|
5311
|
-
|
5312
|
-
|
5313
|
-
|
6135
|
+
this.append(property);
|
6136
|
+
this.append(': ');
|
6137
|
+
if (isGetter) {
|
6138
|
+
this.append('<getter>');
|
6139
|
+
} else {
|
6140
|
+
this.format(obj[property]);
|
6141
|
+
}
|
5314
6142
|
};
|
5315
6143
|
|
5316
6144
|
PrettyPrinter.prototype.append = function(value) {
|
6145
|
+
// This check protects us from the rare case where an object has overriden
|
6146
|
+
// `toString()` with an invalid implementation (returning a non-string).
|
6147
|
+
if (typeof value !== 'string') {
|
6148
|
+
value = Object.prototype.toString.call(value);
|
6149
|
+
}
|
6150
|
+
|
5317
6151
|
var result = truncate(value, j$.MAX_PRETTY_PRINT_CHARS - this.length);
|
5318
6152
|
this.length += result.value.length;
|
5319
6153
|
this.stringParts.push(result.value);
|
@@ -5323,7 +6157,6 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5323
6157
|
}
|
5324
6158
|
};
|
5325
6159
|
|
5326
|
-
|
5327
6160
|
function truncate(s, maxlen) {
|
5328
6161
|
if (s.length <= maxlen) {
|
5329
6162
|
return { value: s, truncated: false };
|
@@ -5334,30 +6167,33 @@ getJasmineRequireObj().pp = function(j$) {
|
|
5334
6167
|
}
|
5335
6168
|
|
5336
6169
|
function MaxCharsReachedError() {
|
5337
|
-
this.message =
|
6170
|
+
this.message =
|
6171
|
+
'Exceeded ' +
|
6172
|
+
j$.MAX_PRETTY_PRINT_CHARS +
|
5338
6173
|
' characters while pretty-printing a value';
|
5339
6174
|
}
|
5340
6175
|
|
5341
6176
|
MaxCharsReachedError.prototype = new Error();
|
5342
6177
|
|
5343
6178
|
function keys(obj, isArray) {
|
5344
|
-
var allKeys = Object.keys
|
5345
|
-
(
|
6179
|
+
var allKeys = Object.keys
|
6180
|
+
? Object.keys(obj)
|
6181
|
+
: (function(o) {
|
5346
6182
|
var keys = [];
|
5347
6183
|
for (var key in o) {
|
5348
|
-
|
5349
|
-
|
5350
|
-
|
6184
|
+
if (j$.util.has(o, key)) {
|
6185
|
+
keys.push(key);
|
6186
|
+
}
|
5351
6187
|
}
|
5352
6188
|
return keys;
|
5353
|
-
|
6189
|
+
})(obj);
|
5354
6190
|
|
5355
6191
|
if (!isArray) {
|
5356
6192
|
return allKeys;
|
5357
6193
|
}
|
5358
6194
|
|
5359
6195
|
if (allKeys.length === 0) {
|
5360
|
-
|
6196
|
+
return allKeys;
|
5361
6197
|
}
|
5362
6198
|
|
5363
6199
|
var extraKeys = [];
|
@@ -5400,16 +6236,26 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
5400
6236
|
this.queueableFns = queueableFns.concat(attrs.cleanupFns || []);
|
5401
6237
|
this.firstCleanupIx = queueableFns.length;
|
5402
6238
|
this.onComplete = attrs.onComplete || emptyFn;
|
5403
|
-
this.clearStack =
|
6239
|
+
this.clearStack =
|
6240
|
+
attrs.clearStack ||
|
6241
|
+
function(fn) {
|
6242
|
+
fn();
|
6243
|
+
};
|
5404
6244
|
this.onException = attrs.onException || emptyFn;
|
5405
6245
|
this.userContext = attrs.userContext || new j$.UserContext();
|
5406
|
-
this.timeout = attrs.timeout || {
|
6246
|
+
this.timeout = attrs.timeout || {
|
6247
|
+
setTimeout: setTimeout,
|
6248
|
+
clearTimeout: clearTimeout
|
6249
|
+
};
|
5407
6250
|
this.fail = attrs.fail || emptyFn;
|
5408
|
-
this.globalErrors = attrs.globalErrors || {
|
6251
|
+
this.globalErrors = attrs.globalErrors || {
|
6252
|
+
pushListener: emptyFn,
|
6253
|
+
popListener: emptyFn
|
6254
|
+
};
|
5409
6255
|
this.completeOnFirstError = !!attrs.completeOnFirstError;
|
5410
6256
|
this.errored = false;
|
5411
6257
|
|
5412
|
-
if (typeof
|
6258
|
+
if (typeof this.onComplete !== 'function') {
|
5413
6259
|
throw new Error('invalid onComplete ' + JSON.stringify(this.onComplete));
|
5414
6260
|
}
|
5415
6261
|
this.deprecated = attrs.deprecated;
|
@@ -5417,8 +6263,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
5417
6263
|
|
5418
6264
|
QueueRunner.prototype.execute = function() {
|
5419
6265
|
var self = this;
|
5420
|
-
this.handleFinalError = function(error) {
|
5421
|
-
|
6266
|
+
this.handleFinalError = function(message, source, lineno, colno, error) {
|
6267
|
+
// Older browsers would send the error as the first parameter. HTML5
|
6268
|
+
// specifies the the five parameters above. The error instance should
|
6269
|
+
// be preffered, otherwise the call stack would get lost.
|
6270
|
+
self.onException(error || message);
|
5422
6271
|
};
|
5423
6272
|
this.globalErrors.pushListener(this.handleFinalError);
|
5424
6273
|
this.run(0);
|
@@ -5433,15 +6282,22 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
5433
6282
|
};
|
5434
6283
|
|
5435
6284
|
QueueRunner.prototype.clearTimeout = function(timeoutId) {
|
5436
|
-
Function.prototype.apply.apply(this.timeout.clearTimeout, [
|
6285
|
+
Function.prototype.apply.apply(this.timeout.clearTimeout, [
|
6286
|
+
j$.getGlobal(),
|
6287
|
+
[timeoutId]
|
6288
|
+
]);
|
5437
6289
|
};
|
5438
6290
|
|
5439
6291
|
QueueRunner.prototype.setTimeout = function(fn, timeout) {
|
5440
|
-
return Function.prototype.apply.apply(this.timeout.setTimeout, [
|
6292
|
+
return Function.prototype.apply.apply(this.timeout.setTimeout, [
|
6293
|
+
j$.getGlobal(),
|
6294
|
+
[fn, timeout]
|
6295
|
+
]);
|
5441
6296
|
};
|
5442
6297
|
|
5443
6298
|
QueueRunner.prototype.attempt = function attempt(iterativeIndex) {
|
5444
|
-
var self = this,
|
6299
|
+
var self = this,
|
6300
|
+
completedSynchronously = true,
|
5445
6301
|
handleError = function handleError(error) {
|
5446
6302
|
onException(error);
|
5447
6303
|
next(error);
|
@@ -5492,8 +6348,12 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
5492
6348
|
var timeoutInterval = queueableFn.timeout || j$.DEFAULT_TIMEOUT_INTERVAL;
|
5493
6349
|
timeoutId = self.setTimeout(function() {
|
5494
6350
|
var error = new Error(
|
5495
|
-
'Timeout - Async
|
5496
|
-
|
6351
|
+
'Timeout - Async function did not complete within ' +
|
6352
|
+
timeoutInterval +
|
6353
|
+
'ms ' +
|
6354
|
+
(queueableFn.timeout
|
6355
|
+
? '(custom timeout)'
|
6356
|
+
: '(set by jasmine.DEFAULT_TIMEOUT_INTERVAL)')
|
5497
6357
|
);
|
5498
6358
|
onException(error);
|
5499
6359
|
next();
|
@@ -5538,8 +6398,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
5538
6398
|
self = this,
|
5539
6399
|
iterativeIndex;
|
5540
6400
|
|
5541
|
-
|
5542
|
-
|
6401
|
+
for (
|
6402
|
+
iterativeIndex = recursiveIndex;
|
6403
|
+
iterativeIndex < length;
|
6404
|
+
iterativeIndex++
|
6405
|
+
) {
|
5543
6406
|
var result = this.attempt(iterativeIndex);
|
5544
6407
|
|
5545
6408
|
if (!result.completedSynchronously) {
|
@@ -5558,7 +6421,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
5558
6421
|
self.globalErrors.popListener(self.handleFinalError);
|
5559
6422
|
self.onComplete(self.errored && new StopExecutionError());
|
5560
6423
|
});
|
5561
|
-
|
5562
6424
|
};
|
5563
6425
|
|
5564
6426
|
return QueueRunner;
|
@@ -5566,7 +6428,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
5566
6428
|
|
5567
6429
|
getJasmineRequireObj().ReportDispatcher = function(j$) {
|
5568
6430
|
function ReportDispatcher(methods, queueRunnerFactory) {
|
5569
|
-
|
5570
6431
|
var dispatchedMethods = methods || [];
|
5571
6432
|
|
5572
6433
|
for (var i = 0; i < dispatchedMethods.length; i++) {
|
@@ -5575,7 +6436,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|
5575
6436
|
return function() {
|
5576
6437
|
dispatch(m, arguments);
|
5577
6438
|
};
|
5578
|
-
}(method)
|
6439
|
+
})(method);
|
5579
6440
|
}
|
5580
6441
|
|
5581
6442
|
var reporters = [];
|
@@ -5597,7 +6458,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|
5597
6458
|
|
5598
6459
|
function dispatch(method, args) {
|
5599
6460
|
if (reporters.length === 0 && fallbackReporter !== null) {
|
5600
|
-
|
6461
|
+
reporters.push(fallbackReporter);
|
5601
6462
|
}
|
5602
6463
|
var onComplete = args[args.length - 1];
|
5603
6464
|
args = j$.util.argsToArray(args).splice(0, args.length - 1);
|
@@ -5623,13 +6484,13 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|
5623
6484
|
var thisArgs = j$.util.cloneArgs(args);
|
5624
6485
|
if (fn.length <= 1) {
|
5625
6486
|
fns.push({
|
5626
|
-
fn: function
|
6487
|
+
fn: function() {
|
5627
6488
|
return fn.apply(reporter, thisArgs);
|
5628
6489
|
}
|
5629
6490
|
});
|
5630
6491
|
} else {
|
5631
6492
|
fns.push({
|
5632
|
-
fn: function
|
6493
|
+
fn: function(done) {
|
5633
6494
|
return fn.apply(reporter, thisArgs.concat([done]));
|
5634
6495
|
}
|
5635
6496
|
});
|
@@ -5640,7 +6501,6 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|
5640
6501
|
return ReportDispatcher;
|
5641
6502
|
};
|
5642
6503
|
|
5643
|
-
|
5644
6504
|
getJasmineRequireObj().interface = function(jasmine, env) {
|
5645
6505
|
var jasmineInterface = {
|
5646
6506
|
/**
|
@@ -5658,6 +6518,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5658
6518
|
*
|
5659
6519
|
* Calls to `describe` can be nested within other calls to compose your suite as a tree.
|
5660
6520
|
* @name describe
|
6521
|
+
* @since 1.3.0
|
5661
6522
|
* @function
|
5662
6523
|
* @global
|
5663
6524
|
* @param {String} description Textual description of the group
|
@@ -5672,6 +6533,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5672
6533
|
*
|
5673
6534
|
* Specs within an `xdescribe` will be marked pending and not executed
|
5674
6535
|
* @name xdescribe
|
6536
|
+
* @since 1.3.0
|
5675
6537
|
* @function
|
5676
6538
|
* @global
|
5677
6539
|
* @param {String} description Textual description of the group
|
@@ -5687,6 +6549,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5687
6549
|
* If suites or specs are focused, only those that are focused will be executed
|
5688
6550
|
* @see fit
|
5689
6551
|
* @name fdescribe
|
6552
|
+
* @since 2.1.0
|
5690
6553
|
* @function
|
5691
6554
|
* @global
|
5692
6555
|
* @param {String} description Textual description of the group
|
@@ -5701,6 +6564,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5701
6564
|
*
|
5702
6565
|
* A spec whose expectations all succeed will be passing and a spec with any failures will fail.
|
5703
6566
|
* @name it
|
6567
|
+
* @since 1.3.0
|
5704
6568
|
* @function
|
5705
6569
|
* @global
|
5706
6570
|
* @param {String} description Textual description of what this spec is checking
|
@@ -5717,6 +6581,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5717
6581
|
*
|
5718
6582
|
* The spec will report as `pending` and will not be executed.
|
5719
6583
|
* @name xit
|
6584
|
+
* @since 1.3.0
|
5720
6585
|
* @function
|
5721
6586
|
* @global
|
5722
6587
|
* @param {String} description Textual description of what this spec is checking.
|
@@ -5731,6 +6596,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5731
6596
|
*
|
5732
6597
|
* If suites or specs are focused, only those that are focused will be executed.
|
5733
6598
|
* @name fit
|
6599
|
+
* @since 2.1.0
|
5734
6600
|
* @function
|
5735
6601
|
* @global
|
5736
6602
|
* @param {String} description Textual description of what this spec is checking.
|
@@ -5745,6 +6611,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5745
6611
|
/**
|
5746
6612
|
* Run some shared setup before each of the specs in the {@link describe} in which it is called.
|
5747
6613
|
* @name beforeEach
|
6614
|
+
* @since 1.3.0
|
5748
6615
|
* @function
|
5749
6616
|
* @global
|
5750
6617
|
* @param {implementationCallback} [function] Function that contains the code to setup your specs.
|
@@ -5758,6 +6625,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5758
6625
|
/**
|
5759
6626
|
* Run some shared teardown after each of the specs in the {@link describe} in which it is called.
|
5760
6627
|
* @name afterEach
|
6628
|
+
* @since 1.3.0
|
5761
6629
|
* @function
|
5762
6630
|
* @global
|
5763
6631
|
* @param {implementationCallback} [function] Function that contains the code to teardown your specs.
|
@@ -5773,6 +6641,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5773
6641
|
*
|
5774
6642
|
* _Note:_ Be careful, sharing the setup from a beforeAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail.
|
5775
6643
|
* @name beforeAll
|
6644
|
+
* @since 2.1.0
|
5776
6645
|
* @function
|
5777
6646
|
* @global
|
5778
6647
|
* @param {implementationCallback} [function] Function that contains the code to setup your specs.
|
@@ -5788,6 +6657,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5788
6657
|
*
|
5789
6658
|
* _Note:_ Be careful, sharing the teardown from a afterAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail.
|
5790
6659
|
* @name afterAll
|
6660
|
+
* @since 2.1.0
|
5791
6661
|
* @function
|
5792
6662
|
* @global
|
5793
6663
|
* @param {implementationCallback} [function] Function that contains the code to teardown your specs.
|
@@ -5801,6 +6671,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5801
6671
|
/**
|
5802
6672
|
* Create an expectation for a spec.
|
5803
6673
|
* @name expect
|
6674
|
+
* @since 1.3.0
|
5804
6675
|
* @function
|
5805
6676
|
* @global
|
5806
6677
|
* @param {Object} actual - Actual computed value to test expectations against.
|
@@ -5816,6 +6687,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5816
6687
|
* which must be either returned from the spec or waited for using `await`
|
5817
6688
|
* in order for Jasmine to associate them with the correct spec.
|
5818
6689
|
* @name expectAsync
|
6690
|
+
* @since 3.3.0
|
5819
6691
|
* @function
|
5820
6692
|
* @global
|
5821
6693
|
* @param {Object} actual - Actual computed value to test expectations against.
|
@@ -5832,6 +6704,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5832
6704
|
/**
|
5833
6705
|
* Mark a spec as pending, expectation results will be ignored.
|
5834
6706
|
* @name pending
|
6707
|
+
* @since 2.0.0
|
5835
6708
|
* @function
|
5836
6709
|
* @global
|
5837
6710
|
* @param {String} [message] - Reason the spec is pending.
|
@@ -5843,10 +6716,11 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5843
6716
|
/**
|
5844
6717
|
* Explicitly mark a spec as failed.
|
5845
6718
|
* @name fail
|
6719
|
+
* @since 2.1.0
|
5846
6720
|
* @function
|
5847
6721
|
* @global
|
5848
6722
|
* @param {String|Error} [error] - Reason for the failure.
|
5849
|
-
|
6723
|
+
*/
|
5850
6724
|
fail: function() {
|
5851
6725
|
return env.fail.apply(env, arguments);
|
5852
6726
|
},
|
@@ -5854,6 +6728,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5854
6728
|
/**
|
5855
6729
|
* Install a spy onto an existing object.
|
5856
6730
|
* @name spyOn
|
6731
|
+
* @since 1.3.0
|
5857
6732
|
* @function
|
5858
6733
|
* @global
|
5859
6734
|
* @param {Object} obj - The object upon which to install the {@link Spy}.
|
@@ -5867,6 +6742,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5867
6742
|
/**
|
5868
6743
|
* Install a spy on a property installed with `Object.defineProperty` onto an existing object.
|
5869
6744
|
* @name spyOnProperty
|
6745
|
+
* @since 2.6.0
|
5870
6746
|
* @function
|
5871
6747
|
* @global
|
5872
6748
|
* @param {Object} obj - The object upon which to install the {@link Spy}
|
@@ -5881,6 +6757,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5881
6757
|
/**
|
5882
6758
|
* Installs spies on all writable and configurable properties of an object.
|
5883
6759
|
* @name spyOnAllFunctions
|
6760
|
+
* @since 3.2.1
|
5884
6761
|
* @function
|
5885
6762
|
* @global
|
5886
6763
|
* @param {Object} obj - The object upon which to install the {@link Spy}s
|
@@ -5905,6 +6782,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5905
6782
|
*
|
5906
6783
|
* _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
|
5907
6784
|
* @name jasmine.addCustomEqualityTester
|
6785
|
+
* @since 2.0.0
|
5908
6786
|
* @function
|
5909
6787
|
* @param {Function} tester - A function which takes two arguments to compare and returns a `true` or `false` comparison result if it knows how to compare them, and `undefined` otherwise.
|
5910
6788
|
* @see custom_equality
|
@@ -5918,6 +6796,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5918
6796
|
*
|
5919
6797
|
* _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
|
5920
6798
|
* @name jasmine.addMatchers
|
6799
|
+
* @since 2.0.0
|
5921
6800
|
* @function
|
5922
6801
|
* @param {Object} matchers - Keys from this object will be the new matcher names.
|
5923
6802
|
* @see custom_matcher
|
@@ -5926,9 +6805,24 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5926
6805
|
return env.addMatchers(matchers);
|
5927
6806
|
};
|
5928
6807
|
|
6808
|
+
/**
|
6809
|
+
* Add custom async matchers for the current scope of specs.
|
6810
|
+
*
|
6811
|
+
* _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
|
6812
|
+
* @name jasmine.addAsyncMatchers
|
6813
|
+
* @since 3.5.0
|
6814
|
+
* @function
|
6815
|
+
* @param {Object} matchers - Keys from this object will be the new async matcher names.
|
6816
|
+
* @see custom_matcher
|
6817
|
+
*/
|
6818
|
+
jasmine.addAsyncMatchers = function(matchers) {
|
6819
|
+
return env.addAsyncMatchers(matchers);
|
6820
|
+
};
|
6821
|
+
|
5929
6822
|
/**
|
5930
6823
|
* Get the currently booted mock {Clock} for this Jasmine environment.
|
5931
6824
|
* @name jasmine.clock
|
6825
|
+
* @since 2.0.0
|
5932
6826
|
* @function
|
5933
6827
|
* @returns {Clock}
|
5934
6828
|
*/
|
@@ -5939,6 +6833,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5939
6833
|
/**
|
5940
6834
|
* Create a bare {@link Spy} object. This won't be installed anywhere and will not have any implementation behind it.
|
5941
6835
|
* @name jasmine.createSpy
|
6836
|
+
* @since 1.3.0
|
5942
6837
|
* @function
|
5943
6838
|
* @param {String} [name] - Name to give the spy. This will be displayed in failure messages.
|
5944
6839
|
* @param {Function} [originalFn] - Function to act as the real implementation.
|
@@ -5951,13 +6846,15 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5951
6846
|
/**
|
5952
6847
|
* Create an object with multiple {@link Spy}s as its members.
|
5953
6848
|
* @name jasmine.createSpyObj
|
6849
|
+
* @since 1.3.0
|
5954
6850
|
* @function
|
5955
6851
|
* @param {String} [baseName] - Base name for the spies in the object.
|
5956
6852
|
* @param {String[]|Object} methodNames - Array of method names to create spies for, or Object whose keys will be method names and values the {@link Spy#and#returnValue|returnValue}.
|
6853
|
+
* @param {String[]|Object} [propertyNames] - Array of property names to create spies for, or Object whose keys will be propertynames and values the {@link Spy#and#returnValue|returnValue}.
|
5957
6854
|
* @return {Object}
|
5958
6855
|
*/
|
5959
|
-
jasmine.createSpyObj = function(baseName, methodNames) {
|
5960
|
-
return env.createSpyObj(baseName, methodNames);
|
6856
|
+
jasmine.createSpyObj = function(baseName, methodNames, propertyNames) {
|
6857
|
+
return env.createSpyObj(baseName, methodNames, propertyNames);
|
5961
6858
|
};
|
5962
6859
|
|
5963
6860
|
/**
|
@@ -5965,6 +6862,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5965
6862
|
*
|
5966
6863
|
* _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
|
5967
6864
|
* @name jasmine.addSpyStrategy
|
6865
|
+
* @since 3.5.0
|
5968
6866
|
* @function
|
5969
6867
|
* @param {String} name - The name of the strategy (i.e. what you call from `and`)
|
5970
6868
|
* @param {Function} factory - Factory function that returns the plan to be executed.
|
@@ -5973,11 +6871,26 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
5973
6871
|
return env.addSpyStrategy(name, factory);
|
5974
6872
|
};
|
5975
6873
|
|
6874
|
+
/**
|
6875
|
+
* Set the default spy strategy for the current scope of specs.
|
6876
|
+
*
|
6877
|
+
* _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
|
6878
|
+
* @name jasmine.setDefaultSpyStrategy
|
6879
|
+
* @function
|
6880
|
+
* @param {Function} defaultStrategyFn - a function that assigns a strategy
|
6881
|
+
* @example
|
6882
|
+
* beforeEach(function() {
|
6883
|
+
* jasmine.setDefaultSpyStrategy(and => and.returnValue(true));
|
6884
|
+
* });
|
6885
|
+
*/
|
6886
|
+
jasmine.setDefaultSpyStrategy = function(defaultStrategyFn) {
|
6887
|
+
return env.setDefaultSpyStrategy(defaultStrategyFn);
|
6888
|
+
};
|
6889
|
+
|
5976
6890
|
return jasmineInterface;
|
5977
6891
|
};
|
5978
6892
|
|
5979
|
-
getJasmineRequireObj().Spy = function
|
5980
|
-
|
6893
|
+
getJasmineRequireObj().Spy = function(j$) {
|
5981
6894
|
var nextOrder = (function() {
|
5982
6895
|
var order = 0;
|
5983
6896
|
|
@@ -5991,21 +6904,28 @@ getJasmineRequireObj().Spy = function (j$) {
|
|
5991
6904
|
* @constructor
|
5992
6905
|
* @name Spy
|
5993
6906
|
*/
|
5994
|
-
function Spy(
|
5995
|
-
|
5996
|
-
|
6907
|
+
function Spy(
|
6908
|
+
name,
|
6909
|
+
originalFn,
|
6910
|
+
customStrategies,
|
6911
|
+
defaultStrategyFn,
|
6912
|
+
getPromise
|
6913
|
+
) {
|
6914
|
+
var numArgs = typeof originalFn === 'function' ? originalFn.length : 0,
|
6915
|
+
wrapper = makeFunc(numArgs, function() {
|
5997
6916
|
return spy.apply(this, Array.prototype.slice.call(arguments));
|
5998
6917
|
}),
|
5999
6918
|
strategyDispatcher = new SpyStrategyDispatcher({
|
6000
6919
|
name: name,
|
6001
6920
|
fn: originalFn,
|
6002
|
-
getSpy: function
|
6921
|
+
getSpy: function() {
|
6003
6922
|
return wrapper;
|
6004
6923
|
},
|
6005
|
-
customStrategies: customStrategies
|
6924
|
+
customStrategies: customStrategies,
|
6925
|
+
getPromise: getPromise
|
6006
6926
|
}),
|
6007
6927
|
callTracker = new j$.CallTracker(),
|
6008
|
-
spy = function
|
6928
|
+
spy = function() {
|
6009
6929
|
/**
|
6010
6930
|
* @name Spy.callData
|
6011
6931
|
* @property {object} object - `this` context for the invocation.
|
@@ -6027,22 +6947,54 @@ getJasmineRequireObj().Spy = function (j$) {
|
|
6027
6947
|
|
6028
6948
|
function makeFunc(length, fn) {
|
6029
6949
|
switch (length) {
|
6030
|
-
case 1
|
6031
|
-
|
6032
|
-
|
6033
|
-
|
6034
|
-
case
|
6035
|
-
|
6036
|
-
|
6037
|
-
|
6038
|
-
case
|
6039
|
-
|
6950
|
+
case 1:
|
6951
|
+
return function(a) {
|
6952
|
+
return fn.apply(this, arguments);
|
6953
|
+
};
|
6954
|
+
case 2:
|
6955
|
+
return function(a, b) {
|
6956
|
+
return fn.apply(this, arguments);
|
6957
|
+
};
|
6958
|
+
case 3:
|
6959
|
+
return function(a, b, c) {
|
6960
|
+
return fn.apply(this, arguments);
|
6961
|
+
};
|
6962
|
+
case 4:
|
6963
|
+
return function(a, b, c, d) {
|
6964
|
+
return fn.apply(this, arguments);
|
6965
|
+
};
|
6966
|
+
case 5:
|
6967
|
+
return function(a, b, c, d, e) {
|
6968
|
+
return fn.apply(this, arguments);
|
6969
|
+
};
|
6970
|
+
case 6:
|
6971
|
+
return function(a, b, c, d, e, f) {
|
6972
|
+
return fn.apply(this, arguments);
|
6973
|
+
};
|
6974
|
+
case 7:
|
6975
|
+
return function(a, b, c, d, e, f, g) {
|
6976
|
+
return fn.apply(this, arguments);
|
6977
|
+
};
|
6978
|
+
case 8:
|
6979
|
+
return function(a, b, c, d, e, f, g, h) {
|
6980
|
+
return fn.apply(this, arguments);
|
6981
|
+
};
|
6982
|
+
case 9:
|
6983
|
+
return function(a, b, c, d, e, f, g, h, i) {
|
6984
|
+
return fn.apply(this, arguments);
|
6985
|
+
};
|
6986
|
+
default:
|
6987
|
+
return function() {
|
6988
|
+
return fn.apply(this, arguments);
|
6989
|
+
};
|
6040
6990
|
}
|
6041
6991
|
}
|
6042
6992
|
|
6043
6993
|
for (var prop in originalFn) {
|
6044
6994
|
if (prop === 'and' || prop === 'calls') {
|
6045
|
-
throw new Error(
|
6995
|
+
throw new Error(
|
6996
|
+
"Jasmine spies would overwrite the 'and' and 'calls' properties on the object being spied upon"
|
6997
|
+
);
|
6046
6998
|
}
|
6047
6999
|
|
6048
7000
|
wrapper[prop] = originalFn[prop];
|
@@ -6053,6 +7005,7 @@ getJasmineRequireObj().Spy = function (j$) {
|
|
6053
7005
|
* whenever the spy is called with arguments that don't match any strategy
|
6054
7006
|
* created with {@link Spy#withArgs}.
|
6055
7007
|
* @name Spy#and
|
7008
|
+
* @since 2.0.0
|
6056
7009
|
* @example
|
6057
7010
|
* spyOn(someObj, 'func').and.returnValue(42);
|
6058
7011
|
*/
|
@@ -6061,6 +7014,7 @@ getJasmineRequireObj().Spy = function (j$) {
|
|
6061
7014
|
* Specifies a strategy to be used for calls to the spy that have the
|
6062
7015
|
* specified arguments.
|
6063
7016
|
* @name Spy#withArgs
|
7017
|
+
* @since 3.0.0
|
6064
7018
|
* @function
|
6065
7019
|
* @param {...*} args - The arguments to match
|
6066
7020
|
* @type {SpyStrategy}
|
@@ -6073,10 +7027,13 @@ getJasmineRequireObj().Spy = function (j$) {
|
|
6073
7027
|
};
|
6074
7028
|
wrapper.calls = callTracker;
|
6075
7029
|
|
7030
|
+
if (defaultStrategyFn) {
|
7031
|
+
defaultStrategyFn(wrapper.and);
|
7032
|
+
}
|
7033
|
+
|
6076
7034
|
return wrapper;
|
6077
7035
|
}
|
6078
7036
|
|
6079
|
-
|
6080
7037
|
function SpyStrategyDispatcher(strategyArgs) {
|
6081
7038
|
var baseStrategy = new j$.SpyStrategy(strategyArgs);
|
6082
7039
|
var argsStrategies = new StrategyDict(function() {
|
@@ -6090,7 +7047,13 @@ getJasmineRequireObj().Spy = function (j$) {
|
|
6090
7047
|
|
6091
7048
|
if (!strategy) {
|
6092
7049
|
if (argsStrategies.any() && !baseStrategy.isConfigured()) {
|
6093
|
-
throw new Error(
|
7050
|
+
throw new Error(
|
7051
|
+
"Spy '" +
|
7052
|
+
strategyArgs.name +
|
7053
|
+
"' received a call with arguments " +
|
7054
|
+
j$.pp(Array.prototype.slice.call(args)) +
|
7055
|
+
' but all configured strategies specify other arguments.'
|
7056
|
+
);
|
6094
7057
|
} else {
|
6095
7058
|
strategy = baseStrategy;
|
6096
7059
|
}
|
@@ -6141,41 +7104,56 @@ getJasmineRequireObj().Spy = function (j$) {
|
|
6141
7104
|
};
|
6142
7105
|
|
6143
7106
|
getJasmineRequireObj().SpyFactory = function(j$) {
|
6144
|
-
|
6145
|
-
function SpyFactory(getCustomStrategies) {
|
7107
|
+
function SpyFactory(getCustomStrategies, getDefaultStrategyFn, getPromise) {
|
6146
7108
|
var self = this;
|
6147
7109
|
|
6148
7110
|
this.createSpy = function(name, originalFn) {
|
6149
|
-
return j$.Spy(
|
7111
|
+
return j$.Spy(
|
7112
|
+
name,
|
7113
|
+
originalFn,
|
7114
|
+
getCustomStrategies(),
|
7115
|
+
getDefaultStrategyFn(),
|
7116
|
+
getPromise
|
7117
|
+
);
|
6150
7118
|
};
|
6151
7119
|
|
6152
|
-
this.createSpyObj = function(baseName, methodNames) {
|
6153
|
-
var baseNameIsCollection =
|
7120
|
+
this.createSpyObj = function(baseName, methodNames, propertyNames) {
|
7121
|
+
var baseNameIsCollection =
|
7122
|
+
j$.isObject_(baseName) || j$.isArray_(baseName);
|
6154
7123
|
|
6155
|
-
if (baseNameIsCollection
|
7124
|
+
if (baseNameIsCollection) {
|
7125
|
+
propertyNames = methodNames;
|
6156
7126
|
methodNames = baseName;
|
6157
7127
|
baseName = 'unknown';
|
6158
7128
|
}
|
6159
7129
|
|
6160
7130
|
var obj = {};
|
6161
|
-
var
|
7131
|
+
var spy, descriptor;
|
6162
7132
|
|
6163
|
-
|
6164
|
-
|
6165
|
-
|
6166
|
-
|
7133
|
+
var methods = normalizeKeyValues(methodNames);
|
7134
|
+
for (var i = 0; i < methods.length; i++) {
|
7135
|
+
spy = obj[methods[i][0]] = self.createSpy(
|
7136
|
+
baseName + '.' + methods[i][0]
|
7137
|
+
);
|
7138
|
+
if (methods[i].length > 1) {
|
7139
|
+
spy.and.returnValue(methods[i][1]);
|
6167
7140
|
}
|
6168
|
-
}
|
6169
|
-
|
6170
|
-
|
6171
|
-
|
6172
|
-
|
6173
|
-
|
6174
|
-
|
7141
|
+
}
|
7142
|
+
|
7143
|
+
var properties = normalizeKeyValues(propertyNames);
|
7144
|
+
for (var i = 0; i < properties.length; i++) {
|
7145
|
+
descriptor = {
|
7146
|
+
get: self.createSpy(baseName + '.' + properties[i][0] + '.get'),
|
7147
|
+
set: self.createSpy(baseName + '.' + properties[i][0] + '.set')
|
7148
|
+
};
|
7149
|
+
if (properties[i].length > 1) {
|
7150
|
+
descriptor.get.and.returnValue(properties[i][1]);
|
7151
|
+
descriptor.set.and.returnValue(properties[i][1]);
|
6175
7152
|
}
|
7153
|
+
Object.defineProperty(obj, properties[i][0], descriptor);
|
6176
7154
|
}
|
6177
7155
|
|
6178
|
-
if (
|
7156
|
+
if (methods.length === 0 && properties.length === 0) {
|
6179
7157
|
throw 'createSpyObj requires a non-empty array or object of method names to create spies for';
|
6180
7158
|
}
|
6181
7159
|
|
@@ -6183,27 +7161,55 @@ getJasmineRequireObj().SpyFactory = function(j$) {
|
|
6183
7161
|
};
|
6184
7162
|
}
|
6185
7163
|
|
7164
|
+
function normalizeKeyValues(object) {
|
7165
|
+
var result = [];
|
7166
|
+
if (j$.isArray_(object)) {
|
7167
|
+
for (var i = 0; i < object.length; i++) {
|
7168
|
+
result.push([object[i]]);
|
7169
|
+
}
|
7170
|
+
} else if (j$.isObject_(object)) {
|
7171
|
+
for (var key in object) {
|
7172
|
+
if (object.hasOwnProperty(key)) {
|
7173
|
+
result.push([key, object[key]]);
|
7174
|
+
}
|
7175
|
+
}
|
7176
|
+
}
|
7177
|
+
return result;
|
7178
|
+
}
|
7179
|
+
|
6186
7180
|
return SpyFactory;
|
6187
7181
|
};
|
6188
7182
|
|
6189
7183
|
getJasmineRequireObj().SpyRegistry = function(j$) {
|
6190
|
-
|
6191
|
-
var
|
7184
|
+
var spyOnMsg = j$.formatErrorMsg('<spyOn>', 'spyOn(<object>, <methodName>)');
|
7185
|
+
var spyOnPropertyMsg = j$.formatErrorMsg(
|
7186
|
+
'<spyOnProperty>',
|
7187
|
+
'spyOnProperty(<object>, <propName>, [accessType])'
|
7188
|
+
);
|
6192
7189
|
|
6193
7190
|
function SpyRegistry(options) {
|
6194
7191
|
options = options || {};
|
6195
7192
|
var global = options.global || j$.getGlobal();
|
6196
7193
|
var createSpy = options.createSpy;
|
6197
|
-
var currentSpies =
|
7194
|
+
var currentSpies =
|
7195
|
+
options.currentSpies ||
|
7196
|
+
function() {
|
7197
|
+
return [];
|
7198
|
+
};
|
6198
7199
|
|
6199
|
-
this.allowRespy = function(allow){
|
7200
|
+
this.allowRespy = function(allow) {
|
6200
7201
|
this.respy = allow;
|
6201
7202
|
};
|
6202
7203
|
|
6203
7204
|
this.spyOn = function(obj, methodName) {
|
7205
|
+
var getErrorMsg = spyOnMsg;
|
6204
7206
|
|
6205
7207
|
if (j$.util.isUndefined(obj) || obj === null) {
|
6206
|
-
throw new Error(
|
7208
|
+
throw new Error(
|
7209
|
+
getErrorMsg(
|
7210
|
+
'could not find an object to spy upon for ' + methodName + '()'
|
7211
|
+
)
|
7212
|
+
);
|
6207
7213
|
}
|
6208
7214
|
|
6209
7215
|
if (j$.util.isUndefined(methodName) || methodName === null) {
|
@@ -6214,25 +7220,32 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|
6214
7220
|
throw new Error(getErrorMsg(methodName + '() method does not exist'));
|
6215
7221
|
}
|
6216
7222
|
|
6217
|
-
if (obj[methodName] && j$.isSpy(obj[methodName])
|
6218
|
-
if (
|
7223
|
+
if (obj[methodName] && j$.isSpy(obj[methodName])) {
|
7224
|
+
if (this.respy) {
|
6219
7225
|
return obj[methodName];
|
6220
|
-
}else {
|
6221
|
-
throw new Error(
|
7226
|
+
} else {
|
7227
|
+
throw new Error(
|
7228
|
+
getErrorMsg(methodName + ' has already been spied upon')
|
7229
|
+
);
|
6222
7230
|
}
|
6223
7231
|
}
|
6224
7232
|
|
6225
7233
|
var descriptor = Object.getOwnPropertyDescriptor(obj, methodName);
|
6226
7234
|
|
6227
7235
|
if (descriptor && !(descriptor.writable || descriptor.set)) {
|
6228
|
-
throw new Error(
|
7236
|
+
throw new Error(
|
7237
|
+
getErrorMsg(methodName + ' is not declared writable or has no setter')
|
7238
|
+
);
|
6229
7239
|
}
|
6230
7240
|
|
6231
7241
|
var originalMethod = obj[methodName],
|
6232
7242
|
spiedMethod = createSpy(methodName, originalMethod),
|
6233
7243
|
restoreStrategy;
|
6234
7244
|
|
6235
|
-
if (
|
7245
|
+
if (
|
7246
|
+
Object.prototype.hasOwnProperty.call(obj, methodName) ||
|
7247
|
+
(obj === global && methodName === 'onerror')
|
7248
|
+
) {
|
6236
7249
|
restoreStrategy = function() {
|
6237
7250
|
obj[methodName] = originalMethod;
|
6238
7251
|
};
|
@@ -6253,34 +7266,58 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|
6253
7266
|
return spiedMethod;
|
6254
7267
|
};
|
6255
7268
|
|
6256
|
-
this.spyOnProperty = function
|
7269
|
+
this.spyOnProperty = function(obj, propertyName, accessType) {
|
7270
|
+
var getErrorMsg = spyOnPropertyMsg;
|
7271
|
+
|
6257
7272
|
accessType = accessType || 'get';
|
6258
7273
|
|
6259
7274
|
if (j$.util.isUndefined(obj)) {
|
6260
|
-
throw new Error(
|
7275
|
+
throw new Error(
|
7276
|
+
getErrorMsg(
|
7277
|
+
'spyOn could not find an object to spy upon for ' +
|
7278
|
+
propertyName +
|
7279
|
+
''
|
7280
|
+
)
|
7281
|
+
);
|
6261
7282
|
}
|
6262
7283
|
|
6263
7284
|
if (j$.util.isUndefined(propertyName)) {
|
6264
|
-
throw new Error('No property name supplied');
|
7285
|
+
throw new Error(getErrorMsg('No property name supplied'));
|
6265
7286
|
}
|
6266
7287
|
|
6267
7288
|
var descriptor = j$.util.getPropertyDescriptor(obj, propertyName);
|
6268
7289
|
|
6269
7290
|
if (!descriptor) {
|
6270
|
-
throw new Error(propertyName + ' property does not exist');
|
7291
|
+
throw new Error(getErrorMsg(propertyName + ' property does not exist'));
|
6271
7292
|
}
|
6272
7293
|
|
6273
7294
|
if (!descriptor.configurable) {
|
6274
|
-
throw new Error(
|
7295
|
+
throw new Error(
|
7296
|
+
getErrorMsg(propertyName + ' is not declared configurable')
|
7297
|
+
);
|
6275
7298
|
}
|
6276
7299
|
|
6277
|
-
if(!descriptor[accessType]) {
|
6278
|
-
throw new Error(
|
7300
|
+
if (!descriptor[accessType]) {
|
7301
|
+
throw new Error(
|
7302
|
+
getErrorMsg(
|
7303
|
+
'Property ' +
|
7304
|
+
propertyName +
|
7305
|
+
' does not have access type ' +
|
7306
|
+
accessType
|
7307
|
+
)
|
7308
|
+
);
|
6279
7309
|
}
|
6280
7310
|
|
6281
7311
|
if (j$.isSpy(descriptor[accessType])) {
|
6282
|
-
|
6283
|
-
|
7312
|
+
if (this.respy) {
|
7313
|
+
return descriptor[accessType];
|
7314
|
+
} else {
|
7315
|
+
throw new Error(
|
7316
|
+
getErrorMsg(
|
7317
|
+
propertyName + '#' + accessType + ' has already been spied upon'
|
7318
|
+
)
|
7319
|
+
);
|
7320
|
+
}
|
6284
7321
|
}
|
6285
7322
|
|
6286
7323
|
var originalDescriptor = j$.util.clone(descriptor),
|
@@ -6310,16 +7347,36 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|
6310
7347
|
|
6311
7348
|
this.spyOnAllFunctions = function(obj) {
|
6312
7349
|
if (j$.util.isUndefined(obj)) {
|
6313
|
-
throw new Error(
|
7350
|
+
throw new Error(
|
7351
|
+
'spyOnAllFunctions could not find an object to spy upon'
|
7352
|
+
);
|
6314
7353
|
}
|
6315
7354
|
|
6316
|
-
|
6317
|
-
|
6318
|
-
|
6319
|
-
|
6320
|
-
|
7355
|
+
var pointer = obj,
|
7356
|
+
props = [],
|
7357
|
+
prop,
|
7358
|
+
descriptor;
|
7359
|
+
|
7360
|
+
while (pointer) {
|
7361
|
+
for (prop in pointer) {
|
7362
|
+
if (
|
7363
|
+
Object.prototype.hasOwnProperty.call(pointer, prop) &&
|
7364
|
+
pointer[prop] instanceof Function
|
7365
|
+
) {
|
7366
|
+
descriptor = Object.getOwnPropertyDescriptor(pointer, prop);
|
7367
|
+
if (
|
7368
|
+
(descriptor.writable || descriptor.set) &&
|
7369
|
+
descriptor.configurable
|
7370
|
+
) {
|
7371
|
+
props.push(prop);
|
7372
|
+
}
|
6321
7373
|
}
|
6322
7374
|
}
|
7375
|
+
pointer = Object.getPrototypeOf(pointer);
|
7376
|
+
}
|
7377
|
+
|
7378
|
+
for (var i = 0; i < props.length; i++) {
|
7379
|
+
this.spyOn(obj, props[i]);
|
6323
7380
|
}
|
6324
7381
|
|
6325
7382
|
return obj;
|
@@ -6338,16 +7395,18 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|
6338
7395
|
};
|
6339
7396
|
|
6340
7397
|
getJasmineRequireObj().SpyStrategy = function(j$) {
|
6341
|
-
|
6342
7398
|
/**
|
6343
7399
|
* @interface SpyStrategy
|
6344
7400
|
*/
|
6345
7401
|
function SpyStrategy(options) {
|
6346
7402
|
options = options || {};
|
6347
7403
|
|
7404
|
+
var self = this;
|
7405
|
+
|
6348
7406
|
/**
|
6349
7407
|
* Get the identifying information for the spy.
|
6350
7408
|
* @name SpyStrategy#identity
|
7409
|
+
* @since 3.0.0
|
6351
7410
|
* @member
|
6352
7411
|
* @type {String}
|
6353
7412
|
*/
|
@@ -6356,12 +7415,62 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
6356
7415
|
this.getSpy = options.getSpy || function() {};
|
6357
7416
|
this.plan = this._defaultPlan = function() {};
|
6358
7417
|
|
6359
|
-
var k,
|
7418
|
+
var k,
|
7419
|
+
cs = options.customStrategies || {};
|
6360
7420
|
for (k in cs) {
|
6361
7421
|
if (j$.util.has(cs, k) && !this[k]) {
|
6362
7422
|
this[k] = createCustomPlan(cs[k]);
|
6363
7423
|
}
|
6364
7424
|
}
|
7425
|
+
|
7426
|
+
var getPromise =
|
7427
|
+
typeof options.getPromise === 'function'
|
7428
|
+
? options.getPromise
|
7429
|
+
: function() {};
|
7430
|
+
|
7431
|
+
var requirePromise = function(name) {
|
7432
|
+
var Promise = getPromise();
|
7433
|
+
|
7434
|
+
if (!Promise) {
|
7435
|
+
throw new Error(
|
7436
|
+
name +
|
7437
|
+
' requires global Promise, or `Promise` configured with `jasmine.getEnv().configure()`'
|
7438
|
+
);
|
7439
|
+
}
|
7440
|
+
|
7441
|
+
return Promise;
|
7442
|
+
};
|
7443
|
+
|
7444
|
+
/**
|
7445
|
+
* Tell the spy to return a promise resolving to the specified value when invoked.
|
7446
|
+
* @name SpyStrategy#resolveTo
|
7447
|
+
* @since 3.5.0
|
7448
|
+
* @function
|
7449
|
+
* @param {*} value The value to return.
|
7450
|
+
*/
|
7451
|
+
this.resolveTo = function(value) {
|
7452
|
+
var Promise = requirePromise('resolveTo');
|
7453
|
+
self.plan = function() {
|
7454
|
+
return Promise.resolve(value);
|
7455
|
+
};
|
7456
|
+
return self.getSpy();
|
7457
|
+
};
|
7458
|
+
|
7459
|
+
/**
|
7460
|
+
* Tell the spy to return a promise rejecting with the specified value when invoked.
|
7461
|
+
* @name SpyStrategy#rejectWith
|
7462
|
+
* @since 3.5.0
|
7463
|
+
* @function
|
7464
|
+
* @param {*} value The value to return.
|
7465
|
+
*/
|
7466
|
+
this.rejectWith = function(value) {
|
7467
|
+
var Promise = requirePromise('rejectWith');
|
7468
|
+
|
7469
|
+
self.plan = function() {
|
7470
|
+
return Promise.reject(value);
|
7471
|
+
};
|
7472
|
+
return self.getSpy();
|
7473
|
+
};
|
6365
7474
|
}
|
6366
7475
|
|
6367
7476
|
function createCustomPlan(factory) {
|
@@ -6380,6 +7489,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
6380
7489
|
/**
|
6381
7490
|
* Execute the current spy strategy.
|
6382
7491
|
* @name SpyStrategy#exec
|
7492
|
+
* @since 2.0.0
|
6383
7493
|
* @function
|
6384
7494
|
*/
|
6385
7495
|
SpyStrategy.prototype.exec = function(context, args) {
|
@@ -6389,6 +7499,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
6389
7499
|
/**
|
6390
7500
|
* Tell the spy to call through to the real implementation when invoked.
|
6391
7501
|
* @name SpyStrategy#callThrough
|
7502
|
+
* @since 2.0.0
|
6392
7503
|
* @function
|
6393
7504
|
*/
|
6394
7505
|
SpyStrategy.prototype.callThrough = function() {
|
@@ -6399,6 +7510,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
6399
7510
|
/**
|
6400
7511
|
* Tell the spy to return the value when invoked.
|
6401
7512
|
* @name SpyStrategy#returnValue
|
7513
|
+
* @since 2.0.0
|
6402
7514
|
* @function
|
6403
7515
|
* @param {*} value The value to return.
|
6404
7516
|
*/
|
@@ -6412,12 +7524,13 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
6412
7524
|
/**
|
6413
7525
|
* Tell the spy to return one of the specified values (sequentially) each time the spy is invoked.
|
6414
7526
|
* @name SpyStrategy#returnValues
|
7527
|
+
* @since 2.1.0
|
6415
7528
|
* @function
|
6416
7529
|
* @param {...*} values - Values to be returned on subsequent calls to the spy.
|
6417
7530
|
*/
|
6418
7531
|
SpyStrategy.prototype.returnValues = function() {
|
6419
7532
|
var values = Array.prototype.slice.call(arguments);
|
6420
|
-
this.plan = function
|
7533
|
+
this.plan = function() {
|
6421
7534
|
return values.shift();
|
6422
7535
|
};
|
6423
7536
|
return this.getSpy();
|
@@ -6426,11 +7539,12 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
6426
7539
|
/**
|
6427
7540
|
* Tell the spy to throw an error when invoked.
|
6428
7541
|
* @name SpyStrategy#throwError
|
7542
|
+
* @since 2.0.0
|
6429
7543
|
* @function
|
6430
7544
|
* @param {Error|String} something Thing to throw
|
6431
7545
|
*/
|
6432
7546
|
SpyStrategy.prototype.throwError = function(something) {
|
6433
|
-
var error =
|
7547
|
+
var error = something instanceof Error ? something : new Error(something);
|
6434
7548
|
this.plan = function() {
|
6435
7549
|
throw error;
|
6436
7550
|
};
|
@@ -6440,12 +7554,15 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
6440
7554
|
/**
|
6441
7555
|
* Tell the spy to call a fake implementation when invoked.
|
6442
7556
|
* @name SpyStrategy#callFake
|
7557
|
+
* @since 2.0.0
|
6443
7558
|
* @function
|
6444
7559
|
* @param {Function} fn The function to invoke with the passed parameters.
|
6445
7560
|
*/
|
6446
7561
|
SpyStrategy.prototype.callFake = function(fn) {
|
6447
|
-
if(!(j$.isFunction_(fn) || j$.isAsyncFunction_(fn))) {
|
6448
|
-
throw new Error(
|
7562
|
+
if (!(j$.isFunction_(fn) || j$.isAsyncFunction_(fn))) {
|
7563
|
+
throw new Error(
|
7564
|
+
'Argument passed to callFake should be a function, got ' + fn
|
7565
|
+
);
|
6449
7566
|
}
|
6450
7567
|
this.plan = fn;
|
6451
7568
|
return this.getSpy();
|
@@ -6454,6 +7571,7 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
6454
7571
|
/**
|
6455
7572
|
* Tell the spy to do nothing when invoked. This is the default.
|
6456
7573
|
* @name SpyStrategy#stub
|
7574
|
+
* @since 2.0.0
|
6457
7575
|
* @function
|
6458
7576
|
*/
|
6459
7577
|
SpyStrategy.prototype.stub = function(fn) {
|
@@ -6470,9 +7588,9 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
6470
7588
|
|
6471
7589
|
getJasmineRequireObj().StackTrace = function(j$) {
|
6472
7590
|
function StackTrace(error) {
|
6473
|
-
var lines = error.stack
|
6474
|
-
|
6475
|
-
|
7591
|
+
var lines = error.stack.split('\n').filter(function(line) {
|
7592
|
+
return line !== '';
|
7593
|
+
});
|
6476
7594
|
|
6477
7595
|
var extractResult = extractMessage(error.message, lines);
|
6478
7596
|
|
@@ -6491,7 +7609,12 @@ getJasmineRequireObj().StackTrace = function(j$) {
|
|
6491
7609
|
// e.g. " at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)"
|
6492
7610
|
// Note that the "function name" can include a surprisingly large set of
|
6493
7611
|
// characters, including angle brackets and square brackets.
|
6494
|
-
{
|
7612
|
+
{
|
7613
|
+
re: /^\s*at ([^\)]+) \(([^\)]+)\)$/,
|
7614
|
+
fnIx: 1,
|
7615
|
+
fileLineColIx: 2,
|
7616
|
+
style: 'v8'
|
7617
|
+
},
|
6495
7618
|
|
6496
7619
|
// NodeJS alternate form, often mixed in with the Chrome style
|
6497
7620
|
// e.g. " at /some/path:4320:20
|
@@ -6500,7 +7623,12 @@ getJasmineRequireObj().StackTrace = function(j$) {
|
|
6500
7623
|
// PhantomJS on OS X, Safari, Firefox
|
6501
7624
|
// e.g. "run@http://localhost:8888/__jasmine__/jasmine.js:4320:27"
|
6502
7625
|
// or "http://localhost:8888/__jasmine__/jasmine.js:4320:27"
|
6503
|
-
{
|
7626
|
+
{
|
7627
|
+
re: /^(([^@\s]+)@)?([^\s]+)$/,
|
7628
|
+
fnIx: 2,
|
7629
|
+
fileLineColIx: 3,
|
7630
|
+
style: 'webkit'
|
7631
|
+
}
|
6504
7632
|
];
|
6505
7633
|
|
6506
7634
|
// regexes should capture the function name (if any) as group 1
|
@@ -6511,11 +7639,16 @@ getJasmineRequireObj().StackTrace = function(j$) {
|
|
6511
7639
|
var convertedLine = first(framePatterns, function(pattern) {
|
6512
7640
|
var overallMatch = line.match(pattern.re),
|
6513
7641
|
fileLineColMatch;
|
6514
|
-
if (!overallMatch) {
|
7642
|
+
if (!overallMatch) {
|
7643
|
+
return null;
|
7644
|
+
}
|
6515
7645
|
|
6516
7646
|
fileLineColMatch = overallMatch[pattern.fileLineColIx].match(
|
6517
|
-
/^(.*):(\d+):\d+$/
|
6518
|
-
|
7647
|
+
/^(.*):(\d+):\d+$/
|
7648
|
+
);
|
7649
|
+
if (!fileLineColMatch) {
|
7650
|
+
return null;
|
7651
|
+
}
|
6519
7652
|
|
6520
7653
|
style = style || pattern.style;
|
6521
7654
|
return {
|
@@ -6574,7 +7707,7 @@ getJasmineRequireObj().StackTrace = function(j$) {
|
|
6574
7707
|
|
6575
7708
|
return messageLines.length;
|
6576
7709
|
}
|
6577
|
-
|
7710
|
+
|
6578
7711
|
return StackTrace;
|
6579
7712
|
};
|
6580
7713
|
|
@@ -6614,7 +7747,7 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
6614
7747
|
fullName: this.getFullName(),
|
6615
7748
|
failedExpectations: [],
|
6616
7749
|
deprecationWarnings: [],
|
6617
|
-
duration: null
|
7750
|
+
duration: null
|
6618
7751
|
};
|
6619
7752
|
}
|
6620
7753
|
|
@@ -6628,7 +7761,11 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
6628
7761
|
|
6629
7762
|
Suite.prototype.getFullName = function() {
|
6630
7763
|
var fullName = [];
|
6631
|
-
for (
|
7764
|
+
for (
|
7765
|
+
var parentSuite = this;
|
7766
|
+
parentSuite;
|
7767
|
+
parentSuite = parentSuite.parentSuite
|
7768
|
+
) {
|
6632
7769
|
if (parentSuite.parentSuite) {
|
6633
7770
|
fullName.unshift(parentSuite.description);
|
6634
7771
|
}
|
@@ -6665,7 +7802,7 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
6665
7802
|
};
|
6666
7803
|
|
6667
7804
|
function removeFns(queueableFns) {
|
6668
|
-
for(var i = 0; i < queueableFns.length; i++) {
|
7805
|
+
for (var i = 0; i < queueableFns.length; i++) {
|
6669
7806
|
queueableFns[i].fn = null;
|
6670
7807
|
}
|
6671
7808
|
}
|
@@ -6704,7 +7841,9 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
6704
7841
|
|
6705
7842
|
Suite.prototype.sharedUserContext = function() {
|
6706
7843
|
if (!this.sharedContext) {
|
6707
|
-
this.sharedContext = this.parentSuite
|
7844
|
+
this.sharedContext = this.parentSuite
|
7845
|
+
? this.parentSuite.clonedSharedUserContext()
|
7846
|
+
: new j$.UserContext();
|
6708
7847
|
}
|
6709
7848
|
|
6710
7849
|
return this.sharedContext;
|
@@ -6735,11 +7874,11 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
6735
7874
|
this.result.failedExpectations.push(failedExpectation);
|
6736
7875
|
};
|
6737
7876
|
|
6738
|
-
Suite.prototype.addExpectationResult = function
|
6739
|
-
if(isFailure(arguments)) {
|
7877
|
+
Suite.prototype.addExpectationResult = function() {
|
7878
|
+
if (isFailure(arguments)) {
|
6740
7879
|
var data = arguments[1];
|
6741
7880
|
this.result.failedExpectations.push(this.expectationResultFactory(data));
|
6742
|
-
if(this.throwOnExpectationFailure) {
|
7881
|
+
if (this.throwOnExpectationFailure) {
|
6743
7882
|
throw new j$.errors.ExpectationFailed();
|
6744
7883
|
}
|
6745
7884
|
}
|
@@ -6749,7 +7888,9 @@ getJasmineRequireObj().Suite = function(j$) {
|
|
6749
7888
|
if (typeof deprecation === 'string') {
|
6750
7889
|
deprecation = { message: deprecation };
|
6751
7890
|
}
|
6752
|
-
this.result.deprecationWarnings.push(
|
7891
|
+
this.result.deprecationWarnings.push(
|
7892
|
+
this.expectationResultFactory(deprecation)
|
7893
|
+
);
|
6753
7894
|
};
|
6754
7895
|
|
6755
7896
|
function isFailure(args) {
|
@@ -6766,7 +7907,9 @@ if (typeof window == void 0 && typeof exports == 'object') {
|
|
6766
7907
|
|
6767
7908
|
getJasmineRequireObj().Timer = function() {
|
6768
7909
|
var defaultNow = (function(Date) {
|
6769
|
-
return function() {
|
7910
|
+
return function() {
|
7911
|
+
return new Date().getTime();
|
7912
|
+
};
|
6770
7913
|
})(Date);
|
6771
7914
|
|
6772
7915
|
function Timer(options) {
|
@@ -6790,22 +7933,34 @@ getJasmineRequireObj().Timer = function() {
|
|
6790
7933
|
getJasmineRequireObj().noopTimer = function() {
|
6791
7934
|
return {
|
6792
7935
|
start: function() {},
|
6793
|
-
elapsed: function() {
|
7936
|
+
elapsed: function() {
|
7937
|
+
return 0;
|
7938
|
+
}
|
6794
7939
|
};
|
6795
7940
|
};
|
7941
|
+
|
6796
7942
|
getJasmineRequireObj().TreeProcessor = function() {
|
6797
7943
|
function TreeProcessor(attrs) {
|
6798
7944
|
var tree = attrs.tree,
|
6799
|
-
|
6800
|
-
|
6801
|
-
|
6802
|
-
|
6803
|
-
|
6804
|
-
|
6805
|
-
|
6806
|
-
|
6807
|
-
|
6808
|
-
|
7945
|
+
runnableIds = attrs.runnableIds,
|
7946
|
+
queueRunnerFactory = attrs.queueRunnerFactory,
|
7947
|
+
nodeStart = attrs.nodeStart || function() {},
|
7948
|
+
nodeComplete = attrs.nodeComplete || function() {},
|
7949
|
+
failSpecWithNoExpectations = !!attrs.failSpecWithNoExpectations,
|
7950
|
+
orderChildren =
|
7951
|
+
attrs.orderChildren ||
|
7952
|
+
function(node) {
|
7953
|
+
return node.children;
|
7954
|
+
},
|
7955
|
+
excludeNode =
|
7956
|
+
attrs.excludeNode ||
|
7957
|
+
function(node) {
|
7958
|
+
return false;
|
7959
|
+
},
|
7960
|
+
stats = { valid: true },
|
7961
|
+
processed = false,
|
7962
|
+
defaultMin = Infinity,
|
7963
|
+
defaultMax = 1 - Infinity;
|
6809
7964
|
|
6810
7965
|
this.processTree = function() {
|
6811
7966
|
processNode(tree, true);
|
@@ -6854,13 +8009,15 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|
6854
8009
|
stats[node.id] = {
|
6855
8010
|
excluded: excluded,
|
6856
8011
|
willExecute: !excluded && !node.markedPending,
|
6857
|
-
segments: [
|
6858
|
-
|
6859
|
-
|
6860
|
-
|
6861
|
-
|
6862
|
-
|
6863
|
-
|
8012
|
+
segments: [
|
8013
|
+
{
|
8014
|
+
index: 0,
|
8015
|
+
owner: node,
|
8016
|
+
nodes: [node],
|
8017
|
+
min: startingMin(executableIndex),
|
8018
|
+
max: startingMax(executableIndex)
|
8019
|
+
}
|
8020
|
+
]
|
6864
8021
|
};
|
6865
8022
|
} else {
|
6866
8023
|
var hasExecutableChild = false;
|
@@ -6902,14 +8059,29 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|
6902
8059
|
return executableIndex === undefined ? defaultMax : executableIndex;
|
6903
8060
|
}
|
6904
8061
|
|
6905
|
-
function segmentChildren(
|
6906
|
-
|
6907
|
-
|
6908
|
-
|
6909
|
-
|
8062
|
+
function segmentChildren(
|
8063
|
+
node,
|
8064
|
+
orderedChildren,
|
8065
|
+
nodeStats,
|
8066
|
+
executableIndex
|
8067
|
+
) {
|
8068
|
+
var currentSegment = {
|
8069
|
+
index: 0,
|
8070
|
+
owner: node,
|
8071
|
+
nodes: [],
|
8072
|
+
min: startingMin(executableIndex),
|
8073
|
+
max: startingMax(executableIndex)
|
8074
|
+
},
|
8075
|
+
result = [currentSegment],
|
8076
|
+
lastMax = defaultMax,
|
8077
|
+
orderedChildSegments = orderChildSegments(orderedChildren);
|
6910
8078
|
|
6911
8079
|
function isSegmentBoundary(minIndex) {
|
6912
|
-
return
|
8080
|
+
return (
|
8081
|
+
lastMax !== defaultMax &&
|
8082
|
+
minIndex !== defaultMin &&
|
8083
|
+
lastMax < minIndex - 1
|
8084
|
+
);
|
6913
8085
|
}
|
6914
8086
|
|
6915
8087
|
for (var i = 0; i < orderedChildSegments.length; i++) {
|
@@ -6918,7 +8090,13 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|
6918
8090
|
minIndex = childSegment.min;
|
6919
8091
|
|
6920
8092
|
if (isSegmentBoundary(minIndex)) {
|
6921
|
-
currentSegment = {
|
8093
|
+
currentSegment = {
|
8094
|
+
index: result.length,
|
8095
|
+
owner: node,
|
8096
|
+
nodes: [],
|
8097
|
+
min: defaultMin,
|
8098
|
+
max: defaultMax
|
8099
|
+
};
|
6922
8100
|
result.push(currentSegment);
|
6923
8101
|
}
|
6924
8102
|
|
@@ -6933,11 +8111,11 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|
6933
8111
|
|
6934
8112
|
function orderChildSegments(children) {
|
6935
8113
|
var specifiedOrder = [],
|
6936
|
-
|
8114
|
+
unspecifiedOrder = [];
|
6937
8115
|
|
6938
8116
|
for (var i = 0; i < children.length; i++) {
|
6939
8117
|
var child = children[i],
|
6940
|
-
|
8118
|
+
segments = stats[child.id].segments;
|
6941
8119
|
|
6942
8120
|
for (var j = 0; j < segments.length; j++) {
|
6943
8121
|
var seg = segments[j];
|
@@ -6968,7 +8146,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|
6968
8146
|
};
|
6969
8147
|
|
6970
8148
|
queueRunnerFactory({
|
6971
|
-
onComplete: function
|
8149
|
+
onComplete: function() {
|
6972
8150
|
var args = Array.prototype.slice.call(arguments, [0]);
|
6973
8151
|
node.cleanupBeforeAfter();
|
6974
8152
|
nodeComplete(node, node.getResult(), function() {
|
@@ -6977,7 +8155,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|
6977
8155
|
},
|
6978
8156
|
queueableFns: [onStart].concat(wrapChildren(node, segmentNumber)),
|
6979
8157
|
userContext: node.sharedUserContext(),
|
6980
|
-
onException: function
|
8158
|
+
onException: function() {
|
6981
8159
|
node.onException.apply(node, arguments);
|
6982
8160
|
}
|
6983
8161
|
});
|
@@ -6985,17 +8163,25 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|
6985
8163
|
};
|
6986
8164
|
} else {
|
6987
8165
|
return {
|
6988
|
-
fn: function(done) {
|
8166
|
+
fn: function(done) {
|
8167
|
+
node.execute(
|
8168
|
+
done,
|
8169
|
+
stats[node.id].excluded,
|
8170
|
+
failSpecWithNoExpectations
|
8171
|
+
);
|
8172
|
+
}
|
6989
8173
|
};
|
6990
8174
|
}
|
6991
8175
|
}
|
6992
8176
|
|
6993
8177
|
function wrapChildren(node, segmentNumber) {
|
6994
8178
|
var result = [],
|
6995
|
-
|
8179
|
+
segmentChildren = stats[node.id].segments[segmentNumber].nodes;
|
6996
8180
|
|
6997
8181
|
for (var i = 0; i < segmentChildren.length; i++) {
|
6998
|
-
result.push(
|
8182
|
+
result.push(
|
8183
|
+
executeNode(segmentChildren[i].owner, segmentChildren[i].index)
|
8184
|
+
);
|
6999
8185
|
}
|
7000
8186
|
|
7001
8187
|
if (!stats[node.id].willExecute) {
|
@@ -7010,8 +8196,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|
7010
8196
|
};
|
7011
8197
|
|
7012
8198
|
getJasmineRequireObj().UserContext = function(j$) {
|
7013
|
-
function UserContext() {
|
7014
|
-
}
|
8199
|
+
function UserContext() {}
|
7015
8200
|
|
7016
8201
|
UserContext.fromExisting = function(oldContext) {
|
7017
8202
|
var context = new UserContext();
|
@@ -7025,9 +8210,9 @@ getJasmineRequireObj().UserContext = function(j$) {
|
|
7025
8210
|
return context;
|
7026
8211
|
};
|
7027
8212
|
|
7028
|
-
return
|
8213
|
+
return UserContext;
|
7029
8214
|
};
|
7030
8215
|
|
7031
8216
|
getJasmineRequireObj().version = function() {
|
7032
|
-
return '3.
|
8217
|
+
return '3.5.0';
|
7033
8218
|
};
|