ember-source 1.11.4 → 1.12.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
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-runtime.js +22659 -0
- data/dist/ember-template-compiler.js +8981 -241
- data/dist/ember-testing.js +268 -423
- data/dist/ember-tests.js +71583 -0
- data/dist/ember-tests.prod.js +71317 -0
- data/dist/ember.debug.cjs.js +47695 -0
- data/dist/ember.debug.js +10004 -11721
- data/dist/ember.js +10004 -11721
- data/dist/ember.min.js +16 -13
- data/dist/ember.prod.js +9915 -11317
- metadata +8 -4
data/dist/ember-testing.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
|
6
6
|
* @license Licensed under MIT license
|
7
7
|
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
|
8
|
-
* @version 1.
|
8
|
+
* @version 1.12.0-beta.1
|
9
9
|
*/
|
10
10
|
|
11
11
|
(function() {
|
@@ -16,7 +16,6 @@ var mainContext = this;
|
|
16
16
|
|
17
17
|
Ember = this.Ember = this.Ember || {};
|
18
18
|
if (typeof Ember === 'undefined') { Ember = {}; };
|
19
|
-
function UNDEFINED() { }
|
20
19
|
|
21
20
|
if (typeof Ember.__loader === 'undefined') {
|
22
21
|
var registry = {};
|
@@ -37,35 +36,43 @@ var mainContext = this;
|
|
37
36
|
};
|
38
37
|
|
39
38
|
requirejs = eriuqer = requireModule = function(name) {
|
40
|
-
|
39
|
+
return internalRequire(name, null);
|
40
|
+
}
|
41
|
+
|
42
|
+
function internalRequire(name, referrerName) {
|
43
|
+
var exports = seen[name];
|
41
44
|
|
42
|
-
if (
|
43
|
-
|
45
|
+
if (exports !== undefined) {
|
46
|
+
return exports;
|
47
|
+
}
|
44
48
|
|
45
|
-
seen[name] = {};
|
49
|
+
exports = seen[name] = {};
|
46
50
|
|
47
51
|
if (!registry[name]) {
|
48
|
-
|
52
|
+
if (referrerName) {
|
53
|
+
throw new Error('Could not find module ' + name + ' required by: ' + referrerName);
|
54
|
+
} else {
|
55
|
+
throw new Error('Could not find module ' + name);
|
56
|
+
}
|
49
57
|
}
|
50
58
|
|
51
59
|
var mod = registry[name];
|
52
60
|
var deps = mod.deps;
|
53
61
|
var callback = mod.callback;
|
54
62
|
var reified = [];
|
55
|
-
var exports;
|
56
63
|
var length = deps.length;
|
57
64
|
|
58
65
|
for (var i=0; i<length; i++) {
|
59
66
|
if (deps[i] === 'exports') {
|
60
|
-
reified.push(exports
|
67
|
+
reified.push(exports);
|
61
68
|
} else {
|
62
|
-
reified.push(
|
69
|
+
reified.push(internalRequire(resolve(deps[i], name), name));
|
63
70
|
}
|
64
71
|
}
|
65
72
|
|
66
|
-
|
73
|
+
callback.apply(this, reified);
|
67
74
|
|
68
|
-
return
|
75
|
+
return exports;
|
69
76
|
};
|
70
77
|
|
71
78
|
function resolve(child, name) {
|
@@ -109,12 +116,20 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
109
116
|
|
110
117
|
exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags;
|
111
118
|
|
112
|
-
|
119
|
+
/**
|
120
|
+
Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or
|
121
|
+
any specific FEATURES flag is truthy.
|
113
122
|
|
114
|
-
|
123
|
+
This method is called automatically in debug canary builds.
|
124
|
+
|
125
|
+
@private
|
126
|
+
@method _warnIfUsingStrippedFeatureFlags
|
127
|
+
@return {void}
|
128
|
+
*/
|
129
|
+
Ember['default'].assert = function (desc, test) {
|
115
130
|
var throwAssertion;
|
116
131
|
|
117
|
-
if (Ember['default'].typeOf(test) ===
|
132
|
+
if (Ember['default'].typeOf(test) === "function") {
|
118
133
|
throwAssertion = !test();
|
119
134
|
} else {
|
120
135
|
throwAssertion = !test;
|
@@ -125,7 +140,6 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
125
140
|
}
|
126
141
|
};
|
127
142
|
|
128
|
-
|
129
143
|
/**
|
130
144
|
Display a warning with the provided message. Ember build tools will
|
131
145
|
remove any calls to `Ember.warn()` when doing a production build.
|
@@ -135,10 +149,10 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
135
149
|
@param {Boolean} test An optional boolean. If falsy, the warning
|
136
150
|
will be displayed.
|
137
151
|
*/
|
138
|
-
Ember['default'].warn = function(message, test) {
|
152
|
+
Ember['default'].warn = function (message, test) {
|
139
153
|
if (!test) {
|
140
|
-
Logger['default'].warn("WARNING: "+message);
|
141
|
-
if (
|
154
|
+
Logger['default'].warn("WARNING: " + message);
|
155
|
+
if ("trace" in Logger['default']) {
|
142
156
|
Logger['default'].trace();
|
143
157
|
}
|
144
158
|
}
|
@@ -155,8 +169,8 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
155
169
|
@method debug
|
156
170
|
@param {String} message A debug message to display.
|
157
171
|
*/
|
158
|
-
Ember['default'].debug = function(message) {
|
159
|
-
Logger['default'].debug("DEBUG: "+message);
|
172
|
+
Ember['default'].debug = function (message) {
|
173
|
+
Logger['default'].debug("DEBUG: " + message);
|
160
174
|
};
|
161
175
|
|
162
176
|
/**
|
@@ -171,56 +185,59 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
171
185
|
@param {Object} options An optional object that can be used to pass
|
172
186
|
in a `url` to the transition guide on the emberjs.com website.
|
173
187
|
*/
|
174
|
-
Ember['default'].deprecate = function(message, test, options) {
|
188
|
+
Ember['default'].deprecate = function (message, test, options) {
|
175
189
|
var noDeprecation;
|
176
190
|
|
177
|
-
if (typeof test ===
|
191
|
+
if (typeof test === "function") {
|
178
192
|
noDeprecation = test();
|
179
193
|
} else {
|
180
194
|
noDeprecation = test;
|
181
195
|
}
|
182
196
|
|
183
|
-
if (noDeprecation) {
|
197
|
+
if (noDeprecation) {
|
198
|
+
return;
|
199
|
+
}
|
184
200
|
|
185
|
-
if (Ember['default'].ENV.RAISE_ON_DEPRECATION) {
|
201
|
+
if (Ember['default'].ENV.RAISE_ON_DEPRECATION) {
|
202
|
+
throw new EmberError['default'](message);
|
203
|
+
}
|
186
204
|
|
187
205
|
var error;
|
188
206
|
|
189
207
|
// When using new Error, we can't do the arguments check for Chrome. Alternatives are welcome
|
190
|
-
try {
|
208
|
+
try {
|
209
|
+
__fail__.fail();
|
210
|
+
} catch (e) {
|
211
|
+
error = e;
|
212
|
+
}
|
191
213
|
|
192
214
|
if (arguments.length === 3) {
|
193
|
-
Ember['default'].assert(
|
215
|
+
Ember['default'].assert("options argument to Ember.deprecate should be an object", options && typeof options === "object");
|
194
216
|
if (options.url) {
|
195
|
-
message +=
|
217
|
+
message += " See " + options.url + " for more details.";
|
196
218
|
}
|
197
219
|
}
|
198
220
|
|
199
221
|
if (Ember['default'].LOG_STACKTRACE_ON_DEPRECATION && error.stack) {
|
200
222
|
var stack;
|
201
|
-
var stackStr =
|
223
|
+
var stackStr = "";
|
202
224
|
|
203
|
-
if (error[
|
225
|
+
if (error["arguments"]) {
|
204
226
|
// Chrome
|
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');
|
227
|
+
stack = error.stack.replace(/^\s+at\s+/gm, "").replace(/^([^\(]+?)([\n$])/gm, "{anonymous}($1)$2").replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, "{anonymous}($1)").split("\n");
|
208
228
|
stack.shift();
|
209
229
|
} else {
|
210
230
|
// Firefox
|
211
|
-
stack = error.stack.replace(/(?:\n@:0)?\s+$/m,
|
212
|
-
replace(/^\(/gm, '{anonymous}(').split('\n');
|
231
|
+
stack = error.stack.replace(/(?:\n@:0)?\s+$/m, "").replace(/^\(/gm, "{anonymous}(").split("\n");
|
213
232
|
}
|
214
233
|
|
215
234
|
stackStr = "\n " + stack.slice(2).join("\n ");
|
216
235
|
message = message + stackStr;
|
217
236
|
}
|
218
237
|
|
219
|
-
Logger['default'].warn("DEPRECATION: "+message);
|
238
|
+
Logger['default'].warn("DEPRECATION: " + message);
|
220
239
|
};
|
221
240
|
|
222
|
-
|
223
|
-
|
224
241
|
/**
|
225
242
|
Alias an old, deprecated method with its new counterpart.
|
226
243
|
|
@@ -239,14 +256,13 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
239
256
|
@param {Function} func The new function called to replace its deprecated counterpart.
|
240
257
|
@return {Function} a new function that wrapped the original function with a deprecation warning
|
241
258
|
*/
|
242
|
-
Ember['default'].deprecateFunc = function(message, func) {
|
243
|
-
return function() {
|
259
|
+
Ember['default'].deprecateFunc = function (message, func) {
|
260
|
+
return function () {
|
244
261
|
Ember['default'].deprecate(message);
|
245
262
|
return func.apply(this, arguments);
|
246
263
|
};
|
247
264
|
};
|
248
265
|
|
249
|
-
|
250
266
|
/**
|
251
267
|
Run a function meant for debugging. Ember build tools will remove any calls to
|
252
268
|
`Ember.runInDebug()` when doing a production build.
|
@@ -265,28 +281,17 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
265
281
|
@param {Function} func The function to be executed.
|
266
282
|
@since 1.5.0
|
267
283
|
*/
|
268
|
-
Ember['default'].runInDebug = function(func) {
|
284
|
+
Ember['default'].runInDebug = function (func) {
|
269
285
|
func();
|
270
286
|
};
|
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
|
-
*/
|
282
287
|
function _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped) {
|
283
288
|
if (featuresWereStripped) {
|
284
|
-
Ember['default'].warn(
|
285
|
-
Ember['default'].warn(
|
289
|
+
Ember['default'].warn("Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.", !Ember['default'].ENV.ENABLE_ALL_FEATURES);
|
290
|
+
Ember['default'].warn("Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.", !Ember['default'].ENV.ENABLE_OPTIONAL_FEATURES);
|
286
291
|
|
287
292
|
for (var key in FEATURES) {
|
288
|
-
if (FEATURES.hasOwnProperty(key) && key !==
|
289
|
-
Ember['default'].warn(
|
293
|
+
if (FEATURES.hasOwnProperty(key) && key !== "isEnabled") {
|
294
|
+
Ember['default'].warn("FEATURE[\"" + key + "\"] is set as enabled, but FEATURE flags are only available in canary builds.", !FEATURES[key]);
|
290
295
|
}
|
291
296
|
}
|
292
297
|
}
|
@@ -294,29 +299,29 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
294
299
|
|
295
300
|
if (!Ember['default'].testing) {
|
296
301
|
// Complain if they're using FEATURE flags in builds other than canary
|
297
|
-
Ember['default'].FEATURES[
|
302
|
+
Ember['default'].FEATURES["features-stripped-test"] = true;
|
298
303
|
var featuresWereStripped = true;
|
299
304
|
|
300
305
|
|
301
|
-
delete Ember['default'].FEATURES[
|
306
|
+
delete Ember['default'].FEATURES["features-stripped-test"];
|
302
307
|
_warnIfUsingStrippedFeatureFlags(Ember['default'].ENV.FEATURES, featuresWereStripped);
|
303
308
|
|
304
309
|
// Inform the developer about the Ember Inspector if not installed.
|
305
|
-
var isFirefox = typeof InstallTrigger !==
|
310
|
+
var isFirefox = typeof InstallTrigger !== "undefined";
|
306
311
|
var isChrome = environment['default'].isChrome;
|
307
312
|
|
308
|
-
if (typeof window !==
|
309
|
-
window.addEventListener("load", function() {
|
313
|
+
if (typeof window !== "undefined" && (isFirefox || isChrome) && window.addEventListener) {
|
314
|
+
window.addEventListener("load", function () {
|
310
315
|
if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) {
|
311
316
|
var downloadURL;
|
312
317
|
|
313
318
|
if (isChrome) {
|
314
|
-
downloadURL =
|
319
|
+
downloadURL = "https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi";
|
315
320
|
} else if (isFirefox) {
|
316
|
-
downloadURL =
|
321
|
+
downloadURL = "https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/";
|
317
322
|
}
|
318
323
|
|
319
|
-
Ember['default'].debug(
|
324
|
+
Ember['default'].debug("For more advanced debugging, install the Ember Inspector from " + downloadURL);
|
320
325
|
}
|
321
326
|
}, false);
|
322
327
|
}
|
@@ -332,7 +337,7 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/error', 'embe
|
|
332
337
|
*/
|
333
338
|
var runningNonEmberDebugJS = false;
|
334
339
|
if (runningNonEmberDebugJS) {
|
335
|
-
Ember['default'].warn(
|
340
|
+
Ember['default'].warn("Please use `ember.debug.js` instead of `ember.js` for development and debugging.");
|
336
341
|
}
|
337
342
|
|
338
343
|
exports.runningNonEmberDebugJS = runningNonEmberDebugJS;
|
@@ -352,7 +357,9 @@ enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime/system/objec
|
|
352
357
|
|
353
358
|
'use strict';
|
354
359
|
|
355
|
-
function K() {
|
360
|
+
function K() {
|
361
|
+
return this;
|
362
|
+
}
|
356
363
|
|
357
364
|
/**
|
358
365
|
@module ember
|
@@ -369,19 +376,16 @@ enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime/system/objec
|
|
369
376
|
var Adapter = EmberObject['default'].extend({
|
370
377
|
/**
|
371
378
|
This callback will be called whenever an async operation is about to start.
|
372
|
-
|
373
|
-
Override this to call your framework's methods that handle async
|
379
|
+
Override this to call your framework's methods that handle async
|
374
380
|
operations.
|
375
|
-
|
376
|
-
@public
|
381
|
+
@public
|
377
382
|
@method asyncStart
|
378
383
|
*/
|
379
384
|
asyncStart: K,
|
380
385
|
|
381
386
|
/**
|
382
387
|
This callback will be called whenever an async operation has completed.
|
383
|
-
|
384
|
-
@public
|
388
|
+
@public
|
385
389
|
@method asyncEnd
|
386
390
|
*/
|
387
391
|
asyncEnd: K,
|
@@ -390,20 +394,17 @@ enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime/system/objec
|
|
390
394
|
Override this method with your testing framework's false assertion.
|
391
395
|
This function is called whenever an exception occurs causing the testing
|
392
396
|
promise to fail.
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
```javascript
|
397
|
+
QUnit example:
|
398
|
+
```javascript
|
397
399
|
exception: function(error) {
|
398
400
|
ok(false, error);
|
399
401
|
};
|
400
402
|
```
|
401
|
-
|
402
|
-
@public
|
403
|
+
@public
|
403
404
|
@method exception
|
404
405
|
@param {String} error The exception to be raised.
|
405
406
|
*/
|
406
|
-
exception: function(error) {
|
407
|
+
exception: function (error) {
|
407
408
|
throw error;
|
408
409
|
}
|
409
410
|
});
|
@@ -416,13 +417,13 @@ enifed('ember-testing/adapters/qunit', ['exports', 'ember-testing/adapters/adapt
|
|
416
417
|
'use strict';
|
417
418
|
|
418
419
|
exports['default'] = Adapter['default'].extend({
|
419
|
-
asyncStart: function() {
|
420
|
+
asyncStart: function () {
|
420
421
|
QUnit.stop();
|
421
422
|
},
|
422
|
-
asyncEnd: function() {
|
423
|
+
asyncEnd: function () {
|
423
424
|
QUnit.start();
|
424
425
|
},
|
425
|
-
exception: function(error) {
|
426
|
+
exception: function (error) {
|
426
427
|
ok(false, utils.inspect(error));
|
427
428
|
}
|
428
429
|
});
|
@@ -436,40 +437,40 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
436
437
|
var asyncHelper = Test['default'].registerAsyncHelper;
|
437
438
|
|
438
439
|
function currentRouteName(app) {
|
439
|
-
var appController = app.__container__.lookup(
|
440
|
+
var appController = app.__container__.lookup("controller:application");
|
440
441
|
|
441
|
-
return property_get.get(appController,
|
442
|
+
return property_get.get(appController, "currentRouteName");
|
442
443
|
}
|
443
444
|
|
444
445
|
function currentPath(app) {
|
445
|
-
var appController = app.__container__.lookup(
|
446
|
+
var appController = app.__container__.lookup("controller:application");
|
446
447
|
|
447
|
-
return property_get.get(appController,
|
448
|
+
return property_get.get(appController, "currentPath");
|
448
449
|
}
|
449
450
|
|
450
451
|
function currentURL(app) {
|
451
|
-
var router = app.__container__.lookup(
|
452
|
+
var router = app.__container__.lookup("router:main");
|
452
453
|
|
453
|
-
return property_get.get(router,
|
454
|
+
return property_get.get(router, "location").getURL();
|
454
455
|
}
|
455
456
|
|
456
457
|
function pauseTest() {
|
457
458
|
Test['default'].adapter.asyncStart();
|
458
|
-
return new Ember['default'].RSVP.Promise(function() {
|
459
|
+
return new Ember['default'].RSVP.Promise(function () {}, "TestAdapter paused promise");
|
459
460
|
}
|
460
461
|
|
461
462
|
function focus(el) {
|
462
|
-
if (el && el.is(
|
463
|
-
var type = el.prop(
|
464
|
-
if (type !==
|
465
|
-
run['default'](el, function() {
|
463
|
+
if (el && el.is(":input, [contenteditable=true]")) {
|
464
|
+
var type = el.prop("type");
|
465
|
+
if (type !== "checkbox" && type !== "radio" && type !== "hidden") {
|
466
|
+
run['default'](el, function () {
|
466
467
|
// Firefox does not trigger the `focusin` event if the window
|
467
468
|
// does not have focus. If the document doesn't have focus just
|
468
469
|
// use trigger('focusin') instead.
|
469
470
|
if (!document.hasFocus || document.hasFocus()) {
|
470
471
|
this.focus();
|
471
472
|
} else {
|
472
|
-
this.trigger(
|
473
|
+
this.trigger("focusin");
|
473
474
|
}
|
474
475
|
});
|
475
476
|
}
|
@@ -477,15 +478,15 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
477
478
|
}
|
478
479
|
|
479
480
|
function visit(app, url) {
|
480
|
-
var router = app.__container__.lookup(
|
481
|
-
router.location.setURL(url);
|
481
|
+
var router = app.__container__.lookup("router:main");
|
482
482
|
|
483
483
|
if (app._readinessDeferrals > 0) {
|
484
|
-
router[
|
485
|
-
run['default'](app,
|
486
|
-
delete router[
|
484
|
+
router["initialURL"] = url;
|
485
|
+
run['default'](app, "advanceReadiness");
|
486
|
+
delete router["initialURL"];
|
487
487
|
} else {
|
488
|
-
|
488
|
+
router.location.setURL(url);
|
489
|
+
run['default'](app.__deprecatedInstance__, "handleURL", url);
|
489
490
|
}
|
490
491
|
|
491
492
|
return app.testHelpers.wait();
|
@@ -493,24 +494,23 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
493
494
|
|
494
495
|
function click(app, selector, context) {
|
495
496
|
var $el = app.testHelpers.findWithAssert(selector, context);
|
496
|
-
run['default']($el,
|
497
|
+
run['default']($el, "mousedown");
|
497
498
|
|
498
499
|
focus($el);
|
499
500
|
|
500
|
-
run['default']($el,
|
501
|
-
run['default']($el,
|
501
|
+
run['default']($el, "mouseup");
|
502
|
+
run['default']($el, "click");
|
502
503
|
|
503
504
|
return app.testHelpers.wait();
|
504
505
|
}
|
505
506
|
|
506
507
|
function check(app, selector, context) {
|
507
508
|
var $el = app.testHelpers.findWithAssert(selector, context);
|
508
|
-
var type = $el.prop(
|
509
|
+
var type = $el.prop("type");
|
509
510
|
|
510
|
-
Ember['default'].assert(
|
511
|
-
'\', the input must be a checkbox', type === 'checkbox');
|
511
|
+
Ember['default'].assert("To check '" + selector + "', the input must be a checkbox", type === "checkbox");
|
512
512
|
|
513
|
-
if (!$el.prop(
|
513
|
+
if (!$el.prop("checked")) {
|
514
514
|
app.testHelpers.click(selector, context);
|
515
515
|
}
|
516
516
|
|
@@ -519,12 +519,11 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
519
519
|
|
520
520
|
function uncheck(app, selector, context) {
|
521
521
|
var $el = app.testHelpers.findWithAssert(selector, context);
|
522
|
-
var type = $el.prop(
|
522
|
+
var type = $el.prop("type");
|
523
523
|
|
524
|
-
Ember['default'].assert(
|
525
|
-
'\', the input must be a checkbox', type === 'checkbox');
|
524
|
+
Ember['default'].assert("To uncheck '" + selector + "', the input must be a checkbox", type === "checkbox");
|
526
525
|
|
527
|
-
if ($el.prop(
|
526
|
+
if ($el.prop("checked")) {
|
528
527
|
app.testHelpers.click(selector, context);
|
529
528
|
}
|
530
529
|
|
@@ -543,12 +542,14 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
543
542
|
options = {};
|
544
543
|
} else if (arity === 4) {
|
545
544
|
// context and options are optional, so this is
|
546
|
-
if (typeof typeOrOptions === "object") {
|
545
|
+
if (typeof typeOrOptions === "object") {
|
546
|
+
// either
|
547
547
|
// app, selector, type, options
|
548
548
|
context = null;
|
549
549
|
type = contextOrType;
|
550
550
|
options = typeOrOptions;
|
551
|
-
} else {
|
551
|
+
} else {
|
552
|
+
// or
|
552
553
|
// app, selector, context, type
|
553
554
|
context = contextOrType;
|
554
555
|
type = typeOrOptions;
|
@@ -564,7 +565,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
564
565
|
|
565
566
|
var event = jQuery['default'].Event(type, options);
|
566
567
|
|
567
|
-
run['default']($el,
|
568
|
+
run['default']($el, "trigger", event);
|
568
569
|
|
569
570
|
return app.testHelpers.wait();
|
570
571
|
}
|
@@ -572,7 +573,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
572
573
|
function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) {
|
573
574
|
var context, type;
|
574
575
|
|
575
|
-
if (typeof keyCode ===
|
576
|
+
if (typeof keyCode === "undefined") {
|
576
577
|
context = null;
|
577
578
|
keyCode = typeOrKeyCode;
|
578
579
|
type = contextOrType;
|
@@ -586,14 +587,14 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
586
587
|
|
587
588
|
function fillIn(app, selector, contextOrText, text) {
|
588
589
|
var $el, context;
|
589
|
-
if (typeof text ===
|
590
|
+
if (typeof text === "undefined") {
|
590
591
|
text = contextOrText;
|
591
592
|
} else {
|
592
593
|
context = contextOrText;
|
593
594
|
}
|
594
595
|
$el = app.testHelpers.findWithAssert(selector, context);
|
595
596
|
focus($el);
|
596
|
-
run['default'](function() {
|
597
|
+
run['default'](function () {
|
597
598
|
$el.val(text).change();
|
598
599
|
});
|
599
600
|
return app.testHelpers.wait();
|
@@ -609,7 +610,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
609
610
|
|
610
611
|
function find(app, selector, context) {
|
611
612
|
var $el;
|
612
|
-
context = context || property_get.get(app,
|
613
|
+
context = context || property_get.get(app, "rootElement");
|
613
614
|
$el = app.$(selector, context);
|
614
615
|
|
615
616
|
return $el;
|
@@ -620,21 +621,27 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
620
621
|
}
|
621
622
|
|
622
623
|
function wait(app, value) {
|
623
|
-
return new RSVP['default'].Promise(function(resolve) {
|
624
|
+
return new RSVP['default'].Promise(function (resolve) {
|
624
625
|
// Every 10ms, poll for the async thing to have finished
|
625
|
-
var watcher = setInterval(function() {
|
626
|
-
var router = app.__container__.lookup(
|
626
|
+
var watcher = setInterval(function () {
|
627
|
+
var router = app.__container__.lookup("router:main");
|
627
628
|
|
628
629
|
// 1. If the router is loading, keep polling
|
629
630
|
var routerIsLoading = router.router && !!router.router.activeTransition;
|
630
|
-
if (routerIsLoading) {
|
631
|
+
if (routerIsLoading) {
|
632
|
+
return;
|
633
|
+
}
|
631
634
|
|
632
635
|
// 2. If there are pending Ajax requests, keep polling
|
633
|
-
if (Test['default'].pendingAjaxRequests) {
|
636
|
+
if (Test['default'].pendingAjaxRequests) {
|
637
|
+
return;
|
638
|
+
}
|
634
639
|
|
635
640
|
// 3. If there are scheduled timers or we are inside of a run loop, keep polling
|
636
|
-
if (run['default'].hasScheduledTimers() || run['default'].currentRunLoop) {
|
637
|
-
|
641
|
+
if (run['default'].hasScheduledTimers() || run['default'].currentRunLoop) {
|
642
|
+
return;
|
643
|
+
}
|
644
|
+
if (Test['default'].waiters && Test['default'].waiters.any(function (waiter) {
|
638
645
|
var context = waiter[0];
|
639
646
|
var callback = waiter[1];
|
640
647
|
return !callback.call(context);
|
@@ -648,10 +655,8 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
648
655
|
run['default'](null, resolve, value);
|
649
656
|
}, 10);
|
650
657
|
});
|
651
|
-
|
652
658
|
}
|
653
659
|
|
654
|
-
|
655
660
|
/**
|
656
661
|
* Loads a route, sets up any controllers, and renders any templates associated
|
657
662
|
* with the route as though a real user had triggered the route change while
|
@@ -669,7 +674,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
669
674
|
* @param {String} url the name of the route
|
670
675
|
* @return {RSVP.Promise}
|
671
676
|
*/
|
672
|
-
asyncHelper(
|
677
|
+
asyncHelper("visit", visit);
|
673
678
|
|
674
679
|
/**
|
675
680
|
* Clicks an element and triggers any actions triggered by the element's `click`
|
@@ -687,7 +692,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
687
692
|
* @param {String} selector jQuery selector for finding element on the DOM
|
688
693
|
* @return {RSVP.Promise}
|
689
694
|
*/
|
690
|
-
asyncHelper(
|
695
|
+
asyncHelper("click", click);
|
691
696
|
|
692
697
|
/**
|
693
698
|
* Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode
|
@@ -707,7 +712,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
707
712
|
* @return {RSVP.Promise}
|
708
713
|
* @since 1.5.0
|
709
714
|
*/
|
710
|
-
asyncHelper(
|
715
|
+
asyncHelper("keyEvent", keyEvent);
|
711
716
|
|
712
717
|
/**
|
713
718
|
* Fills in an input element with some text.
|
@@ -726,7 +731,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
726
731
|
* @param {String} text text to place inside the input element
|
727
732
|
* @return {RSVP.Promise}
|
728
733
|
*/
|
729
|
-
asyncHelper(
|
734
|
+
asyncHelper("fillIn", fillIn);
|
730
735
|
|
731
736
|
/**
|
732
737
|
* Finds an element in the context of the app's container element. A simple alias
|
@@ -742,7 +747,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
742
747
|
* @param {String} selector jQuery string selector for element lookup
|
743
748
|
* @return {Object} jQuery object representing the results of the query
|
744
749
|
*/
|
745
|
-
helper(
|
750
|
+
helper("find", find);
|
746
751
|
|
747
752
|
/**
|
748
753
|
* Like `find`, but throws an error if the element selector returns no results.
|
@@ -759,7 +764,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
759
764
|
* @return {Object} jQuery object representing the results of the query
|
760
765
|
* @throws {Error} throws error if jQuery object returned has a length of 0
|
761
766
|
*/
|
762
|
-
helper(
|
767
|
+
helper("findWithAssert", findWithAssert);
|
763
768
|
|
764
769
|
/**
|
765
770
|
Causes the run loop to process any pending events. This is used to ensure that
|
@@ -784,9 +789,8 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
784
789
|
@param {Object} value The value to be returned.
|
785
790
|
@return {RSVP.Promise}
|
786
791
|
*/
|
787
|
-
asyncHelper(
|
788
|
-
asyncHelper(
|
789
|
-
|
792
|
+
asyncHelper("wait", wait);
|
793
|
+
asyncHelper("andThen", andThen);
|
790
794
|
|
791
795
|
/**
|
792
796
|
Returns the currently active route name.
|
@@ -805,7 +809,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
805
809
|
@return {Object} The name of the currently active route.
|
806
810
|
@since 1.5.0
|
807
811
|
*/
|
808
|
-
helper(
|
812
|
+
helper("currentRouteName", currentRouteName);
|
809
813
|
|
810
814
|
/**
|
811
815
|
Returns the current path.
|
@@ -824,7 +828,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
824
828
|
@return {Object} The currently active path.
|
825
829
|
@since 1.5.0
|
826
830
|
*/
|
827
|
-
helper(
|
831
|
+
helper("currentPath", currentPath);
|
828
832
|
|
829
833
|
/**
|
830
834
|
Returns the current URL.
|
@@ -843,7 +847,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
843
847
|
@return {Object} The currently active URL.
|
844
848
|
@since 1.5.0
|
845
849
|
*/
|
846
|
-
helper(
|
850
|
+
helper("currentURL", currentURL);
|
847
851
|
|
848
852
|
/**
|
849
853
|
Pauses the current test - this is useful for debugging while testing or for test-driving.
|
@@ -862,7 +866,7 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
862
866
|
@method pauseTest
|
863
867
|
@return {Object} A promise that will never resolve
|
864
868
|
*/
|
865
|
-
helper(
|
869
|
+
helper("pauseTest", pauseTest);
|
866
870
|
|
867
871
|
/**
|
868
872
|
Triggers the given DOM event on the element identified by the provided selector.
|
@@ -888,21 +892,21 @@ enifed('ember-testing/helpers', ['ember-metal/core', 'ember-metal/property_get',
|
|
888
892
|
@return {RSVP.Promise}
|
889
893
|
@since 1.5.0
|
890
894
|
*/
|
891
|
-
asyncHelper(
|
895
|
+
asyncHelper("triggerEvent", triggerEvent);
|
892
896
|
|
893
897
|
});
|
894
898
|
enifed('ember-testing/initializers', ['ember-runtime/system/lazy_load'], function (lazy_load) {
|
895
899
|
|
896
900
|
'use strict';
|
897
901
|
|
898
|
-
var name =
|
902
|
+
var name = "deferReadiness in `testing` mode";
|
899
903
|
|
900
|
-
lazy_load.onLoad(
|
904
|
+
lazy_load.onLoad("Ember.Application", function (Application) {
|
901
905
|
if (!Application.initializers[name]) {
|
902
906
|
Application.initializer({
|
903
907
|
name: name,
|
904
908
|
|
905
|
-
initialize: function(registry, application) {
|
909
|
+
initialize: function (registry, application) {
|
906
910
|
if (application.testing) {
|
907
911
|
application.deferReadiness();
|
908
912
|
}
|
@@ -916,6 +920,20 @@ enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal/core', 'ember
|
|
916
920
|
|
917
921
|
'use strict';
|
918
922
|
|
923
|
+
|
924
|
+
|
925
|
+
/**
|
926
|
+
Sets Ember up for testing. This is useful to perform
|
927
|
+
basic setup steps in order to unit test.
|
928
|
+
|
929
|
+
Use `App.setupForTesting` to perform integration tests (full
|
930
|
+
application testing).
|
931
|
+
|
932
|
+
@method setupForTesting
|
933
|
+
@namespace Ember
|
934
|
+
@since 1.5.0
|
935
|
+
*/
|
936
|
+
exports['default'] = setupForTesting;
|
919
937
|
var Test, requests;
|
920
938
|
|
921
939
|
function incrementAjaxPendingRequests(_, xhr) {
|
@@ -924,27 +942,17 @@ enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal/core', 'ember
|
|
924
942
|
}
|
925
943
|
|
926
944
|
function decrementAjaxPendingRequests(_, xhr) {
|
927
|
-
for (var i=0;i<requests.length;i++) {
|
945
|
+
for (var i = 0; i < requests.length; i++) {
|
928
946
|
if (xhr === requests[i]) {
|
929
947
|
requests.splice(i, 1);
|
930
948
|
}
|
931
949
|
}
|
932
950
|
Test.pendingAjaxRequests = requests.length;
|
933
951
|
}
|
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
|
-
*/
|
946
952
|
function setupForTesting() {
|
947
|
-
if (!Test) {
|
953
|
+
if (!Test) {
|
954
|
+
Test = requireModule("ember-testing/test")["default"];
|
955
|
+
}
|
948
956
|
|
949
957
|
Ember['default'].testing = true;
|
950
958
|
|
@@ -956,12 +964,11 @@ enifed('ember-testing/setup_for_testing', ['exports', 'ember-metal/core', 'ember
|
|
956
964
|
requests = [];
|
957
965
|
Test.pendingAjaxRequests = requests.length;
|
958
966
|
|
959
|
-
jQuery['default'](document).off(
|
960
|
-
jQuery['default'](document).off(
|
961
|
-
jQuery['default'](document).on(
|
962
|
-
jQuery['default'](document).on(
|
967
|
+
jQuery['default'](document).off("ajaxSend", incrementAjaxPendingRequests);
|
968
|
+
jQuery['default'](document).off("ajaxComplete", decrementAjaxPendingRequests);
|
969
|
+
jQuery['default'](document).on("ajaxSend", incrementAjaxPendingRequests);
|
970
|
+
jQuery['default'](document).on("ajaxComplete", decrementAjaxPendingRequests);
|
963
971
|
}
|
964
|
-
exports['default'] = setupForTesting;
|
965
972
|
|
966
973
|
});
|
967
974
|
enifed('ember-testing/support', ['ember-metal/core', 'ember-views/system/jquery', 'ember-metal/environment'], function (Ember, jQuery, environment) {
|
@@ -979,29 +986,23 @@ enifed('ember-testing/support', ['ember-metal/core', 'ember-views/system/jquery'
|
|
979
986
|
@method testCheckboxClick
|
980
987
|
*/
|
981
988
|
function testCheckboxClick(handler) {
|
982
|
-
$(
|
983
|
-
.css({ position: 'absolute', left: '-1000px', top: '-1000px' })
|
984
|
-
.appendTo('body')
|
985
|
-
.on('click', handler)
|
986
|
-
.trigger('click')
|
987
|
-
.remove();
|
989
|
+
$("<input type=\"checkbox\">").css({ position: "absolute", left: "-1000px", top: "-1000px" }).appendTo("body").on("click", handler).trigger("click").remove();
|
988
990
|
}
|
989
991
|
|
990
992
|
if (environment['default'].hasDOM) {
|
991
|
-
$(function() {
|
993
|
+
$(function () {
|
992
994
|
/*
|
993
995
|
Determine whether a checkbox checked using jQuery's "click" method will have
|
994
996
|
the correct value for its checked property.
|
995
|
-
|
996
|
-
If we determine that the current jQuery version exhibits this behavior,
|
997
|
+
If we determine that the current jQuery version exhibits this behavior,
|
997
998
|
patch it to work correctly as in the commit for the actual fix:
|
998
999
|
https://github.com/jquery/jquery/commit/1fb2f92.
|
999
1000
|
*/
|
1000
|
-
testCheckboxClick(function() {
|
1001
|
+
testCheckboxClick(function () {
|
1001
1002
|
if (!this.checked && !$.event.special.click) {
|
1002
1003
|
$.event.special.click = {
|
1003
1004
|
// For checkbox, fire native event so checked state will be right
|
1004
|
-
trigger: function() {
|
1005
|
+
trigger: function () {
|
1005
1006
|
if ($.nodeName(this, "input") && this.type === "checkbox" && this.click) {
|
1006
1007
|
this.click();
|
1007
1008
|
return false;
|
@@ -1012,7 +1013,7 @@ enifed('ember-testing/support', ['ember-metal/core', 'ember-views/system/jquery'
|
|
1012
1013
|
});
|
1013
1014
|
|
1014
1015
|
// Try again to verify that the patch took effect or blow up.
|
1015
|
-
testCheckboxClick(function() {
|
1016
|
+
testCheckboxClick(function () {
|
1016
1017
|
Ember['default'].warn("clicked checkboxes should be checked! the jQuery patch didn't work", this.checked);
|
1017
1018
|
});
|
1018
1019
|
});
|
@@ -1023,7 +1024,6 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1023
1024
|
|
1024
1025
|
'use strict';
|
1025
1026
|
|
1026
|
-
var slice = [].slice;
|
1027
1027
|
var helpers = {};
|
1028
1028
|
var injectHelpersCallbacks = [];
|
1029
1029
|
|
@@ -1041,8 +1041,7 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1041
1041
|
var Test = {
|
1042
1042
|
/**
|
1043
1043
|
Hash containing all known test helpers.
|
1044
|
-
|
1045
|
-
@property _helpers
|
1044
|
+
@property _helpers
|
1046
1045
|
@private
|
1047
1046
|
@since 1.7.0
|
1048
1047
|
*/
|
@@ -1051,34 +1050,28 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1051
1050
|
/**
|
1052
1051
|
`registerHelper` is used to register a test helper that will be injected
|
1053
1052
|
when `App.injectTestHelpers` is called.
|
1054
|
-
|
1055
|
-
The helper method will always be called with the current Application as
|
1053
|
+
The helper method will always be called with the current Application as
|
1056
1054
|
the first parameter.
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
```javascript
|
1055
|
+
For example:
|
1056
|
+
```javascript
|
1061
1057
|
Ember.Test.registerHelper('boot', function(app) {
|
1062
1058
|
Ember.run(app, app.advanceReadiness);
|
1063
1059
|
});
|
1064
1060
|
```
|
1065
|
-
|
1066
|
-
This helper can later be called without arguments because it will be
|
1061
|
+
This helper can later be called without arguments because it will be
|
1067
1062
|
called with `app` as the first parameter.
|
1068
|
-
|
1069
|
-
```javascript
|
1063
|
+
```javascript
|
1070
1064
|
App = Ember.Application.create();
|
1071
1065
|
App.injectTestHelpers();
|
1072
1066
|
boot();
|
1073
1067
|
```
|
1074
|
-
|
1075
|
-
@public
|
1068
|
+
@public
|
1076
1069
|
@method registerHelper
|
1077
1070
|
@param {String} name The name of the helper method to add.
|
1078
1071
|
@param {Function} helperMethod
|
1079
1072
|
@param options {Object}
|
1080
1073
|
*/
|
1081
|
-
registerHelper: function(name, helperMethod) {
|
1074
|
+
registerHelper: function (name, helperMethod) {
|
1082
1075
|
helpers[name] = {
|
1083
1076
|
method: helperMethod,
|
1084
1077
|
meta: { wait: false }
|
@@ -1088,44 +1081,35 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1088
1081
|
/**
|
1089
1082
|
`registerAsyncHelper` is used to register an async test helper that will be injected
|
1090
1083
|
when `App.injectTestHelpers` is called.
|
1091
|
-
|
1092
|
-
The helper method will always be called with the current Application as
|
1084
|
+
The helper method will always be called with the current Application as
|
1093
1085
|
the first parameter.
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
```javascript
|
1086
|
+
For example:
|
1087
|
+
```javascript
|
1098
1088
|
Ember.Test.registerAsyncHelper('boot', function(app) {
|
1099
1089
|
Ember.run(app, app.advanceReadiness);
|
1100
1090
|
});
|
1101
1091
|
```
|
1102
|
-
|
1103
|
-
The advantage of an async helper is that it will not run
|
1092
|
+
The advantage of an async helper is that it will not run
|
1104
1093
|
until the last async helper has completed. All async helpers
|
1105
1094
|
after it will wait for it complete before running.
|
1106
|
-
|
1107
|
-
|
1108
|
-
For example:
|
1109
|
-
|
1110
|
-
```javascript
|
1095
|
+
For example:
|
1096
|
+
```javascript
|
1111
1097
|
Ember.Test.registerAsyncHelper('deletePost', function(app, postId) {
|
1112
1098
|
click('.delete-' + postId);
|
1113
1099
|
});
|
1114
|
-
|
1115
|
-
// ... in your test
|
1100
|
+
// ... in your test
|
1116
1101
|
visit('/post/2');
|
1117
1102
|
deletePost(2);
|
1118
1103
|
visit('/post/3');
|
1119
1104
|
deletePost(3);
|
1120
1105
|
```
|
1121
|
-
|
1122
|
-
@public
|
1106
|
+
@public
|
1123
1107
|
@method registerAsyncHelper
|
1124
1108
|
@param {String} name The name of the helper method to add.
|
1125
1109
|
@param {Function} helperMethod
|
1126
1110
|
@since 1.2.0
|
1127
1111
|
*/
|
1128
|
-
registerAsyncHelper: function(name, helperMethod) {
|
1112
|
+
registerAsyncHelper: function (name, helperMethod) {
|
1129
1113
|
helpers[name] = {
|
1130
1114
|
method: helperMethod,
|
1131
1115
|
meta: { wait: true }
|
@@ -1134,18 +1118,15 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1134
1118
|
|
1135
1119
|
/**
|
1136
1120
|
Remove a previously added helper method.
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
```javascript
|
1121
|
+
Example:
|
1122
|
+
```javascript
|
1141
1123
|
Ember.Test.unregisterHelper('wait');
|
1142
1124
|
```
|
1143
|
-
|
1144
|
-
@public
|
1125
|
+
@public
|
1145
1126
|
@method unregisterHelper
|
1146
1127
|
@param {String} name The helper to remove.
|
1147
1128
|
*/
|
1148
|
-
unregisterHelper: function(name) {
|
1129
|
+
unregisterHelper: function (name) {
|
1149
1130
|
delete helpers[name];
|
1150
1131
|
delete Test.Promise.prototype[name];
|
1151
1132
|
},
|
@@ -1153,28 +1134,23 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1153
1134
|
/**
|
1154
1135
|
Used to register callbacks to be fired whenever `App.injectTestHelpers`
|
1155
1136
|
is called.
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
Example:
|
1160
|
-
|
1161
|
-
```javascript
|
1137
|
+
The callback will receive the current application as an argument.
|
1138
|
+
Example:
|
1139
|
+
```javascript
|
1162
1140
|
Ember.Test.onInjectHelpers(function() {
|
1163
1141
|
Ember.$(document).ajaxSend(function() {
|
1164
1142
|
Test.pendingAjaxRequests++;
|
1165
1143
|
});
|
1166
|
-
|
1167
|
-
Ember.$(document).ajaxComplete(function() {
|
1144
|
+
Ember.$(document).ajaxComplete(function() {
|
1168
1145
|
Test.pendingAjaxRequests--;
|
1169
1146
|
});
|
1170
1147
|
});
|
1171
1148
|
```
|
1172
|
-
|
1173
|
-
@public
|
1149
|
+
@public
|
1174
1150
|
@method onInjectHelpers
|
1175
1151
|
@param {Function} callback The function to be called.
|
1176
1152
|
*/
|
1177
|
-
onInjectHelpers: function(callback) {
|
1153
|
+
onInjectHelpers: function (callback) {
|
1178
1154
|
injectHelpersCallbacks.push(callback);
|
1179
1155
|
},
|
1180
1156
|
|
@@ -1182,32 +1158,25 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1182
1158
|
This returns a thenable tailored for testing. It catches failed
|
1183
1159
|
`onSuccess` callbacks and invokes the `Ember.Test.adapter.exception`
|
1184
1160
|
callback in the last chained then.
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
@public
|
1161
|
+
This method should be returned by async helpers such as `wait`.
|
1162
|
+
@public
|
1189
1163
|
@method promise
|
1190
1164
|
@param {Function} resolver The function used to resolve the promise.
|
1191
1165
|
*/
|
1192
|
-
promise: function(resolver) {
|
1166
|
+
promise: function (resolver) {
|
1193
1167
|
return new Test.Promise(resolver);
|
1194
1168
|
},
|
1195
1169
|
|
1196
1170
|
/**
|
1197
1171
|
Used to allow ember-testing to communicate with a specific testing
|
1198
1172
|
framework.
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
Example:
|
1203
|
-
|
1204
|
-
```javascript
|
1173
|
+
You can manually set it before calling `App.setupForTesting()`.
|
1174
|
+
Example:
|
1175
|
+
```javascript
|
1205
1176
|
Ember.Test.adapter = MyCustomAdapter.create()
|
1206
1177
|
```
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
@public
|
1178
|
+
If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`.
|
1179
|
+
@public
|
1211
1180
|
@property adapter
|
1212
1181
|
@type {Class} The adapter to be used.
|
1213
1182
|
@default Ember.Test.QUnitAdapter
|
@@ -1218,14 +1187,13 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1218
1187
|
Replacement for `Ember.RSVP.resolve`
|
1219
1188
|
The only difference is this uses
|
1220
1189
|
an instance of `Ember.Test.Promise`
|
1221
|
-
|
1222
|
-
@public
|
1190
|
+
@public
|
1223
1191
|
@method resolve
|
1224
1192
|
@param {Mixed} The value to resolve
|
1225
1193
|
@since 1.2.0
|
1226
1194
|
*/
|
1227
|
-
resolve: function(val) {
|
1228
|
-
return Test.promise(function(resolve) {
|
1195
|
+
resolve: function (val) {
|
1196
|
+
return Test.promise(function (resolve) {
|
1229
1197
|
return resolve(val);
|
1230
1198
|
});
|
1231
1199
|
},
|
@@ -1234,30 +1202,25 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1234
1202
|
This allows ember-testing to play nicely with other asynchronous
|
1235
1203
|
events, such as an application that is waiting for a CSS3
|
1236
1204
|
transition or an IndexDB transaction.
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
```javascript
|
1205
|
+
For example:
|
1206
|
+
```javascript
|
1241
1207
|
Ember.Test.registerWaiter(function() {
|
1242
1208
|
return myPendingTransactions() == 0;
|
1243
1209
|
});
|
1244
1210
|
```
|
1245
1211
|
The `context` argument allows you to optionally specify the `this`
|
1246
1212
|
with which your callback will be invoked.
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
```javascript
|
1213
|
+
For example:
|
1214
|
+
```javascript
|
1251
1215
|
Ember.Test.registerWaiter(MyDB, MyDB.hasPendingTransactions);
|
1252
1216
|
```
|
1253
|
-
|
1254
|
-
@public
|
1217
|
+
@public
|
1255
1218
|
@method registerWaiter
|
1256
1219
|
@param {Object} context (optional)
|
1257
1220
|
@param {Function} callback
|
1258
1221
|
@since 1.2.0
|
1259
1222
|
*/
|
1260
|
-
registerWaiter: function(context, callback) {
|
1223
|
+
registerWaiter: function (context, callback) {
|
1261
1224
|
if (arguments.length === 1) {
|
1262
1225
|
callback = context;
|
1263
1226
|
context = null;
|
@@ -1270,20 +1233,21 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1270
1233
|
/**
|
1271
1234
|
`unregisterWaiter` is used to unregister a callback that was
|
1272
1235
|
registered with `registerWaiter`.
|
1273
|
-
|
1274
|
-
@public
|
1236
|
+
@public
|
1275
1237
|
@method unregisterWaiter
|
1276
1238
|
@param {Object} context (optional)
|
1277
1239
|
@param {Function} callback
|
1278
1240
|
@since 1.2.0
|
1279
1241
|
*/
|
1280
|
-
unregisterWaiter: function(context, callback) {
|
1281
|
-
if (!this.waiters) {
|
1242
|
+
unregisterWaiter: function (context, callback) {
|
1243
|
+
if (!this.waiters) {
|
1244
|
+
return;
|
1245
|
+
}
|
1282
1246
|
if (arguments.length === 1) {
|
1283
1247
|
callback = context;
|
1284
1248
|
context = null;
|
1285
1249
|
}
|
1286
|
-
this.waiters = Ember['default'].A(this.waiters.filter(function(elt) {
|
1250
|
+
this.waiters = Ember['default'].A(this.waiters.filter(function (elt) {
|
1287
1251
|
return !(elt[0] === context && elt[1] === callback);
|
1288
1252
|
}));
|
1289
1253
|
}
|
@@ -1293,8 +1257,11 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1293
1257
|
var fn = helpers[name].method;
|
1294
1258
|
var meta = helpers[name].meta;
|
1295
1259
|
|
1296
|
-
return function() {
|
1297
|
-
var args =
|
1260
|
+
return function () {
|
1261
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1262
|
+
args[_key] = arguments[_key];
|
1263
|
+
}
|
1264
|
+
|
1298
1265
|
var lastPromise;
|
1299
1266
|
|
1300
1267
|
args.unshift(app);
|
@@ -1306,7 +1273,7 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1306
1273
|
return fn.apply(app, args);
|
1307
1274
|
}
|
1308
1275
|
|
1309
|
-
lastPromise = run(function() {
|
1276
|
+
lastPromise = run(function () {
|
1310
1277
|
return Test.resolve(Test.lastPromise);
|
1311
1278
|
});
|
1312
1279
|
|
@@ -1315,9 +1282,9 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1315
1282
|
// asynchronous here, because fn may not be invoked before we
|
1316
1283
|
// return.
|
1317
1284
|
Test.adapter.asyncStart();
|
1318
|
-
return lastPromise.then(function() {
|
1285
|
+
return lastPromise.then(function () {
|
1319
1286
|
return fn.apply(app, args);
|
1320
|
-
})["finally"](function() {
|
1287
|
+
})["finally"](function () {
|
1321
1288
|
Test.adapter.asyncEnd();
|
1322
1289
|
});
|
1323
1290
|
};
|
@@ -1337,8 +1304,7 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1337
1304
|
are created once you call `injectTestHelpers` on your `Ember.Application`
|
1338
1305
|
instance. The included helpers are also available on the `window` object by
|
1339
1306
|
default, but can be used from this object on the individual application also.
|
1340
|
-
|
1341
|
-
@property testHelpers
|
1307
|
+
@property testHelpers
|
1342
1308
|
@type {Object}
|
1343
1309
|
@default {}
|
1344
1310
|
*/
|
@@ -1347,11 +1313,9 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1347
1313
|
/**
|
1348
1314
|
This property will contain the original methods that were registered
|
1349
1315
|
on the `helperContainer` before `injectTestHelpers` is called.
|
1350
|
-
|
1351
|
-
When `removeTestHelpers` is called, these methods are restored to the
|
1316
|
+
When `removeTestHelpers` is called, these methods are restored to the
|
1352
1317
|
`helperContainer`.
|
1353
|
-
|
1354
|
-
@property originalMethods
|
1318
|
+
@property originalMethods
|
1355
1319
|
@type {Object}
|
1356
1320
|
@default {}
|
1357
1321
|
@private
|
@@ -1359,13 +1323,11 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1359
1323
|
*/
|
1360
1324
|
originalMethods: {},
|
1361
1325
|
|
1362
|
-
|
1363
1326
|
/**
|
1364
1327
|
This property indicates whether or not this application is currently in
|
1365
1328
|
testing mode. This is set when `setupForTesting` is called on the current
|
1366
1329
|
application.
|
1367
|
-
|
1368
|
-
@property testing
|
1330
|
+
@property testing
|
1369
1331
|
@type {Boolean}
|
1370
1332
|
@default false
|
1371
1333
|
@since 1.3.0
|
@@ -1378,30 +1340,26 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1378
1340
|
location to 'none', so that the window's location will not be modified
|
1379
1341
|
(preventing both accidental leaking of state between tests and interference
|
1380
1342
|
with your testing framework).
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
```
|
1343
|
+
Example:
|
1344
|
+
```
|
1385
1345
|
App.setupForTesting();
|
1386
1346
|
```
|
1387
|
-
|
1388
|
-
@method setupForTesting
|
1347
|
+
@method setupForTesting
|
1389
1348
|
*/
|
1390
|
-
setupForTesting: function() {
|
1349
|
+
setupForTesting: function () {
|
1391
1350
|
setupForTesting['default']();
|
1392
1351
|
|
1393
1352
|
this.testing = true;
|
1394
1353
|
|
1395
1354
|
this.Router.reopen({
|
1396
|
-
location:
|
1355
|
+
location: "none"
|
1397
1356
|
});
|
1398
1357
|
},
|
1399
1358
|
|
1400
1359
|
/**
|
1401
1360
|
This will be used as the container to inject the test helpers into. By
|
1402
1361
|
default the helpers are injected into `window`.
|
1403
|
-
|
1404
|
-
@property helperContainer
|
1362
|
+
@property helperContainer
|
1405
1363
|
@type {Object} The object to be used for test helpers.
|
1406
1364
|
@default window
|
1407
1365
|
@since 1.2.0
|
@@ -1414,18 +1372,15 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1414
1372
|
to `window`. If a function of the same name has already been defined it will be cached
|
1415
1373
|
(so that it can be reset if the helper is removed with `unregisterHelper` or
|
1416
1374
|
`removeTestHelpers`).
|
1417
|
-
|
1418
|
-
Any callbacks registered with `onInjectHelpers` will be called once the
|
1375
|
+
Any callbacks registered with `onInjectHelpers` will be called once the
|
1419
1376
|
helpers have been injected.
|
1420
|
-
|
1421
|
-
Example:
|
1377
|
+
Example:
|
1422
1378
|
```
|
1423
1379
|
App.injectTestHelpers();
|
1424
1380
|
```
|
1425
|
-
|
1426
|
-
@method injectTestHelpers
|
1381
|
+
@method injectTestHelpers
|
1427
1382
|
*/
|
1428
|
-
injectTestHelpers: function(helperContainer) {
|
1383
|
+
injectTestHelpers: function (helperContainer) {
|
1429
1384
|
if (helperContainer) {
|
1430
1385
|
this.helperContainer = helperContainer;
|
1431
1386
|
} else {
|
@@ -1447,18 +1402,17 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1447
1402
|
/**
|
1448
1403
|
This removes all helpers that have been registered, and resets and functions
|
1449
1404
|
that were overridden by the helpers.
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
```javascript
|
1405
|
+
Example:
|
1406
|
+
```javascript
|
1454
1407
|
App.removeTestHelpers();
|
1455
1408
|
```
|
1456
|
-
|
1457
|
-
@public
|
1409
|
+
@public
|
1458
1410
|
@method removeTestHelpers
|
1459
1411
|
*/
|
1460
|
-
removeTestHelpers: function() {
|
1461
|
-
if (!this.helperContainer) {
|
1412
|
+
removeTestHelpers: function () {
|
1413
|
+
if (!this.helperContainer) {
|
1414
|
+
return;
|
1415
|
+
}
|
1462
1416
|
|
1463
1417
|
for (var name in helpers) {
|
1464
1418
|
this.helperContainer[name] = this.originalMethods[name];
|
@@ -1472,19 +1426,22 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1472
1426
|
// But still here for backwards compatibility
|
1473
1427
|
// of helper chaining
|
1474
1428
|
function protoWrap(proto, name, callback, isAsync) {
|
1475
|
-
proto[name] = function() {
|
1476
|
-
var args =
|
1429
|
+
proto[name] = function () {
|
1430
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1431
|
+
args[_key] = arguments[_key];
|
1432
|
+
}
|
1433
|
+
|
1477
1434
|
if (isAsync) {
|
1478
1435
|
return callback.apply(this, args);
|
1479
1436
|
} else {
|
1480
|
-
return this.then(function() {
|
1437
|
+
return this.then(function () {
|
1481
1438
|
return callback.apply(this, args);
|
1482
1439
|
});
|
1483
1440
|
}
|
1484
1441
|
};
|
1485
1442
|
}
|
1486
1443
|
|
1487
|
-
Test.Promise = function() {
|
1444
|
+
Test.Promise = function () {
|
1488
1445
|
RSVP['default'].Promise.apply(this, arguments);
|
1489
1446
|
Test.lastPromise = this;
|
1490
1447
|
};
|
@@ -1496,8 +1453,8 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1496
1453
|
// Patch `then` to isolate async methods
|
1497
1454
|
// specifically `Ember.Test.lastPromise`
|
1498
1455
|
var originalThen = RSVP['default'].Promise.prototype.then;
|
1499
|
-
Test.Promise.prototype.then = function(onSuccess, onFailure) {
|
1500
|
-
return originalThen.call(this, function(val) {
|
1456
|
+
Test.Promise.prototype.then = function (onSuccess, onFailure) {
|
1457
|
+
return originalThen.call(this, function (val) {
|
1501
1458
|
return isolate(onSuccess, val);
|
1502
1459
|
}, onFailure);
|
1503
1460
|
};
|
@@ -1522,11 +1479,11 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1522
1479
|
// If the method returned a promise
|
1523
1480
|
// return that promise. If not,
|
1524
1481
|
// return the last async helper's promise
|
1525
|
-
if (
|
1482
|
+
if (value && value instanceof Test.Promise || !lastPromise) {
|
1526
1483
|
return value;
|
1527
1484
|
} else {
|
1528
|
-
return run(function() {
|
1529
|
-
return Test.resolve(lastPromise).then(function() {
|
1485
|
+
return run(function () {
|
1486
|
+
return Test.resolve(lastPromise).then(function () {
|
1530
1487
|
return value;
|
1531
1488
|
});
|
1532
1489
|
});
|
@@ -1536,118 +1493,6 @@ enifed('ember-testing/test', ['exports', 'ember-metal/core', 'ember-metal/run_lo
|
|
1536
1493
|
exports['default'] = Test;
|
1537
1494
|
|
1538
1495
|
});
|
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
|
-
});
|
1651
1496
|
requireModule("ember-testing");
|
1652
1497
|
|
1653
1498
|
})();
|