ember-source 1.11.3 → 1.11.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ember-source might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/dist/ember-template-compiler.js +219 -8863
- data/dist/ember-testing.js +407 -240
- data/dist/ember.debug.js +9900 -8129
- data/dist/ember.js +9900 -8129
- data/dist/ember.min.js +15 -20
- data/dist/ember.prod.js +9155 -7710
- metadata +5 -9
- data/dist/ember-runtime.js +0 -22645
- data/dist/ember-tests.js +0 -70865
- data/dist/ember-tests.prod.js +0 -70599
- data/dist/ember.debug.cjs.js +0 -47641
data/dist/ember-testing.js
CHANGED
@@ -109,20 +109,12 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
109
109
|
|
110
110
|
exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags;
|
111
111
|
|
112
|
-
|
113
|
-
Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or
|
114
|
-
any specific FEATURES flag is truthy.
|
112
|
+
/*global __fail__*/
|
115
113
|
|
116
|
-
|
117
|
-
|
118
|
-
@private
|
119
|
-
@method _warnIfUsingStrippedFeatureFlags
|
120
|
-
@return {void}
|
121
|
-
*/
|
122
|
-
Ember['default'].assert = function (desc, test) {
|
114
|
+
Ember['default'].assert = function(desc, test) {
|
123
115
|
var throwAssertion;
|
124
116
|
|
125
|
-
if (Ember['default'].typeOf(test) ===
|
117
|
+
if (Ember['default'].typeOf(test) === 'function') {
|
126
118
|
throwAssertion = !test();
|
127
119
|
} else {
|
128
120
|
throwAssertion = !test;
|
@@ -133,6 +125,7 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
133
125
|
}
|
134
126
|
};
|
135
127
|
|
128
|
+
|
136
129
|
/**
|
137
130
|
Display a warning with the provided message. Ember build tools will
|
138
131
|
remove any calls to `Ember.warn()` when doing a production build.
|
@@ -142,10 +135,10 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
142
135
|
@param {Boolean} test An optional boolean. If falsy, the warning
|
143
136
|
will be displayed.
|
144
137
|
*/
|
145
|
-
Ember['default'].warn = function
|
138
|
+
Ember['default'].warn = function(message, test) {
|
146
139
|
if (!test) {
|
147
|
-
Logger['default'].warn("WARNING: "
|
148
|
-
if (
|
140
|
+
Logger['default'].warn("WARNING: "+message);
|
141
|
+
if ('trace' in Logger['default']) {
|
149
142
|
Logger['default'].trace();
|
150
143
|
}
|
151
144
|
}
|
@@ -162,8 +155,8 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
162
155
|
@method debug
|
163
156
|
@param {String} message A debug message to display.
|
164
157
|
*/
|
165
|
-
Ember['default'].debug = function
|
166
|
-
Logger['default'].debug("DEBUG: "
|
158
|
+
Ember['default'].debug = function(message) {
|
159
|
+
Logger['default'].debug("DEBUG: "+message);
|
167
160
|
};
|
168
161
|
|
169
162
|
/**
|
@@ -178,59 +171,56 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
178
171
|
@param {Object} options An optional object that can be used to pass
|
179
172
|
in a `url` to the transition guide on the emberjs.com website.
|
180
173
|
*/
|
181
|
-
Ember['default'].deprecate = function
|
174
|
+
Ember['default'].deprecate = function(message, test, options) {
|
182
175
|
var noDeprecation;
|
183
176
|
|
184
|
-
if (typeof test ===
|
177
|
+
if (typeof test === 'function') {
|
185
178
|
noDeprecation = test();
|
186
179
|
} else {
|
187
180
|
noDeprecation = test;
|
188
181
|
}
|
189
182
|
|
190
|
-
if (noDeprecation) {
|
191
|
-
return;
|
192
|
-
}
|
183
|
+
if (noDeprecation) { return; }
|
193
184
|
|
194
|
-
if (Ember['default'].ENV.RAISE_ON_DEPRECATION) {
|
195
|
-
throw new EmberError['default'](message);
|
196
|
-
}
|
185
|
+
if (Ember['default'].ENV.RAISE_ON_DEPRECATION) { throw new EmberError['default'](message); }
|
197
186
|
|
198
187
|
var error;
|
199
188
|
|
200
189
|
// When using new Error, we can't do the arguments check for Chrome. Alternatives are welcome
|
201
|
-
try {
|
202
|
-
__fail__.fail();
|
203
|
-
} catch (e) {
|
204
|
-
error = e;
|
205
|
-
}
|
190
|
+
try { __fail__.fail(); } catch (e) { error = e; }
|
206
191
|
|
207
192
|
if (arguments.length === 3) {
|
208
|
-
Ember['default'].assert(
|
193
|
+
Ember['default'].assert('options argument to Ember.deprecate should be an object', options && typeof options === 'object');
|
209
194
|
if (options.url) {
|
210
|
-
message +=
|
195
|
+
message += ' See ' + options.url + ' for more details.';
|
211
196
|
}
|
212
197
|
}
|
213
198
|
|
214
199
|
if (Ember['default'].LOG_STACKTRACE_ON_DEPRECATION && error.stack) {
|
215
200
|
var stack;
|
216
|
-
var stackStr =
|
201
|
+
var stackStr = '';
|
217
202
|
|
218
|
-
if (error[
|
203
|
+
if (error['arguments']) {
|
219
204
|
// Chrome
|
220
|
-
stack = error.stack.replace(/^\s+at\s+/gm,
|
205
|
+
stack = error.stack.replace(/^\s+at\s+/gm, '').
|
206
|
+
replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').
|
207
|
+
replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n');
|
221
208
|
stack.shift();
|
222
209
|
} else {
|
223
210
|
// Firefox
|
224
|
-
stack = error.stack.replace(/(?:\n@:0)?\s+$/m,
|
211
|
+
stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').
|
212
|
+
replace(/^\(/gm, '{anonymous}(').split('\n');
|
225
213
|
}
|
226
214
|
|
227
215
|
stackStr = "\n " + stack.slice(2).join("\n ");
|
228
216
|
message = message + stackStr;
|
229
217
|
}
|
230
218
|
|
231
|
-
Logger['default'].warn("DEPRECATION: "
|
219
|
+
Logger['default'].warn("DEPRECATION: "+message);
|
232
220
|
};
|
233
221
|
|
222
|
+
|
223
|
+
|
234
224
|
/**
|
235
225
|
Alias an old, deprecated method with its new counterpart.
|
236
226
|
|
@@ -249,13 +239,14 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
249
239
|
@param {Function} func The new function called to replace its deprecated counterpart.
|
250
240
|
@return {Function} a new function that wrapped the original function with a deprecation warning
|
251
241
|
*/
|
252
|
-
Ember['default'].deprecateFunc = function
|
253
|
-
return function
|
242
|
+
Ember['default'].deprecateFunc = function(message, func) {
|
243
|
+
return function() {
|
254
244
|
Ember['default'].deprecate(message);
|
255
245
|
return func.apply(this, arguments);
|
256
246
|
};
|
257
247
|
};
|
258
248
|
|
249
|
+
|
259
250
|
/**
|
260
251
|
Run a function meant for debugging. Ember build tools will remove any calls to
|
261
252
|
`Ember.runInDebug()` when doing a production build.
|
@@ -274,17 +265,28 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
274
265
|
@param {Function} func The function to be executed.
|
275
266
|
@since 1.5.0
|
276
267
|
*/
|
277
|
-
Ember['default'].runInDebug = function
|
268
|
+
Ember['default'].runInDebug = function(func) {
|
278
269
|
func();
|
279
270
|
};
|
271
|
+
|
272
|
+
/**
|
273
|
+
Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or
|
274
|
+
any specific FEATURES flag is truthy.
|
275
|
+
|
276
|
+
This method is called automatically in debug canary builds.
|
277
|
+
|
278
|
+
@private
|
279
|
+
@method _warnIfUsingStrippedFeatureFlags
|
280
|
+
@return {void}
|
281
|
+
*/
|
280
282
|
function _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped) {
|
281
283
|
if (featuresWereStripped) {
|
282
|
-
Ember['default'].warn(
|
283
|
-
Ember['default'].warn(
|
284
|
+
Ember['default'].warn('Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.', !Ember['default'].ENV.ENABLE_ALL_FEATURES);
|
285
|
+
Ember['default'].warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !Ember['default'].ENV.ENABLE_OPTIONAL_FEATURES);
|
284
286
|
|
285
287
|
for (var key in FEATURES) {
|
286
|
-
if (FEATURES.hasOwnProperty(key) && key !==
|
287
|
-
Ember['default'].warn(
|
288
|
+
if (FEATURES.hasOwnProperty(key) && key !== 'isEnabled') {
|
289
|
+
Ember['default'].warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key]);
|
288
290
|
}
|
289
291
|
}
|
290
292
|
}
|
@@ -292,29 +294,29 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
292
294
|
|
293
295
|
if (!Ember['default'].testing) {
|
294
296
|
// Complain if they're using FEATURE flags in builds other than canary
|
295
|
-
Ember['default'].FEATURES[
|
297
|
+
Ember['default'].FEATURES['features-stripped-test'] = true;
|
296
298
|
var featuresWereStripped = true;
|
297
299
|
|
298
300
|
|
299
|
-
delete Ember['default'].FEATURES[
|
301
|
+
delete Ember['default'].FEATURES['features-stripped-test'];
|
300
302
|
_warnIfUsingStrippedFeatureFlags(Ember['default'].ENV.FEATURES, featuresWereStripped);
|
301
303
|
|
302
304
|
// Inform the developer about the Ember Inspector if not installed.
|
303
|
-
var isFirefox = typeof InstallTrigger !==
|
305
|
+
var isFirefox = typeof InstallTrigger !== 'undefined';
|
304
306
|
var isChrome = environment['default'].isChrome;
|
305
307
|
|
306
|
-
if (typeof window !==
|
307
|
-
window.addEventListener("load", function
|
308
|
+
if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) {
|
309
|
+
window.addEventListener("load", function() {
|
308
310
|
if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) {
|
309
311
|
var downloadURL;
|
310
312
|
|
311
313
|
if (isChrome) {
|
312
|
-
downloadURL =
|
314
|
+
downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi';
|
313
315
|
} else if (isFirefox) {
|
314
|
-
downloadURL =
|
316
|
+
downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/';
|
315
317
|
}
|
316
318
|
|
317
|
-
Ember['default'].debug(
|
319
|
+
Ember['default'].debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL);
|
318
320
|
}
|
319
321
|
}, false);
|
320
322
|
}
|
@@ -330,7 +332,7 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
330
332
|
*/
|
331
333
|
var runningNonEmberDebugJS = false;
|
332
334
|
if (runningNonEmberDebugJS) {
|
333
|
-
Ember['default'].warn(
|
335
|
+
Ember['default'].warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.');
|
334
336
|
}
|
335
337
|
|
336
338
|
exports.runningNonEmberDebugJS = runningNonEmberDebugJS;
|
@@ -350,9 +352,7 @@ enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime/system/objec
|
|
350
352
|
|
351
353
|
'use strict';
|
352
354
|
|
353
|
-
function K() {
|
354
|
-
return this;
|
355
|
-
}
|
355
|
+
function K() { return this; }
|
356
356
|
|
357
357
|
/**
|
358
358
|
@module ember
|
@@ -369,16 +369,19 @@ enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime/system/objec
|
|
369
369
|
var Adapter = EmberObject['default'].extend({
|
370
370
|
/**
|
371
371
|
This callback will be called whenever an async operation is about to start.
|
372
|
-
|
372
|
+
|
373
|
+
Override this to call your framework's methods that handle async
|
373
374
|
operations.
|
374
|
-
|
375
|
+
|
376
|
+
@public
|
375
377
|
@method asyncStart
|
376
378
|
*/
|
377
379
|
asyncStart: K,
|
378
380
|
|
379
381
|
/**
|
380
382
|
This callback will be called whenever an async operation has completed.
|
381
|
-
|
383
|
+
|
384
|
+
@public
|
382
385
|
@method asyncEnd
|
383
386
|
*/
|
384
387
|
asyncEnd: K,
|
@@ -387,17 +390,20 @@ enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime/system/objec
|
|
387
390
|
Override this method with your testing framework's false assertion.
|
388
391
|
This function is called whenever an exception occurs causing the testing
|
389
392
|
promise to fail.
|
390
|
-
|
391
|
-
|
393
|
+
|
394
|
+
QUnit example:
|
395
|
+
|
396
|
+
```javascript
|
392
397
|
exception: function(error) {
|
393
398
|
ok(false, error);
|
394
399
|
};
|
395
400
|
```
|
396
|
-
|
401
|
+
|
402
|
+
@public
|
397
403
|
@method exception
|
398
404
|
@param {String} error The exception to be raised.
|
399
405
|
*/
|
400
|
-
exception: function
|
406
|
+
exception: function(error) {
|
401
407
|
throw error;
|
402
408
|
}
|
403
409
|
});
|
@@ -410,13 +416,13 @@ enifed('ember-testing/adapters/qunit', ['exports', 'ember-testing/adapters/adapt
|
|
410
416
|
'use strict';
|
411
417
|
|
412
418
|
exports['default'] = Adapter['default'].extend({
|
413
|
-
asyncStart: function
|
419
|
+
asyncStart: function() {
|
414
420
|
QUnit.stop();
|
415
421
|
},
|
416
|
-
asyncEnd: function
|
422
|
+
asyncEnd: function() {
|
417
423
|
QUnit.start();
|
418
424
|
},
|
419
|
-
exception: function
|
425
|
+
exception: function(error) {
|
420
426
|
ok(false, utils.inspect(error));
|
421
427
|
}
|
422
428
|
});
|
@@ -430,40 +436,40 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
430
436
|
var asyncHelper = Test['default'].registerAsyncHelper;
|
431
437
|
|
432
438
|
function currentRouteName(app) {
|
433
|
-
var appController = app.__container__.lookup(
|
439
|
+
var appController = app.__container__.lookup('controller:application');
|
434
440
|
|
435
|
-
return property_get.get(appController,
|
441
|
+
return property_get.get(appController, 'currentRouteName');
|
436
442
|
}
|
437
443
|
|
438
444
|
function currentPath(app) {
|
439
|
-
var appController = app.__container__.lookup(
|
445
|
+
var appController = app.__container__.lookup('controller:application');
|
440
446
|
|
441
|
-
return property_get.get(appController,
|
447
|
+
return property_get.get(appController, 'currentPath');
|
442
448
|
}
|
443
449
|
|
444
450
|
function currentURL(app) {
|
445
|
-
var router = app.__container__.lookup(
|
451
|
+
var router = app.__container__.lookup('router:main');
|
446
452
|
|
447
|
-
return property_get.get(router,
|
453
|
+
return property_get.get(router, 'location').getURL();
|
448
454
|
}
|
449
455
|
|
450
456
|
function pauseTest() {
|
451
457
|
Test['default'].adapter.asyncStart();
|
452
|
-
return new Ember['default'].RSVP.Promise(function
|
458
|
+
return new Ember['default'].RSVP.Promise(function() { }, 'TestAdapter paused promise');
|
453
459
|
}
|
454
460
|
|
455
461
|
function focus(el) {
|
456
|
-
if (el && el.is(
|
457
|
-
var type = el.prop(
|
458
|
-
if (type !==
|
459
|
-
run['default'](el, function
|
462
|
+
if (el && el.is(':input, [contenteditable=true]')) {
|
463
|
+
var type = el.prop('type');
|
464
|
+
if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') {
|
465
|
+
run['default'](el, function() {
|
460
466
|
// Firefox does not trigger the `focusin` event if the window
|
461
467
|
// does not have focus. If the document doesn't have focus just
|
462
468
|
// use trigger('focusin') instead.
|
463
469
|
if (!document.hasFocus || document.hasFocus()) {
|
464
470
|
this.focus();
|
465
471
|
} else {
|
466
|
-
this.trigger(
|
472
|
+
this.trigger('focusin');
|
467
473
|
}
|
468
474
|
});
|
469
475
|
}
|
@@ -471,15 +477,15 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
471
477
|
}
|
472
478
|
|
473
479
|
function visit(app, url) {
|
474
|
-
var router = app.__container__.lookup(
|
480
|
+
var router = app.__container__.lookup('router:main');
|
475
481
|
router.location.setURL(url);
|
476
482
|
|
477
483
|
if (app._readinessDeferrals > 0) {
|
478
|
-
router[
|
479
|
-
run['default'](app,
|
480
|
-
delete router[
|
484
|
+
router['initialURL'] = url;
|
485
|
+
run['default'](app, 'advanceReadiness');
|
486
|
+
delete router['initialURL'];
|
481
487
|
} else {
|
482
|
-
run['default'](app.__deprecatedInstance__,
|
488
|
+
run['default'](app.__deprecatedInstance__, 'handleURL', url);
|
483
489
|
}
|
484
490
|
|
485
491
|
return app.testHelpers.wait();
|
@@ -487,23 +493,24 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
487
493
|
|
488
494
|
function click(app, selector, context) {
|
489
495
|
var $el = app.testHelpers.findWithAssert(selector, context);
|
490
|
-
run['default']($el,
|
496
|
+
run['default']($el, 'mousedown');
|
491
497
|
|
492
498
|
focus($el);
|
493
499
|
|
494
|
-
run['default']($el,
|
495
|
-
run['default']($el,
|
500
|
+
run['default']($el, 'mouseup');
|
501
|
+
run['default']($el, 'click');
|
496
502
|
|
497
503
|
return app.testHelpers.wait();
|
498
504
|
}
|
499
505
|
|
500
506
|
function check(app, selector, context) {
|
501
507
|
var $el = app.testHelpers.findWithAssert(selector, context);
|
502
|
-
var type = $el.prop(
|
508
|
+
var type = $el.prop('type');
|
503
509
|
|
504
|
-
Ember['default'].assert(
|
510
|
+
Ember['default'].assert('To check \'' + selector +
|
511
|
+
'\', the input must be a checkbox', type === 'checkbox');
|
505
512
|
|
506
|
-
if (!$el.prop(
|
513
|
+
if (!$el.prop('checked')) {
|
507
514
|
app.testHelpers.click(selector, context);
|
508
515
|
}
|
509
516
|
|
@@ -512,11 +519,12 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
512
519
|
|
513
520
|
function uncheck(app, selector, context) {
|
514
521
|
var $el = app.testHelpers.findWithAssert(selector, context);
|
515
|
-
var type = $el.prop(
|
522
|
+
var type = $el.prop('type');
|
516
523
|
|
517
|
-
Ember['default'].assert(
|
524
|
+
Ember['default'].assert('To uncheck \'' + selector +
|
525
|
+
'\', the input must be a checkbox', type === 'checkbox');
|
518
526
|
|
519
|
-
if ($el.prop(
|
527
|
+
if ($el.prop('checked')) {
|
520
528
|
app.testHelpers.click(selector, context);
|
521
529
|
}
|
522
530
|
|
@@ -535,14 +543,12 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
535
543
|
options = {};
|
536
544
|
} else if (arity === 4) {
|
537
545
|
// context and options are optional, so this is
|
538
|
-
if (typeof typeOrOptions === "object") {
|
539
|
-
// either
|
546
|
+
if (typeof typeOrOptions === "object") { // either
|
540
547
|
// app, selector, type, options
|
541
548
|
context = null;
|
542
549
|
type = contextOrType;
|
543
550
|
options = typeOrOptions;
|
544
|
-
} else {
|
545
|
-
// or
|
551
|
+
} else { // or
|
546
552
|
// app, selector, context, type
|
547
553
|
context = contextOrType;
|
548
554
|
type = typeOrOptions;
|
@@ -558,7 +564,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
558
564
|
|
559
565
|
var event = jQuery['default'].Event(type, options);
|
560
566
|
|
561
|
-
run['default']($el,
|
567
|
+
run['default']($el, 'trigger', event);
|
562
568
|
|
563
569
|
return app.testHelpers.wait();
|
564
570
|
}
|
@@ -566,7 +572,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
566
572
|
function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) {
|
567
573
|
var context, type;
|
568
574
|
|
569
|
-
if (typeof keyCode ===
|
575
|
+
if (typeof keyCode === 'undefined') {
|
570
576
|
context = null;
|
571
577
|
keyCode = typeOrKeyCode;
|
572
578
|
type = contextOrType;
|
@@ -580,14 +586,14 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
580
586
|
|
581
587
|
function fillIn(app, selector, contextOrText, text) {
|
582
588
|
var $el, context;
|
583
|
-
if (typeof text ===
|
589
|
+
if (typeof text === 'undefined') {
|
584
590
|
text = contextOrText;
|
585
591
|
} else {
|
586
592
|
context = contextOrText;
|
587
593
|
}
|
588
594
|
$el = app.testHelpers.findWithAssert(selector, context);
|
589
595
|
focus($el);
|
590
|
-
run['default'](function
|
596
|
+
run['default'](function() {
|
591
597
|
$el.val(text).change();
|
592
598
|
});
|
593
599
|
return app.testHelpers.wait();
|
@@ -603,7 +609,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
603
609
|
|
604
610
|
function find(app, selector, context) {
|
605
611
|
var $el;
|
606
|
-
context = context || property_get.get(app,
|
612
|
+
context = context || property_get.get(app, 'rootElement');
|
607
613
|
$el = app.$(selector, context);
|
608
614
|
|
609
615
|
return $el;
|
@@ -614,27 +620,21 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
614
620
|
}
|
615
621
|
|
616
622
|
function wait(app, value) {
|
617
|
-
return new RSVP['default'].Promise(function
|
623
|
+
return new RSVP['default'].Promise(function(resolve) {
|
618
624
|
// Every 10ms, poll for the async thing to have finished
|
619
|
-
var watcher = setInterval(function
|
620
|
-
var router = app.__container__.lookup(
|
625
|
+
var watcher = setInterval(function() {
|
626
|
+
var router = app.__container__.lookup('router:main');
|
621
627
|
|
622
628
|
// 1. If the router is loading, keep polling
|
623
629
|
var routerIsLoading = router.router && !!router.router.activeTransition;
|
624
|
-
if (routerIsLoading) {
|
625
|
-
return;
|
626
|
-
}
|
630
|
+
if (routerIsLoading) { return; }
|
627
631
|
|
628
632
|
// 2. If there are pending Ajax requests, keep polling
|
629
|
-
if (Test['default'].pendingAjaxRequests) {
|
630
|
-
return;
|
631
|
-
}
|
633
|
+
if (Test['default'].pendingAjaxRequests) { return; }
|
632
634
|
|
633
635
|
// 3. If there are scheduled timers or we are inside of a run loop, keep polling
|
634
|
-
if (run['default'].hasScheduledTimers() || run['default'].currentRunLoop) {
|
635
|
-
|
636
|
-
}
|
637
|
-
if (Test['default'].waiters && Test['default'].waiters.any(function (waiter) {
|
636
|
+
if (run['default'].hasScheduledTimers() || run['default'].currentRunLoop) { return; }
|
637
|
+
if (Test['default'].waiters && Test['default'].waiters.any(function(waiter) {
|
638
638
|
var context = waiter[0];
|
639
639
|
var callback = waiter[1];
|
640
640
|
return !callback.call(context);
|
@@ -648,8 +648,10 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
648
648
|
run['default'](null, resolve, value);
|
649
649
|
}, 10);
|
650
650
|
});
|
651
|
+
|
651
652
|
}
|
652
653
|
|
654
|
+
|
653
655
|
/**
|
654
656
|
* Loads a route, sets up any controllers, and renders any templates associated
|
655
657
|
* with the route as though a real user had triggered the route change while
|
@@ -667,7 +669,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
667
669
|
* @param {String} url the name of the route
|
668
670
|
* @return {RSVP.Promise}
|
669
671
|
*/
|
670
|
-
asyncHelper(
|
672
|
+
asyncHelper('visit', visit);
|
671
673
|
|
672
674
|
/**
|
673
675
|
* Clicks an element and triggers any actions triggered by the element's `click`
|
@@ -685,7 +687,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
685
687
|
* @param {String} selector jQuery selector for finding element on the DOM
|
686
688
|
* @return {RSVP.Promise}
|
687
689
|
*/
|
688
|
-
asyncHelper(
|
690
|
+
asyncHelper('click', click);
|
689
691
|
|
690
692
|
/**
|
691
693
|
* Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode
|
@@ -705,7 +707,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
705
707
|
* @return {RSVP.Promise}
|
706
708
|
* @since 1.5.0
|
707
709
|
*/
|
708
|
-
asyncHelper(
|
710
|
+
asyncHelper('keyEvent', keyEvent);
|
709
711
|
|
710
712
|
/**
|
711
713
|
* Fills in an input element with some text.
|
@@ -724,7 +726,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
724
726
|
* @param {String} text text to place inside the input element
|
725
727
|
* @return {RSVP.Promise}
|
726
728
|
*/
|
727
|
-
asyncHelper(
|
729
|
+
asyncHelper('fillIn', fillIn);
|
728
730
|
|
729
731
|
/**
|
730
732
|
* Finds an element in the context of the app's container element. A simple alias
|
@@ -740,7 +742,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
740
742
|
* @param {String} selector jQuery string selector for element lookup
|
741
743
|
* @return {Object} jQuery object representing the results of the query
|
742
744
|
*/
|
743
|
-
helper(
|
745
|
+
helper('find', find);
|
744
746
|
|
745
747
|
/**
|
746
748
|
* Like `find`, but throws an error if the element selector returns no results.
|
@@ -757,7 +759,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
757
759
|
* @return {Object} jQuery object representing the results of the query
|
758
760
|
* @throws {Error} throws error if jQuery object returned has a length of 0
|
759
761
|
*/
|
760
|
-
helper(
|
762
|
+
helper('findWithAssert', findWithAssert);
|
761
763
|
|
762
764
|
/**
|
763
765
|
Causes the run loop to process any pending events. This is used to ensure that
|
@@ -782,8 +784,9 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
782
784
|
@param {Object} value The value to be returned.
|
783
785
|
@return {RSVP.Promise}
|
784
786
|
*/
|
785
|
-
asyncHelper(
|
786
|
-
asyncHelper(
|
787
|
+
asyncHelper('wait', wait);
|
788
|
+
asyncHelper('andThen', andThen);
|
789
|
+
|
787
790
|
|
788
791
|
/**
|
789
792
|
Returns the currently active route name.
|
@@ -802,7 +805,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
802
805
|
@return {Object} The name of the currently active route.
|
803
806
|
@since 1.5.0
|
804
807
|
*/
|
805
|
-
helper(
|
808
|
+
helper('currentRouteName', currentRouteName);
|
806
809
|
|
807
810
|
/**
|
808
811
|
Returns the current path.
|
@@ -821,7 +824,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
821
824
|
@return {Object} The currently active path.
|
822
825
|
@since 1.5.0
|
823
826
|
*/
|
824
|
-
helper(
|
827
|
+
helper('currentPath', currentPath);
|
825
828
|
|
826
829
|
/**
|
827
830
|
Returns the current URL.
|
@@ -840,7 +843,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
840
843
|
@return {Object} The currently active URL.
|
841
844
|
@since 1.5.0
|
842
845
|
*/
|
843
|
-
helper(
|
846
|
+
helper('currentURL', currentURL);
|
844
847
|
|
845
848
|
/**
|
846
849
|
Pauses the current test - this is useful for debugging while testing or for test-driving.
|
@@ -859,7 +862,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
859
862
|
@method pauseTest
|
860
863
|
@return {Object} A promise that will never resolve
|
861
864
|
*/
|
862
|
-
helper(
|
865
|
+
helper('pauseTest', pauseTest);
|
863
866
|
|
864
867
|
/**
|
865
868
|
Triggers the given DOM event on the element identified by the provided selector.
|
@@ -885,21 +888,21 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
885
888
|
@return {RSVP.Promise}
|
886
889
|
@since 1.5.0
|
887
890
|
*/
|
888
|
-
asyncHelper(
|
891
|
+
asyncHelper('triggerEvent', triggerEvent);
|
889
892
|
|
890
893
|
});
|
891
894
|
enifed('ember-testing/initializers', ['ember-runtime/system/lazy_load'], function (lazy_load) {
|
892
895
|
|
893
896
|
'use strict';
|
894
897
|
|
895
|
-
var name =
|
898
|
+
var name = 'deferReadiness in `testing` mode';
|
896
899
|
|
897
|
-
lazy_load.onLoad(
|
900
|
+
lazy_load.onLoad('Ember.Application', function(Application) {
|
898
901
|
if (!Application.initializers[name]) {
|
899
902
|
Application.initializer({
|
900
903
|
name: name,
|
901
904
|
|
902
|
-
initialize: function
|
905
|
+
initialize: function(registry, application) {
|
903
906
|
if (application.testing) {
|
904
907
|
application.deferReadiness();
|
905
908
|
}
|
@@ -913,20 +916,6 @@ enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal/core', 'ember
|
|
913
916
|
|
914
917
|
'use strict';
|
915
918
|
|
916
|
-
|
917
|
-
|
918
|
-
/**
|
919
|
-
Sets Ember up for testing. This is useful to perform
|
920
|
-
basic setup steps in order to unit test.
|
921
|
-
|
922
|
-
Use `App.setupForTesting` to perform integration tests (full
|
923
|
-
application testing).
|
924
|
-
|
925
|
-
@method setupForTesting
|
926
|
-
@namespace Ember
|
927
|
-
@since 1.5.0
|
928
|
-
*/
|
929
|
-
exports['default'] = setupForTesting;
|
930
919
|
var Test, requests;
|
931
920
|
|
932
921
|
function incrementAjaxPendingRequests(_, xhr) {
|
@@ -935,17 +924,27 @@ enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal/core', 'ember
|
|
935
924
|
}
|
936
925
|
|
937
926
|
function decrementAjaxPendingRequests(_, xhr) {
|
938
|
-
for (var i
|
927
|
+
for (var i=0;i<requests.length;i++) {
|
939
928
|
if (xhr === requests[i]) {
|
940
929
|
requests.splice(i, 1);
|
941
930
|
}
|
942
931
|
}
|
943
932
|
Test.pendingAjaxRequests = requests.length;
|
944
933
|
}
|
934
|
+
|
935
|
+
/**
|
936
|
+
Sets Ember up for testing. This is useful to perform
|
937
|
+
basic setup steps in order to unit test.
|
938
|
+
|
939
|
+
Use `App.setupForTesting` to perform integration tests (full
|
940
|
+
application testing).
|
941
|
+
|
942
|
+
@method setupForTesting
|
943
|
+
@namespace Ember
|
944
|
+
@since 1.5.0
|
945
|
+
*/
|
945
946
|
function setupForTesting() {
|
946
|
-
if (!Test) {
|
947
|
-
Test = requireModule("ember-testing/test")["default"];
|
948
|
-
}
|
947
|
+
if (!Test) { Test = requireModule('ember-testing/test')['default']; }
|
949
948
|
|
950
949
|
Ember['default'].testing = true;
|
951
950
|
|
@@ -957,11 +956,12 @@ enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal/core', 'ember
|
|
957
956
|
requests = [];
|
958
957
|
Test.pendingAjaxRequests = requests.length;
|
959
958
|
|
960
|
-
jQuery['default'](document).off(
|
961
|
-
jQuery['default'](document).off(
|
962
|
-
jQuery['default'](document).on(
|
963
|
-
jQuery['default'](document).on(
|
959
|
+
jQuery['default'](document).off('ajaxSend', incrementAjaxPendingRequests);
|
960
|
+
jQuery['default'](document).off('ajaxComplete', decrementAjaxPendingRequests);
|
961
|
+
jQuery['default'](document).on('ajaxSend', incrementAjaxPendingRequests);
|
962
|
+
jQuery['default'](document).on('ajaxComplete', decrementAjaxPendingRequests);
|
964
963
|
}
|
964
|
+
exports['default'] = setupForTesting;
|
965
965
|
|
966
966
|
});
|
967
967
|
enifed('ember-testing/support', ['ember-metal/core', 'ember-views/system/jquery', 'ember-metal/environment'], function (Ember, jQuery, environment) {
|
@@ -979,23 +979,29 @@ enifed('ember-testing/support', ['ember-metal/core', 'ember-views/system/jquery'
|
|
979
979
|
@method testCheckboxClick
|
980
980
|
*/
|
981
981
|
function testCheckboxClick(handler) {
|
982
|
-
$(
|
982
|
+
$('<input type="checkbox">')
|
983
|
+
.css({ position: 'absolute', left: '-1000px', top: '-1000px' })
|
984
|
+
.appendTo('body')
|
985
|
+
.on('click', handler)
|
986
|
+
.trigger('click')
|
987
|
+
.remove();
|
983
988
|
}
|
984
989
|
|
985
990
|
if (environment['default'].hasDOM) {
|
986
|
-
$(function
|
991
|
+
$(function() {
|
987
992
|
/*
|
988
993
|
Determine whether a checkbox checked using jQuery's "click" method will have
|
989
994
|
the correct value for its checked property.
|
990
|
-
|
995
|
+
|
996
|
+
If we determine that the current jQuery version exhibits this behavior,
|
991
997
|
patch it to work correctly as in the commit for the actual fix:
|
992
998
|
https://github.com/jquery/jquery/commit/1fb2f92.
|
993
999
|
*/
|
994
|
-
testCheckboxClick(function
|
1000
|
+
testCheckboxClick(function() {
|
995
1001
|
if (!this.checked && !$.event.special.click) {
|
996
1002
|
$.event.special.click = {
|
997
1003
|
// For checkbox, fire native event so checked state will be right
|
998
|
-
trigger: function
|
1004
|
+
trigger: function() {
|
999
1005
|
if ($.nodeName(this, "input") && this.type === "checkbox" && this.click) {
|
1000
1006
|
this.click();
|
1001
1007
|
return false;
|
@@ -1006,7 +1012,7 @@ enifed('ember-testing/support', ['ember-metal/core', 'ember-views/system/jquery'
|
|
1006
1012
|
});
|
1007
1013
|
|
1008
1014
|
// Try again to verify that the patch took effect or blow up.
|
1009
|
-
testCheckboxClick(function
|
1015
|
+
testCheckboxClick(function() {
|
1010
1016
|
Ember['default'].warn("clicked checkboxes should be checked! the jQuery patch didn't work", this.checked);
|
1011
1017
|
});
|
1012
1018
|
});
|
@@ -1035,7 +1041,8 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1035
1041
|
var Test = {
|
1036
1042
|
/**
|
1037
1043
|
Hash containing all known test helpers.
|
1038
|
-
|
1044
|
+
|
1045
|
+
@property _helpers
|
1039
1046
|
@private
|
1040
1047
|
@since 1.7.0
|
1041
1048
|
*/
|
@@ -1044,28 +1051,34 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1044
1051
|
/**
|
1045
1052
|
`registerHelper` is used to register a test helper that will be injected
|
1046
1053
|
when `App.injectTestHelpers` is called.
|
1047
|
-
|
1054
|
+
|
1055
|
+
The helper method will always be called with the current Application as
|
1048
1056
|
the first parameter.
|
1049
|
-
|
1050
|
-
|
1057
|
+
|
1058
|
+
For example:
|
1059
|
+
|
1060
|
+
```javascript
|
1051
1061
|
Ember.Test.registerHelper('boot', function(app) {
|
1052
1062
|
Ember.run(app, app.advanceReadiness);
|
1053
1063
|
});
|
1054
1064
|
```
|
1055
|
-
|
1065
|
+
|
1066
|
+
This helper can later be called without arguments because it will be
|
1056
1067
|
called with `app` as the first parameter.
|
1057
|
-
|
1068
|
+
|
1069
|
+
```javascript
|
1058
1070
|
App = Ember.Application.create();
|
1059
1071
|
App.injectTestHelpers();
|
1060
1072
|
boot();
|
1061
1073
|
```
|
1062
|
-
|
1074
|
+
|
1075
|
+
@public
|
1063
1076
|
@method registerHelper
|
1064
1077
|
@param {String} name The name of the helper method to add.
|
1065
1078
|
@param {Function} helperMethod
|
1066
1079
|
@param options {Object}
|
1067
1080
|
*/
|
1068
|
-
registerHelper: function
|
1081
|
+
registerHelper: function(name, helperMethod) {
|
1069
1082
|
helpers[name] = {
|
1070
1083
|
method: helperMethod,
|
1071
1084
|
meta: { wait: false }
|
@@ -1075,35 +1088,44 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1075
1088
|
/**
|
1076
1089
|
`registerAsyncHelper` is used to register an async test helper that will be injected
|
1077
1090
|
when `App.injectTestHelpers` is called.
|
1078
|
-
|
1091
|
+
|
1092
|
+
The helper method will always be called with the current Application as
|
1079
1093
|
the first parameter.
|
1080
|
-
|
1081
|
-
|
1094
|
+
|
1095
|
+
For example:
|
1096
|
+
|
1097
|
+
```javascript
|
1082
1098
|
Ember.Test.registerAsyncHelper('boot', function(app) {
|
1083
1099
|
Ember.run(app, app.advanceReadiness);
|
1084
1100
|
});
|
1085
1101
|
```
|
1086
|
-
|
1102
|
+
|
1103
|
+
The advantage of an async helper is that it will not run
|
1087
1104
|
until the last async helper has completed. All async helpers
|
1088
1105
|
after it will wait for it complete before running.
|
1089
|
-
|
1090
|
-
|
1106
|
+
|
1107
|
+
|
1108
|
+
For example:
|
1109
|
+
|
1110
|
+
```javascript
|
1091
1111
|
Ember.Test.registerAsyncHelper('deletePost', function(app, postId) {
|
1092
1112
|
click('.delete-' + postId);
|
1093
1113
|
});
|
1094
|
-
|
1114
|
+
|
1115
|
+
// ... in your test
|
1095
1116
|
visit('/post/2');
|
1096
1117
|
deletePost(2);
|
1097
1118
|
visit('/post/3');
|
1098
1119
|
deletePost(3);
|
1099
1120
|
```
|
1100
|
-
|
1121
|
+
|
1122
|
+
@public
|
1101
1123
|
@method registerAsyncHelper
|
1102
1124
|
@param {String} name The name of the helper method to add.
|
1103
1125
|
@param {Function} helperMethod
|
1104
1126
|
@since 1.2.0
|
1105
1127
|
*/
|
1106
|
-
registerAsyncHelper: function
|
1128
|
+
registerAsyncHelper: function(name, helperMethod) {
|
1107
1129
|
helpers[name] = {
|
1108
1130
|
method: helperMethod,
|
1109
1131
|
meta: { wait: true }
|
@@ -1112,15 +1134,18 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1112
1134
|
|
1113
1135
|
/**
|
1114
1136
|
Remove a previously added helper method.
|
1115
|
-
|
1116
|
-
|
1137
|
+
|
1138
|
+
Example:
|
1139
|
+
|
1140
|
+
```javascript
|
1117
1141
|
Ember.Test.unregisterHelper('wait');
|
1118
1142
|
```
|
1119
|
-
|
1143
|
+
|
1144
|
+
@public
|
1120
1145
|
@method unregisterHelper
|
1121
1146
|
@param {String} name The helper to remove.
|
1122
1147
|
*/
|
1123
|
-
unregisterHelper: function
|
1148
|
+
unregisterHelper: function(name) {
|
1124
1149
|
delete helpers[name];
|
1125
1150
|
delete Test.Promise.prototype[name];
|
1126
1151
|
},
|
@@ -1128,23 +1153,28 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1128
1153
|
/**
|
1129
1154
|
Used to register callbacks to be fired whenever `App.injectTestHelpers`
|
1130
1155
|
is called.
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1156
|
+
|
1157
|
+
The callback will receive the current application as an argument.
|
1158
|
+
|
1159
|
+
Example:
|
1160
|
+
|
1161
|
+
```javascript
|
1134
1162
|
Ember.Test.onInjectHelpers(function() {
|
1135
1163
|
Ember.$(document).ajaxSend(function() {
|
1136
1164
|
Test.pendingAjaxRequests++;
|
1137
1165
|
});
|
1138
|
-
|
1166
|
+
|
1167
|
+
Ember.$(document).ajaxComplete(function() {
|
1139
1168
|
Test.pendingAjaxRequests--;
|
1140
1169
|
});
|
1141
1170
|
});
|
1142
1171
|
```
|
1143
|
-
|
1172
|
+
|
1173
|
+
@public
|
1144
1174
|
@method onInjectHelpers
|
1145
1175
|
@param {Function} callback The function to be called.
|
1146
1176
|
*/
|
1147
|
-
onInjectHelpers: function
|
1177
|
+
onInjectHelpers: function(callback) {
|
1148
1178
|
injectHelpersCallbacks.push(callback);
|
1149
1179
|
},
|
1150
1180
|
|
@@ -1152,25 +1182,32 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1152
1182
|
This returns a thenable tailored for testing. It catches failed
|
1153
1183
|
`onSuccess` callbacks and invokes the `Ember.Test.adapter.exception`
|
1154
1184
|
callback in the last chained then.
|
1155
|
-
|
1156
|
-
|
1185
|
+
|
1186
|
+
This method should be returned by async helpers such as `wait`.
|
1187
|
+
|
1188
|
+
@public
|
1157
1189
|
@method promise
|
1158
1190
|
@param {Function} resolver The function used to resolve the promise.
|
1159
1191
|
*/
|
1160
|
-
promise: function
|
1192
|
+
promise: function(resolver) {
|
1161
1193
|
return new Test.Promise(resolver);
|
1162
1194
|
},
|
1163
1195
|
|
1164
1196
|
/**
|
1165
1197
|
Used to allow ember-testing to communicate with a specific testing
|
1166
1198
|
framework.
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1199
|
+
|
1200
|
+
You can manually set it before calling `App.setupForTesting()`.
|
1201
|
+
|
1202
|
+
Example:
|
1203
|
+
|
1204
|
+
```javascript
|
1170
1205
|
Ember.Test.adapter = MyCustomAdapter.create()
|
1171
1206
|
```
|
1172
|
-
|
1173
|
-
|
1207
|
+
|
1208
|
+
If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`.
|
1209
|
+
|
1210
|
+
@public
|
1174
1211
|
@property adapter
|
1175
1212
|
@type {Class} The adapter to be used.
|
1176
1213
|
@default Ember.Test.QUnitAdapter
|
@@ -1181,13 +1218,14 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1181
1218
|
Replacement for `Ember.RSVP.resolve`
|
1182
1219
|
The only difference is this uses
|
1183
1220
|
an instance of `Ember.Test.Promise`
|
1184
|
-
|
1221
|
+
|
1222
|
+
@public
|
1185
1223
|
@method resolve
|
1186
1224
|
@param {Mixed} The value to resolve
|
1187
1225
|
@since 1.2.0
|
1188
1226
|
*/
|
1189
|
-
resolve: function
|
1190
|
-
return Test.promise(function
|
1227
|
+
resolve: function(val) {
|
1228
|
+
return Test.promise(function(resolve) {
|
1191
1229
|
return resolve(val);
|
1192
1230
|
});
|
1193
1231
|
},
|
@@ -1196,25 +1234,30 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1196
1234
|
This allows ember-testing to play nicely with other asynchronous
|
1197
1235
|
events, such as an application that is waiting for a CSS3
|
1198
1236
|
transition or an IndexDB transaction.
|
1199
|
-
|
1200
|
-
|
1237
|
+
|
1238
|
+
For example:
|
1239
|
+
|
1240
|
+
```javascript
|
1201
1241
|
Ember.Test.registerWaiter(function() {
|
1202
1242
|
return myPendingTransactions() == 0;
|
1203
1243
|
});
|
1204
1244
|
```
|
1205
1245
|
The `context` argument allows you to optionally specify the `this`
|
1206
1246
|
with which your callback will be invoked.
|
1207
|
-
|
1208
|
-
|
1247
|
+
|
1248
|
+
For example:
|
1249
|
+
|
1250
|
+
```javascript
|
1209
1251
|
Ember.Test.registerWaiter(MyDB, MyDB.hasPendingTransactions);
|
1210
1252
|
```
|
1211
|
-
|
1253
|
+
|
1254
|
+
@public
|
1212
1255
|
@method registerWaiter
|
1213
1256
|
@param {Object} context (optional)
|
1214
1257
|
@param {Function} callback
|
1215
1258
|
@since 1.2.0
|
1216
1259
|
*/
|
1217
|
-
registerWaiter: function
|
1260
|
+
registerWaiter: function(context, callback) {
|
1218
1261
|
if (arguments.length === 1) {
|
1219
1262
|
callback = context;
|
1220
1263
|
context = null;
|
@@ -1227,21 +1270,20 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1227
1270
|
/**
|
1228
1271
|
`unregisterWaiter` is used to unregister a callback that was
|
1229
1272
|
registered with `registerWaiter`.
|
1230
|
-
|
1273
|
+
|
1274
|
+
@public
|
1231
1275
|
@method unregisterWaiter
|
1232
1276
|
@param {Object} context (optional)
|
1233
1277
|
@param {Function} callback
|
1234
1278
|
@since 1.2.0
|
1235
1279
|
*/
|
1236
|
-
unregisterWaiter: function
|
1237
|
-
if (!this.waiters) {
|
1238
|
-
return;
|
1239
|
-
}
|
1280
|
+
unregisterWaiter: function(context, callback) {
|
1281
|
+
if (!this.waiters) { return; }
|
1240
1282
|
if (arguments.length === 1) {
|
1241
1283
|
callback = context;
|
1242
1284
|
context = null;
|
1243
1285
|
}
|
1244
|
-
this.waiters = Ember['default'].A(this.waiters.filter(function
|
1286
|
+
this.waiters = Ember['default'].A(this.waiters.filter(function(elt) {
|
1245
1287
|
return !(elt[0] === context && elt[1] === callback);
|
1246
1288
|
}));
|
1247
1289
|
}
|
@@ -1251,7 +1293,7 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1251
1293
|
var fn = helpers[name].method;
|
1252
1294
|
var meta = helpers[name].meta;
|
1253
1295
|
|
1254
|
-
return function
|
1296
|
+
return function() {
|
1255
1297
|
var args = slice.call(arguments);
|
1256
1298
|
var lastPromise;
|
1257
1299
|
|
@@ -1264,7 +1306,7 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1264
1306
|
return fn.apply(app, args);
|
1265
1307
|
}
|
1266
1308
|
|
1267
|
-
lastPromise = run(function
|
1309
|
+
lastPromise = run(function() {
|
1268
1310
|
return Test.resolve(Test.lastPromise);
|
1269
1311
|
});
|
1270
1312
|
|
@@ -1273,9 +1315,9 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1273
1315
|
// asynchronous here, because fn may not be invoked before we
|
1274
1316
|
// return.
|
1275
1317
|
Test.adapter.asyncStart();
|
1276
|
-
return lastPromise.then(function
|
1318
|
+
return lastPromise.then(function() {
|
1277
1319
|
return fn.apply(app, args);
|
1278
|
-
})["finally"](function
|
1320
|
+
})["finally"](function() {
|
1279
1321
|
Test.adapter.asyncEnd();
|
1280
1322
|
});
|
1281
1323
|
};
|
@@ -1295,7 +1337,8 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1295
1337
|
are created once you call `injectTestHelpers` on your `Ember.Application`
|
1296
1338
|
instance. The included helpers are also available on the `window` object by
|
1297
1339
|
default, but can be used from this object on the individual application also.
|
1298
|
-
|
1340
|
+
|
1341
|
+
@property testHelpers
|
1299
1342
|
@type {Object}
|
1300
1343
|
@default {}
|
1301
1344
|
*/
|
@@ -1304,9 +1347,11 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1304
1347
|
/**
|
1305
1348
|
This property will contain the original methods that were registered
|
1306
1349
|
on the `helperContainer` before `injectTestHelpers` is called.
|
1307
|
-
|
1350
|
+
|
1351
|
+
When `removeTestHelpers` is called, these methods are restored to the
|
1308
1352
|
`helperContainer`.
|
1309
|
-
|
1353
|
+
|
1354
|
+
@property originalMethods
|
1310
1355
|
@type {Object}
|
1311
1356
|
@default {}
|
1312
1357
|
@private
|
@@ -1314,11 +1359,13 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1314
1359
|
*/
|
1315
1360
|
originalMethods: {},
|
1316
1361
|
|
1362
|
+
|
1317
1363
|
/**
|
1318
1364
|
This property indicates whether or not this application is currently in
|
1319
1365
|
testing mode. This is set when `setupForTesting` is called on the current
|
1320
1366
|
application.
|
1321
|
-
|
1367
|
+
|
1368
|
+
@property testing
|
1322
1369
|
@type {Boolean}
|
1323
1370
|
@default false
|
1324
1371
|
@since 1.3.0
|
@@ -1331,26 +1378,30 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1331
1378
|
location to 'none', so that the window's location will not be modified
|
1332
1379
|
(preventing both accidental leaking of state between tests and interference
|
1333
1380
|
with your testing framework).
|
1334
|
-
|
1335
|
-
|
1381
|
+
|
1382
|
+
Example:
|
1383
|
+
|
1384
|
+
```
|
1336
1385
|
App.setupForTesting();
|
1337
1386
|
```
|
1338
|
-
|
1387
|
+
|
1388
|
+
@method setupForTesting
|
1339
1389
|
*/
|
1340
|
-
setupForTesting: function
|
1390
|
+
setupForTesting: function() {
|
1341
1391
|
setupForTesting['default']();
|
1342
1392
|
|
1343
1393
|
this.testing = true;
|
1344
1394
|
|
1345
1395
|
this.Router.reopen({
|
1346
|
-
location:
|
1396
|
+
location: 'none'
|
1347
1397
|
});
|
1348
1398
|
},
|
1349
1399
|
|
1350
1400
|
/**
|
1351
1401
|
This will be used as the container to inject the test helpers into. By
|
1352
1402
|
default the helpers are injected into `window`.
|
1353
|
-
|
1403
|
+
|
1404
|
+
@property helperContainer
|
1354
1405
|
@type {Object} The object to be used for test helpers.
|
1355
1406
|
@default window
|
1356
1407
|
@since 1.2.0
|
@@ -1363,15 +1414,18 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1363
1414
|
to `window`. If a function of the same name has already been defined it will be cached
|
1364
1415
|
(so that it can be reset if the helper is removed with `unregisterHelper` or
|
1365
1416
|
`removeTestHelpers`).
|
1366
|
-
|
1417
|
+
|
1418
|
+
Any callbacks registered with `onInjectHelpers` will be called once the
|
1367
1419
|
helpers have been injected.
|
1368
|
-
|
1420
|
+
|
1421
|
+
Example:
|
1369
1422
|
```
|
1370
1423
|
App.injectTestHelpers();
|
1371
1424
|
```
|
1372
|
-
|
1425
|
+
|
1426
|
+
@method injectTestHelpers
|
1373
1427
|
*/
|
1374
|
-
injectTestHelpers: function
|
1428
|
+
injectTestHelpers: function(helperContainer) {
|
1375
1429
|
if (helperContainer) {
|
1376
1430
|
this.helperContainer = helperContainer;
|
1377
1431
|
} else {
|
@@ -1393,17 +1447,18 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1393
1447
|
/**
|
1394
1448
|
This removes all helpers that have been registered, and resets and functions
|
1395
1449
|
that were overridden by the helpers.
|
1396
|
-
|
1397
|
-
|
1450
|
+
|
1451
|
+
Example:
|
1452
|
+
|
1453
|
+
```javascript
|
1398
1454
|
App.removeTestHelpers();
|
1399
1455
|
```
|
1400
|
-
|
1456
|
+
|
1457
|
+
@public
|
1401
1458
|
@method removeTestHelpers
|
1402
1459
|
*/
|
1403
|
-
removeTestHelpers: function
|
1404
|
-
if (!this.helperContainer) {
|
1405
|
-
return;
|
1406
|
-
}
|
1460
|
+
removeTestHelpers: function() {
|
1461
|
+
if (!this.helperContainer) { return; }
|
1407
1462
|
|
1408
1463
|
for (var name in helpers) {
|
1409
1464
|
this.helperContainer[name] = this.originalMethods[name];
|
@@ -1417,19 +1472,19 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1417
1472
|
// But still here for backwards compatibility
|
1418
1473
|
// of helper chaining
|
1419
1474
|
function protoWrap(proto, name, callback, isAsync) {
|
1420
|
-
proto[name] = function
|
1475
|
+
proto[name] = function() {
|
1421
1476
|
var args = arguments;
|
1422
1477
|
if (isAsync) {
|
1423
1478
|
return callback.apply(this, args);
|
1424
1479
|
} else {
|
1425
|
-
return this.then(function
|
1480
|
+
return this.then(function() {
|
1426
1481
|
return callback.apply(this, args);
|
1427
1482
|
});
|
1428
1483
|
}
|
1429
1484
|
};
|
1430
1485
|
}
|
1431
1486
|
|
1432
|
-
Test.Promise = function
|
1487
|
+
Test.Promise = function() {
|
1433
1488
|
RSVP['default'].Promise.apply(this, arguments);
|
1434
1489
|
Test.lastPromise = this;
|
1435
1490
|
};
|
@@ -1441,8 +1496,8 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1441
1496
|
// Patch `then` to isolate async methods
|
1442
1497
|
// specifically `Ember.Test.lastPromise`
|
1443
1498
|
var originalThen = RSVP['default'].Promise.prototype.then;
|
1444
|
-
Test.Promise.prototype.then = function
|
1445
|
-
return originalThen.call(this, function
|
1499
|
+
Test.Promise.prototype.then = function(onSuccess, onFailure) {
|
1500
|
+
return originalThen.call(this, function(val) {
|
1446
1501
|
return isolate(onSuccess, val);
|
1447
1502
|
}, onFailure);
|
1448
1503
|
};
|
@@ -1467,11 +1522,11 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1467
1522
|
// If the method returned a promise
|
1468
1523
|
// return that promise. If not,
|
1469
1524
|
// return the last async helper's promise
|
1470
|
-
if (value && value instanceof Test.Promise || !lastPromise) {
|
1525
|
+
if ((value && (value instanceof Test.Promise)) || !lastPromise) {
|
1471
1526
|
return value;
|
1472
1527
|
} else {
|
1473
|
-
return run(function
|
1474
|
-
return Test.resolve(lastPromise).then(function
|
1528
|
+
return run(function() {
|
1529
|
+
return Test.resolve(lastPromise).then(function() {
|
1475
1530
|
return value;
|
1476
1531
|
});
|
1477
1532
|
});
|
@@ -1481,6 +1536,118 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1481
1536
|
exports['default'] = Test;
|
1482
1537
|
|
1483
1538
|
});
|
1539
|
+
enifed("htmlbars-test-helpers",
|
1540
|
+
["exports"],
|
1541
|
+
function(__exports__) {
|
1542
|
+
"use strict";
|
1543
|
+
function equalInnerHTML(fragment, html) {
|
1544
|
+
var actualHTML = normalizeInnerHTML(fragment.innerHTML);
|
1545
|
+
QUnit.push(actualHTML === html, actualHTML, html);
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
__exports__.equalInnerHTML = equalInnerHTML;function equalHTML(node, html) {
|
1549
|
+
var fragment;
|
1550
|
+
if (!node.nodeType && node.length) {
|
1551
|
+
fragment = document.createDocumentFragment();
|
1552
|
+
while (node[0]) {
|
1553
|
+
fragment.appendChild(node[0]);
|
1554
|
+
}
|
1555
|
+
} else {
|
1556
|
+
fragment = node;
|
1557
|
+
}
|
1558
|
+
|
1559
|
+
var div = document.createElement("div");
|
1560
|
+
div.appendChild(fragment.cloneNode(true));
|
1561
|
+
|
1562
|
+
equalInnerHTML(div, html);
|
1563
|
+
}
|
1564
|
+
|
1565
|
+
__exports__.equalHTML = equalHTML;// detect weird IE8 html strings
|
1566
|
+
var ie8InnerHTMLTestElement = document.createElement('div');
|
1567
|
+
ie8InnerHTMLTestElement.setAttribute('id', 'womp');
|
1568
|
+
var ie8InnerHTML = (ie8InnerHTMLTestElement.outerHTML.indexOf('id=womp') > -1);
|
1569
|
+
|
1570
|
+
// detect side-effects of cloning svg elements in IE9-11
|
1571
|
+
var ieSVGInnerHTML = (function () {
|
1572
|
+
if (!document.createElementNS) {
|
1573
|
+
return false;
|
1574
|
+
}
|
1575
|
+
var div = document.createElement('div');
|
1576
|
+
var node = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
1577
|
+
div.appendChild(node);
|
1578
|
+
var clone = div.cloneNode(true);
|
1579
|
+
return clone.innerHTML === '<svg xmlns="http://www.w3.org/2000/svg" />';
|
1580
|
+
})();
|
1581
|
+
|
1582
|
+
function normalizeInnerHTML(actualHTML) {
|
1583
|
+
if (ie8InnerHTML) {
|
1584
|
+
// drop newlines in IE8
|
1585
|
+
actualHTML = actualHTML.replace(/\r\n/gm, '');
|
1586
|
+
// downcase ALLCAPS tags in IE8
|
1587
|
+
actualHTML = actualHTML.replace(/<\/?[A-Z\-]+/gi, function(tag){
|
1588
|
+
return tag.toLowerCase();
|
1589
|
+
});
|
1590
|
+
// quote ids in IE8
|
1591
|
+
actualHTML = actualHTML.replace(/id=([^ >]+)/gi, function(match, id){
|
1592
|
+
return 'id="'+id+'"';
|
1593
|
+
});
|
1594
|
+
// IE8 adds ':' to some tags
|
1595
|
+
// <keygen> becomes <:keygen>
|
1596
|
+
actualHTML = actualHTML.replace(/<(\/?):([^ >]+)/gi, function(match, slash, tag){
|
1597
|
+
return '<'+slash+tag;
|
1598
|
+
});
|
1599
|
+
|
1600
|
+
// Normalize the style attribute
|
1601
|
+
actualHTML = actualHTML.replace(/style="(.+?)"/gi, function(match, val){
|
1602
|
+
return 'style="'+val.toLowerCase()+';"';
|
1603
|
+
});
|
1604
|
+
|
1605
|
+
}
|
1606
|
+
if (ieSVGInnerHTML) {
|
1607
|
+
// Replace `<svg xmlns="http://www.w3.org/2000/svg" height="50%" />` with `<svg height="50%"></svg>`, etc.
|
1608
|
+
// drop namespace attribute
|
1609
|
+
actualHTML = actualHTML.replace(/ xmlns="[^"]+"/, '');
|
1610
|
+
// replace self-closing elements
|
1611
|
+
actualHTML = actualHTML.replace(/<([^ >]+) [^\/>]*\/>/gi, function(tag, tagName) {
|
1612
|
+
return tag.slice(0, tag.length - 3) + '></' + tagName + '>';
|
1613
|
+
});
|
1614
|
+
}
|
1615
|
+
|
1616
|
+
return actualHTML;
|
1617
|
+
}
|
1618
|
+
|
1619
|
+
__exports__.normalizeInnerHTML = normalizeInnerHTML;// detect weird IE8 checked element string
|
1620
|
+
var checkedInput = document.createElement('input');
|
1621
|
+
checkedInput.setAttribute('checked', 'checked');
|
1622
|
+
var checkedInputString = checkedInput.outerHTML;
|
1623
|
+
function isCheckedInputHTML(element) {
|
1624
|
+
equal(element.outerHTML, checkedInputString);
|
1625
|
+
}
|
1626
|
+
|
1627
|
+
__exports__.isCheckedInputHTML = isCheckedInputHTML;// check which property has the node's text content
|
1628
|
+
var textProperty = document.createElement('div').textContent === undefined ? 'innerText' : 'textContent';
|
1629
|
+
function getTextContent(el) {
|
1630
|
+
// textNode
|
1631
|
+
if (el.nodeType === 3) {
|
1632
|
+
return el.nodeValue;
|
1633
|
+
} else {
|
1634
|
+
return el[textProperty];
|
1635
|
+
}
|
1636
|
+
}
|
1637
|
+
|
1638
|
+
__exports__.getTextContent = getTextContent;// IE8 does not have Object.create, so use a polyfill if needed.
|
1639
|
+
// Polyfill based on Mozilla's (MDN)
|
1640
|
+
function createObject(obj) {
|
1641
|
+
if (typeof Object.create === 'function') {
|
1642
|
+
return Object.create(obj);
|
1643
|
+
} else {
|
1644
|
+
var Temp = function() {};
|
1645
|
+
Temp.prototype = obj;
|
1646
|
+
return new Temp();
|
1647
|
+
}
|
1648
|
+
}
|
1649
|
+
__exports__.createObject = createObject;
|
1650
|
+
});
|
1484
1651
|
requireModule("ember-testing");
|
1485
1652
|
|
1486
1653
|
})();
|