ember-source 1.8.0.beta.5 → 1.8.0

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.

@@ -2,6 +2,11 @@
2
2
  var Ember = { assert: function() {}, FEATURES: { isEnabled: function() {} } };
3
3
  /* global Handlebars:true */
4
4
 
5
+ // Remove "use strict"; from transpiled module (in browser builds only) until
6
+ // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed
7
+ //
8
+ // REMOVE_USE_STRICT: true
9
+
5
10
  /**
6
11
  @module ember
7
12
  @submodule ember-handlebars-compiler
@@ -0,0 +1,1474 @@
1
+ /*!
2
+ * @overview Ember - JavaScript Application Framework
3
+ * @copyright Copyright 2011-2014 Tilde Inc. and contributors
4
+ * Portions Copyright 2006-2011 Strobe Inc.
5
+ * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
+ * @license Licensed under MIT license
7
+ * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
+ * @version 1.8.0
9
+ */
10
+
11
+ (function() {
12
+ var enifed, requireModule, eriuqer, requirejs, Ember;
13
+
14
+ (function() {
15
+ Ember = this.Ember = this.Ember || {};
16
+ if (typeof Ember === 'undefined') { Ember = {}; };
17
+
18
+ if (typeof Ember.__loader === 'undefined') {
19
+ var registry = {}, seen = {};
20
+
21
+ enifed = function(name, deps, callback) {
22
+ registry[name] = { deps: deps, callback: callback };
23
+ };
24
+
25
+ requirejs = eriuqer = requireModule = function(name) {
26
+ if (seen.hasOwnProperty(name)) { return seen[name]; }
27
+ seen[name] = {};
28
+
29
+ if (!registry[name]) {
30
+ throw new Error("Could not find module " + name);
31
+ }
32
+
33
+ var mod = registry[name];
34
+ var deps = mod.deps;
35
+ var callback = mod.callback;
36
+ var reified = [];
37
+ var exports;
38
+
39
+ for (var i=0, l=deps.length; i<l; i++) {
40
+ if (deps[i] === 'exports') {
41
+ reified.push(exports = {});
42
+ } else {
43
+ reified.push(requireModule(resolve(deps[i])));
44
+ }
45
+ }
46
+
47
+ var value = callback.apply(this, reified);
48
+ return seen[name] = exports || value;
49
+
50
+ function resolve(child) {
51
+ if (child.charAt(0) !== '.') { return child; }
52
+ var parts = child.split("/");
53
+ var parentBase = name.split("/").slice(0, -1);
54
+
55
+ for (var i=0, l=parts.length; i<l; i++) {
56
+ var part = parts[i];
57
+
58
+ if (part === '..') { parentBase.pop(); }
59
+ else if (part === '.') { continue; }
60
+ else { parentBase.push(part); }
61
+ }
62
+
63
+ return parentBase.join("/");
64
+ }
65
+ };
66
+ requirejs._eak_seen = registry;
67
+
68
+ Ember.__loader = {define: enifed, require: eriuqer, registry: registry};
69
+ } else {
70
+ enifed = Ember.__loader.define;
71
+ requirejs = eriuqer = requireModule = Ember.__loader.require;
72
+ }
73
+ })();
74
+
75
+ enifed("ember-debug",
76
+ ["ember-metal/core","ember-metal/error","ember-metal/logger"],
77
+ function(__dependency1__, __dependency2__, __dependency3__) {
78
+ "use strict";
79
+ /*global __fail__*/
80
+
81
+ var Ember = __dependency1__["default"];
82
+ var EmberError = __dependency2__["default"];
83
+ var Logger = __dependency3__["default"];
84
+
85
+ /**
86
+ Ember Debug
87
+
88
+ @module ember
89
+ @submodule ember-debug
90
+ */
91
+
92
+ /**
93
+ @class Ember
94
+ */
95
+
96
+ /**
97
+ Define an assertion that will throw an exception if the condition is not
98
+ met. Ember build tools will remove any calls to `Ember.assert()` when
99
+ doing a production build. Example:
100
+
101
+ ```javascript
102
+ // Test for truthiness
103
+ Ember.assert('Must pass a valid object', obj);
104
+
105
+ // Fail unconditionally
106
+ Ember.assert('This code path should never be run');
107
+ ```
108
+
109
+ @method assert
110
+ @param {String} desc A description of the assertion. This will become
111
+ the text of the Error thrown if the assertion fails.
112
+ @param {Boolean} test Must be truthy for the assertion to pass. If
113
+ falsy, an exception will be thrown.
114
+ */
115
+ Ember.assert = function(desc, test) {
116
+ if (!test) {
117
+ throw new EmberError("Assertion Failed: " + desc);
118
+ }
119
+ };
120
+
121
+
122
+ /**
123
+ Display a warning with the provided message. Ember build tools will
124
+ remove any calls to `Ember.warn()` when doing a production build.
125
+
126
+ @method warn
127
+ @param {String} message A warning to display.
128
+ @param {Boolean} test An optional boolean. If falsy, the warning
129
+ will be displayed.
130
+ */
131
+ Ember.warn = function(message, test) {
132
+ if (!test) {
133
+ Logger.warn("WARNING: "+message);
134
+ if ('trace' in Logger) Logger.trace();
135
+ }
136
+ };
137
+
138
+ /**
139
+ Display a debug notice. Ember build tools will remove any calls to
140
+ `Ember.debug()` when doing a production build.
141
+
142
+ ```javascript
143
+ Ember.debug('I\'m a debug notice!');
144
+ ```
145
+
146
+ @method debug
147
+ @param {String} message A debug message to display.
148
+ */
149
+ Ember.debug = function(message) {
150
+ Logger.debug("DEBUG: "+message);
151
+ };
152
+
153
+ /**
154
+ Display a deprecation warning with the provided message and a stack trace
155
+ (Chrome and Firefox only). Ember build tools will remove any calls to
156
+ `Ember.deprecate()` when doing a production build.
157
+
158
+ @method deprecate
159
+ @param {String} message A description of the deprecation.
160
+ @param {Boolean} test An optional boolean. If falsy, the deprecation
161
+ will be displayed.
162
+ */
163
+ Ember.deprecate = function(message, test) {
164
+ if (test) { return; }
165
+
166
+ if (Ember.ENV.RAISE_ON_DEPRECATION) { throw new EmberError(message); }
167
+
168
+ var error;
169
+
170
+ // When using new Error, we can't do the arguments check for Chrome. Alternatives are welcome
171
+ try { __fail__.fail(); } catch (e) { error = e; }
172
+
173
+ if (Ember.LOG_STACKTRACE_ON_DEPRECATION && error.stack) {
174
+ var stack;
175
+ var stackStr = '';
176
+
177
+ if (error['arguments']) {
178
+ // Chrome
179
+ stack = error.stack.replace(/^\s+at\s+/gm, '').
180
+ replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').
181
+ replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n');
182
+ stack.shift();
183
+ } else {
184
+ // Firefox
185
+ stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').
186
+ replace(/^\(/gm, '{anonymous}(').split('\n');
187
+ }
188
+
189
+ stackStr = "\n " + stack.slice(2).join("\n ");
190
+ message = message + stackStr;
191
+ }
192
+
193
+ Logger.warn("DEPRECATION: "+message);
194
+ };
195
+
196
+
197
+
198
+ /**
199
+ Alias an old, deprecated method with its new counterpart.
200
+
201
+ Display a deprecation warning with the provided message and a stack trace
202
+ (Chrome and Firefox only) when the assigned method is called.
203
+
204
+ Ember build tools will not remove calls to `Ember.deprecateFunc()`, though
205
+ no warnings will be shown in production.
206
+
207
+ ```javascript
208
+ Ember.oldMethod = Ember.deprecateFunc('Please use the new, updated method', Ember.newMethod);
209
+ ```
210
+
211
+ @method deprecateFunc
212
+ @param {String} message A description of the deprecation.
213
+ @param {Function} func The new function called to replace its deprecated counterpart.
214
+ @return {Function} a new function that wrapped the original function with a deprecation warning
215
+ */
216
+ Ember.deprecateFunc = function(message, func) {
217
+ return function() {
218
+ Ember.deprecate(message);
219
+ return func.apply(this, arguments);
220
+ };
221
+ };
222
+
223
+
224
+ /**
225
+ Run a function meant for debugging. Ember build tools will remove any calls to
226
+ `Ember.runInDebug()` when doing a production build.
227
+
228
+ ```javascript
229
+ Ember.runInDebug(function() {
230
+ Ember.Handlebars.EachView.reopen({
231
+ didInsertElement: function() {
232
+ console.log('I\'m happy');
233
+ }
234
+ });
235
+ });
236
+ ```
237
+
238
+ @method runInDebug
239
+ @param {Function} func The function to be executed.
240
+ @since 1.5.0
241
+ */
242
+ Ember.runInDebug = function(func) {
243
+ func();
244
+ };
245
+
246
+ // Inform the developer about the Ember Inspector if not installed.
247
+ if (!Ember.testing) {
248
+ var isFirefox = typeof InstallTrigger !== 'undefined';
249
+ var isChrome = !!window.chrome && !window.opera;
250
+
251
+ if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) {
252
+ window.addEventListener("load", function() {
253
+ if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) {
254
+ var downloadURL;
255
+
256
+ if(isChrome) {
257
+ downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi';
258
+ } else if(isFirefox) {
259
+ downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/';
260
+ }
261
+
262
+ Ember.debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL);
263
+ }
264
+ }, false);
265
+ }
266
+ }
267
+ });
268
+ enifed("ember-testing",
269
+ ["ember-metal/core","ember-testing/initializers","ember-testing/support","ember-testing/setup_for_testing","ember-testing/test","ember-testing/adapters/adapter","ember-testing/adapters/qunit","ember-testing/helpers"],
270
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {
271
+ "use strict";
272
+ var Ember = __dependency1__["default"];
273
+
274
+ // to setup initializer
275
+ // to handle various edge cases
276
+
277
+ var setupForTesting = __dependency4__["default"];
278
+ var Test = __dependency5__["default"];
279
+ var Adapter = __dependency6__["default"];
280
+ var QUnitAdapter = __dependency7__["default"];
281
+ // adds helpers to helpers object in Test
282
+
283
+ /**
284
+ Ember Testing
285
+
286
+ @module ember
287
+ @submodule ember-testing
288
+ @requires ember-application
289
+ */
290
+
291
+ Ember.Test = Test;
292
+ Ember.Test.Adapter = Adapter;
293
+ Ember.Test.QUnitAdapter = QUnitAdapter;
294
+ Ember.setupForTesting = setupForTesting;
295
+ });
296
+ enifed("ember-testing/adapters/adapter",
297
+ ["ember-metal/core","ember-metal/utils","ember-runtime/system/object","exports"],
298
+ function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
299
+ "use strict";
300
+ var Ember = __dependency1__["default"];
301
+ // Ember.K
302
+ var inspect = __dependency2__.inspect;
303
+ var EmberObject = __dependency3__["default"];
304
+
305
+ /**
306
+ @module ember
307
+ @submodule ember-testing
308
+ */
309
+
310
+ /**
311
+ The primary purpose of this class is to create hooks that can be implemented
312
+ by an adapter for various test frameworks.
313
+
314
+ @class Adapter
315
+ @namespace Ember.Test
316
+ */
317
+ var Adapter = EmberObject.extend({
318
+ /**
319
+ This callback will be called whenever an async operation is about to start.
320
+
321
+ Override this to call your framework's methods that handle async
322
+ operations.
323
+
324
+ @public
325
+ @method asyncStart
326
+ */
327
+ asyncStart: Ember.K,
328
+
329
+ /**
330
+ This callback will be called whenever an async operation has completed.
331
+
332
+ @public
333
+ @method asyncEnd
334
+ */
335
+ asyncEnd: Ember.K,
336
+
337
+ /**
338
+ Override this method with your testing framework's false assertion.
339
+ This function is called whenever an exception occurs causing the testing
340
+ promise to fail.
341
+
342
+ QUnit example:
343
+
344
+ ```javascript
345
+ exception: function(error) {
346
+ ok(false, error);
347
+ };
348
+ ```
349
+
350
+ @public
351
+ @method exception
352
+ @param {String} error The exception to be raised.
353
+ */
354
+ exception: function(error) {
355
+ throw error;
356
+ }
357
+ });
358
+
359
+ __exports__["default"] = Adapter;
360
+ });
361
+ enifed("ember-testing/adapters/qunit",
362
+ ["ember-testing/adapters/adapter","ember-metal/utils","exports"],
363
+ function(__dependency1__, __dependency2__, __exports__) {
364
+ "use strict";
365
+ var Adapter = __dependency1__["default"];
366
+ var inspect = __dependency2__.inspect;
367
+
368
+ /**
369
+ This class implements the methods defined by Ember.Test.Adapter for the
370
+ QUnit testing framework.
371
+
372
+ @class QUnitAdapter
373
+ @namespace Ember.Test
374
+ @extends Ember.Test.Adapter
375
+ */
376
+ __exports__["default"] = Adapter.extend({
377
+ asyncStart: function() {
378
+ QUnit.stop();
379
+ },
380
+ asyncEnd: function() {
381
+ QUnit.start();
382
+ },
383
+ exception: function(error) {
384
+ ok(false, inspect(error));
385
+ }
386
+ });
387
+ });
388
+ enifed("ember-testing/helpers",
389
+ ["ember-metal/property_get","ember-metal/error","ember-metal/run_loop","ember-views/system/jquery","ember-testing/test"],
390
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
391
+ "use strict";
392
+ var get = __dependency1__.get;
393
+ var EmberError = __dependency2__["default"];
394
+ var run = __dependency3__["default"];
395
+ var jQuery = __dependency4__["default"];
396
+ var Test = __dependency5__["default"];
397
+
398
+ /**
399
+ * @module ember
400
+ * @submodule ember-testing
401
+ */
402
+
403
+ var helper = Test.registerHelper;
404
+ var asyncHelper = Test.registerAsyncHelper;
405
+ var countAsync = 0;
406
+
407
+ function currentRouteName(app){
408
+ var appController = app.__container__.lookup('controller:application');
409
+
410
+ return get(appController, 'currentRouteName');
411
+ }
412
+
413
+ function currentPath(app){
414
+ var appController = app.__container__.lookup('controller:application');
415
+
416
+ return get(appController, 'currentPath');
417
+ }
418
+
419
+ function currentURL(app){
420
+ var router = app.__container__.lookup('router:main');
421
+
422
+ return get(router, 'location').getURL();
423
+ }
424
+
425
+ function visit(app, url) {
426
+ var router = app.__container__.lookup('router:main');
427
+ router.location.setURL(url);
428
+
429
+ if (app._readinessDeferrals > 0) {
430
+ router['initialURL'] = url;
431
+ run(app, 'advanceReadiness');
432
+ delete router['initialURL'];
433
+ } else {
434
+ run(app, app.handleURL, url);
435
+ }
436
+
437
+ return app.testHelpers.wait();
438
+ }
439
+
440
+ function click(app, selector, context) {
441
+ var $el = app.testHelpers.findWithAssert(selector, context);
442
+ run($el, 'mousedown');
443
+
444
+ if ($el.is(':input')) {
445
+ var type = $el.prop('type');
446
+ if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') {
447
+ run($el, function(){
448
+ // Firefox does not trigger the `focusin` event if the window
449
+ // does not have focus. If the document doesn't have focus just
450
+ // use trigger('focusin') instead.
451
+ if (!document.hasFocus || document.hasFocus()) {
452
+ this.focus();
453
+ } else {
454
+ this.trigger('focusin');
455
+ }
456
+ });
457
+ }
458
+ }
459
+
460
+ run($el, 'mouseup');
461
+ run($el, 'click');
462
+
463
+ return app.testHelpers.wait();
464
+ }
465
+
466
+ function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions){
467
+ var arity = arguments.length;
468
+ var context, type, options;
469
+
470
+ if (arity === 3) {
471
+ // context and options are optional, so this is
472
+ // app, selector, type
473
+ context = null;
474
+ type = contextOrType;
475
+ options = {};
476
+ } else if (arity === 4) {
477
+ // context and options are optional, so this is
478
+ if (typeof typeOrOptions === "object") { // either
479
+ // app, selector, type, options
480
+ context = null;
481
+ type = contextOrType;
482
+ options = typeOrOptions;
483
+ } else { // or
484
+ // app, selector, context, type
485
+ context = contextOrType;
486
+ type = typeOrOptions;
487
+ options = {};
488
+ }
489
+ } else {
490
+ context = contextOrType;
491
+ type = typeOrOptions;
492
+ options = possibleOptions;
493
+ }
494
+
495
+ var $el = app.testHelpers.findWithAssert(selector, context);
496
+
497
+ var event = jQuery.Event(type, options);
498
+
499
+ run($el, 'trigger', event);
500
+
501
+ return app.testHelpers.wait();
502
+ }
503
+
504
+ function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) {
505
+ var context, type;
506
+
507
+ if (typeof keyCode === 'undefined') {
508
+ context = null;
509
+ keyCode = typeOrKeyCode;
510
+ type = contextOrType;
511
+ } else {
512
+ context = contextOrType;
513
+ type = typeOrKeyCode;
514
+ }
515
+
516
+ return app.testHelpers.triggerEvent(selector, context, type, { keyCode: keyCode, which: keyCode });
517
+ }
518
+
519
+ function fillIn(app, selector, contextOrText, text) {
520
+ var $el, context;
521
+ if (typeof text === 'undefined') {
522
+ text = contextOrText;
523
+ } else {
524
+ context = contextOrText;
525
+ }
526
+ $el = app.testHelpers.findWithAssert(selector, context);
527
+ run(function() {
528
+ $el.val(text).change();
529
+ });
530
+ return app.testHelpers.wait();
531
+ }
532
+
533
+ function findWithAssert(app, selector, context) {
534
+ var $el = app.testHelpers.find(selector, context);
535
+ if ($el.length === 0) {
536
+ throw new EmberError("Element " + selector + " not found.");
537
+ }
538
+ return $el;
539
+ }
540
+
541
+ function find(app, selector, context) {
542
+ var $el;
543
+ context = context || get(app, 'rootElement');
544
+ $el = app.$(selector, context);
545
+
546
+ return $el;
547
+ }
548
+
549
+ function andThen(app, callback) {
550
+ return app.testHelpers.wait(callback(app));
551
+ }
552
+
553
+ function wait(app, value) {
554
+ return Test.promise(function(resolve) {
555
+ // If this is the first async promise, kick off the async test
556
+ if (++countAsync === 1) {
557
+ Test.adapter.asyncStart();
558
+ }
559
+
560
+ // Every 10ms, poll for the async thing to have finished
561
+ var watcher = setInterval(function() {
562
+ // 1. If the router is loading, keep polling
563
+ var routerIsLoading = !!app.__container__.lookup('router:main').router.activeTransition;
564
+ if (routerIsLoading) { return; }
565
+
566
+ // 2. If there are pending Ajax requests, keep polling
567
+ if (Test.pendingAjaxRequests) { return; }
568
+
569
+ // 3. If there are scheduled timers or we are inside of a run loop, keep polling
570
+ if (run.hasScheduledTimers() || run.currentRunLoop) { return; }
571
+ if (Test.waiters && Test.waiters.any(function(waiter) {
572
+ var context = waiter[0];
573
+ var callback = waiter[1];
574
+ return !callback.call(context);
575
+ })) { return; }
576
+ // Stop polling
577
+ clearInterval(watcher);
578
+
579
+ // If this is the last async promise, end the async test
580
+ if (--countAsync === 0) {
581
+ Test.adapter.asyncEnd();
582
+ }
583
+
584
+ // Synchronously resolve the promise
585
+ run(null, resolve, value);
586
+ }, 10);
587
+ });
588
+
589
+ }
590
+
591
+
592
+ /**
593
+ * Loads a route, sets up any controllers, and renders any templates associated
594
+ * with the route as though a real user had triggered the route change while
595
+ * using your app.
596
+ *
597
+ * Example:
598
+ *
599
+ * ```javascript
600
+ * visit('posts/index').then(function() {
601
+ * // assert something
602
+ * });
603
+ * ```
604
+ *
605
+ * @method visit
606
+ * @param {String} url the name of the route
607
+ * @return {RSVP.Promise}
608
+ */
609
+ asyncHelper('visit', visit);
610
+
611
+ /**
612
+ * Clicks an element and triggers any actions triggered by the element's `click`
613
+ * event.
614
+ *
615
+ * Example:
616
+ *
617
+ * ```javascript
618
+ * click('.some-jQuery-selector').then(function() {
619
+ * // assert something
620
+ * });
621
+ * ```
622
+ *
623
+ * @method click
624
+ * @param {String} selector jQuery selector for finding element on the DOM
625
+ * @return {RSVP.Promise}
626
+ */
627
+ asyncHelper('click', click);
628
+
629
+ /**
630
+ * Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode
631
+ *
632
+ * Example:
633
+ *
634
+ * ```javascript
635
+ * keyEvent('.some-jQuery-selector', 'keypress', 13).then(function() {
636
+ * // assert something
637
+ * });
638
+ * ```
639
+ *
640
+ * @method keyEvent
641
+ * @param {String} selector jQuery selector for finding element on the DOM
642
+ * @param {String} type the type of key event, e.g. `keypress`, `keydown`, `keyup`
643
+ * @param {Number} keyCode the keyCode of the simulated key event
644
+ * @return {RSVP.Promise}
645
+ * @since 1.5.0
646
+ */
647
+ asyncHelper('keyEvent', keyEvent);
648
+
649
+ /**
650
+ * Fills in an input element with some text.
651
+ *
652
+ * Example:
653
+ *
654
+ * ```javascript
655
+ * fillIn('#email', 'you@example.com').then(function() {
656
+ * // assert something
657
+ * });
658
+ * ```
659
+ *
660
+ * @method fillIn
661
+ * @param {String} selector jQuery selector finding an input element on the DOM
662
+ * to fill text with
663
+ * @param {String} text text to place inside the input element
664
+ * @return {RSVP.Promise}
665
+ */
666
+ asyncHelper('fillIn', fillIn);
667
+
668
+ /**
669
+ * Finds an element in the context of the app's container element. A simple alias
670
+ * for `app.$(selector)`.
671
+ *
672
+ * Example:
673
+ *
674
+ * ```javascript
675
+ * var $el = find('.my-selector');
676
+ * ```
677
+ *
678
+ * @method find
679
+ * @param {String} selector jQuery string selector for element lookup
680
+ * @return {Object} jQuery object representing the results of the query
681
+ */
682
+ helper('find', find);
683
+
684
+ /**
685
+ * Like `find`, but throws an error if the element selector returns no results.
686
+ *
687
+ * Example:
688
+ *
689
+ * ```javascript
690
+ * var $el = findWithAssert('.doesnt-exist'); // throws error
691
+ * ```
692
+ *
693
+ * @method findWithAssert
694
+ * @param {String} selector jQuery selector string for finding an element within
695
+ * the DOM
696
+ * @return {Object} jQuery object representing the results of the query
697
+ * @throws {Error} throws error if jQuery object returned has a length of 0
698
+ */
699
+ helper('findWithAssert', findWithAssert);
700
+
701
+ /**
702
+ Causes the run loop to process any pending events. This is used to ensure that
703
+ any async operations from other helpers (or your assertions) have been processed.
704
+
705
+ This is most often used as the return value for the helper functions (see 'click',
706
+ 'fillIn','visit',etc).
707
+
708
+ Example:
709
+
710
+ ```javascript
711
+ Ember.Test.registerAsyncHelper('loginUser', function(app, username, password) {
712
+ visit('secured/path/here')
713
+ .fillIn('#username', username)
714
+ .fillIn('#password', username)
715
+ .click('.submit')
716
+
717
+ return app.testHelpers.wait();
718
+ });
719
+
720
+ @method wait
721
+ @param {Object} value The value to be returned.
722
+ @return {RSVP.Promise}
723
+ */
724
+ asyncHelper('wait', wait);
725
+ asyncHelper('andThen', andThen);
726
+
727
+
728
+ /**
729
+ Returns the currently active route name.
730
+
731
+ Example:
732
+
733
+ ```javascript
734
+ function validateRouteName(){
735
+ equal(currentRouteName(), 'some.path', "correct route was transitioned into.");
736
+ }
737
+
738
+ visit('/some/path').then(validateRouteName)
739
+ ```
740
+
741
+ @method currentRouteName
742
+ @return {Object} The name of the currently active route.
743
+ @since 1.5.0
744
+ */
745
+ helper('currentRouteName', currentRouteName);
746
+
747
+ /**
748
+ Returns the current path.
749
+
750
+ Example:
751
+
752
+ ```javascript
753
+ function validateURL(){
754
+ equal(currentPath(), 'some.path.index', "correct path was transitioned into.");
755
+ }
756
+
757
+ click('#some-link-id').then(validateURL);
758
+ ```
759
+
760
+ @method currentPath
761
+ @return {Object} The currently active path.
762
+ @since 1.5.0
763
+ */
764
+ helper('currentPath', currentPath);
765
+
766
+ /**
767
+ Returns the current URL.
768
+
769
+ Example:
770
+
771
+ ```javascript
772
+ function validateURL(){
773
+ equal(currentURL(), '/some/path', "correct URL was transitioned into.");
774
+ }
775
+
776
+ click('#some-link-id').then(validateURL);
777
+ ```
778
+
779
+ @method currentURL
780
+ @return {Object} The currently active URL.
781
+ @since 1.5.0
782
+ */
783
+ helper('currentURL', currentURL);
784
+
785
+ /**
786
+ Triggers the given DOM event on the element identified by the provided selector.
787
+
788
+ Example:
789
+
790
+ ```javascript
791
+ triggerEvent('#some-elem-id', 'blur');
792
+ ```
793
+
794
+ This is actually used internally by the `keyEvent` helper like so:
795
+
796
+ ```javascript
797
+ triggerEvent('#some-elem-id', 'keypress', { keyCode: 13 });
798
+ ```
799
+
800
+ @method triggerEvent
801
+ @param {String} selector jQuery selector for finding element on the DOM
802
+ @param {String} [context] jQuery selector that will limit the selector
803
+ argument to find only within the context's children
804
+ @param {String} type The event type to be triggered.
805
+ @param {Object} [options] The options to be passed to jQuery.Event.
806
+ @return {RSVP.Promise}
807
+ @since 1.5.0
808
+ */
809
+ asyncHelper('triggerEvent', triggerEvent);
810
+ });
811
+ enifed("ember-testing/initializers",
812
+ ["ember-runtime/system/lazy_load"],
813
+ function(__dependency1__) {
814
+ "use strict";
815
+ var onLoad = __dependency1__.onLoad;
816
+
817
+ var name = 'deferReadiness in `testing` mode';
818
+
819
+ onLoad('Ember.Application', function(Application) {
820
+ if (!Application.initializers[name]) {
821
+ Application.initializer({
822
+ name: name,
823
+
824
+ initialize: function(container, application){
825
+ if (application.testing) {
826
+ application.deferReadiness();
827
+ }
828
+ }
829
+ });
830
+ }
831
+ });
832
+ });
833
+ enifed("ember-testing/setup_for_testing",
834
+ ["ember-metal/core","ember-testing/adapters/qunit","ember-views/system/jquery","exports"],
835
+ function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
836
+ "use strict";
837
+ var Ember = __dependency1__["default"];
838
+ // import Test from "ember-testing/test"; // ES6TODO: fix when cycles are supported
839
+ var QUnitAdapter = __dependency2__["default"];
840
+ var jQuery = __dependency3__["default"];
841
+
842
+ var Test, requests;
843
+
844
+ function incrementAjaxPendingRequests(_, xhr){
845
+ requests.push(xhr);
846
+ Test.pendingAjaxRequests = requests.length;
847
+ }
848
+
849
+ function decrementAjaxPendingRequests(_, xhr){
850
+ for (var i=0;i<requests.length;i++) {
851
+ if (xhr === requests[i]) {
852
+ requests.splice(i, 1);
853
+ }
854
+ }
855
+ Test.pendingAjaxRequests = requests.length;
856
+ }
857
+
858
+ /**
859
+ Sets Ember up for testing. This is useful to perform
860
+ basic setup steps in order to unit test.
861
+
862
+ Use `App.setupForTesting` to perform integration tests (full
863
+ application testing).
864
+
865
+ @method setupForTesting
866
+ @namespace Ember
867
+ @since 1.5.0
868
+ */
869
+ __exports__["default"] = function setupForTesting() {
870
+ if (!Test) { Test = requireModule('ember-testing/test')['default']; }
871
+
872
+ Ember.testing = true;
873
+
874
+ // if adapter is not manually set default to QUnit
875
+ if (!Test.adapter) {
876
+ Test.adapter = QUnitAdapter.create();
877
+ }
878
+
879
+ requests = [];
880
+ Test.pendingAjaxRequests = requests.length;
881
+
882
+ jQuery(document).off('ajaxSend', incrementAjaxPendingRequests);
883
+ jQuery(document).off('ajaxComplete', decrementAjaxPendingRequests);
884
+ jQuery(document).on('ajaxSend', incrementAjaxPendingRequests);
885
+ jQuery(document).on('ajaxComplete', decrementAjaxPendingRequests);
886
+ }
887
+ });
888
+ enifed("ember-testing/support",
889
+ ["ember-metal/core","ember-views/system/jquery"],
890
+ function(__dependency1__, __dependency2__) {
891
+ "use strict";
892
+ var Ember = __dependency1__["default"];
893
+ var jQuery = __dependency2__["default"];
894
+
895
+ /**
896
+ @module ember
897
+ @submodule ember-testing
898
+ */
899
+
900
+ var $ = jQuery;
901
+
902
+ /**
903
+ This method creates a checkbox and triggers the click event to fire the
904
+ passed in handler. It is used to correct for a bug in older versions
905
+ of jQuery (e.g 1.8.3).
906
+
907
+ @private
908
+ @method testCheckboxClick
909
+ */
910
+ function testCheckboxClick(handler) {
911
+ $('<input type="checkbox">')
912
+ .css({ position: 'absolute', left: '-1000px', top: '-1000px' })
913
+ .appendTo('body')
914
+ .on('click', handler)
915
+ .trigger('click')
916
+ .remove();
917
+ }
918
+
919
+ $(function() {
920
+ /*
921
+ Determine whether a checkbox checked using jQuery's "click" method will have
922
+ the correct value for its checked property.
923
+
924
+ If we determine that the current jQuery version exhibits this behavior,
925
+ patch it to work correctly as in the commit for the actual fix:
926
+ https://github.com/jquery/jquery/commit/1fb2f92.
927
+ */
928
+ testCheckboxClick(function() {
929
+ if (!this.checked && !$.event.special.click) {
930
+ $.event.special.click = {
931
+ // For checkbox, fire native event so checked state will be right
932
+ trigger: function() {
933
+ if ($.nodeName( this, "input" ) && this.type === "checkbox" && this.click) {
934
+ this.click();
935
+ return false;
936
+ }
937
+ }
938
+ };
939
+ }
940
+ });
941
+
942
+ // Try again to verify that the patch took effect or blow up.
943
+ testCheckboxClick(function() {
944
+ Ember.warn("clicked checkboxes should be checked! the jQuery patch didn't work", this.checked);
945
+ });
946
+ });
947
+ });
948
+ enifed("ember-testing/test",
949
+ ["ember-metal/core","ember-metal/run_loop","ember-metal/platform","ember-runtime/compare","ember-runtime/ext/rsvp","ember-testing/setup_for_testing","ember-application/system/application","exports"],
950
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __exports__) {
951
+ "use strict";
952
+ var Ember = __dependency1__["default"];
953
+ var emberRun = __dependency2__["default"];
954
+ var create = __dependency3__.create;
955
+ var compare = __dependency4__["default"];
956
+ var RSVP = __dependency5__["default"];
957
+ var setupForTesting = __dependency6__["default"];
958
+ var EmberApplication = __dependency7__["default"];
959
+
960
+ /**
961
+ @module ember
962
+ @submodule ember-testing
963
+ */
964
+ var slice = [].slice;
965
+ var helpers = {};
966
+ var injectHelpersCallbacks = [];
967
+
968
+ /**
969
+ This is a container for an assortment of testing related functionality:
970
+
971
+ * Choose your default test adapter (for your framework of choice).
972
+ * Register/Unregister additional test helpers.
973
+ * Setup callbacks to be fired when the test helpers are injected into
974
+ your application.
975
+
976
+ @class Test
977
+ @namespace Ember
978
+ */
979
+ var Test = {
980
+ /**
981
+ Hash containing all known test helpers.
982
+
983
+ @property _helpers
984
+ @private
985
+ @since 1.7.0
986
+ */
987
+ _helpers: helpers,
988
+
989
+ /**
990
+ `registerHelper` is used to register a test helper that will be injected
991
+ when `App.injectTestHelpers` is called.
992
+
993
+ The helper method will always be called with the current Application as
994
+ the first parameter.
995
+
996
+ For example:
997
+
998
+ ```javascript
999
+ Ember.Test.registerHelper('boot', function(app) {
1000
+ Ember.run(app, app.advanceReadiness);
1001
+ });
1002
+ ```
1003
+
1004
+ This helper can later be called without arguments because it will be
1005
+ called with `app` as the first parameter.
1006
+
1007
+ ```javascript
1008
+ App = Ember.Application.create();
1009
+ App.injectTestHelpers();
1010
+ boot();
1011
+ ```
1012
+
1013
+ @public
1014
+ @method registerHelper
1015
+ @param {String} name The name of the helper method to add.
1016
+ @param {Function} helperMethod
1017
+ @param options {Object}
1018
+ */
1019
+ registerHelper: function(name, helperMethod) {
1020
+ helpers[name] = {
1021
+ method: helperMethod,
1022
+ meta: { wait: false }
1023
+ };
1024
+ },
1025
+
1026
+ /**
1027
+ `registerAsyncHelper` is used to register an async test helper that will be injected
1028
+ when `App.injectTestHelpers` is called.
1029
+
1030
+ The helper method will always be called with the current Application as
1031
+ the first parameter.
1032
+
1033
+ For example:
1034
+
1035
+ ```javascript
1036
+ Ember.Test.registerAsyncHelper('boot', function(app) {
1037
+ Ember.run(app, app.advanceReadiness);
1038
+ });
1039
+ ```
1040
+
1041
+ The advantage of an async helper is that it will not run
1042
+ until the last async helper has completed. All async helpers
1043
+ after it will wait for it complete before running.
1044
+
1045
+
1046
+ For example:
1047
+
1048
+ ```javascript
1049
+ Ember.Test.registerAsyncHelper('deletePost', function(app, postId) {
1050
+ click('.delete-' + postId);
1051
+ });
1052
+
1053
+ // ... in your test
1054
+ visit('/post/2');
1055
+ deletePost(2);
1056
+ visit('/post/3');
1057
+ deletePost(3);
1058
+ ```
1059
+
1060
+ @public
1061
+ @method registerAsyncHelper
1062
+ @param {String} name The name of the helper method to add.
1063
+ @param {Function} helperMethod
1064
+ @since 1.2.0
1065
+ */
1066
+ registerAsyncHelper: function(name, helperMethod) {
1067
+ helpers[name] = {
1068
+ method: helperMethod,
1069
+ meta: { wait: true }
1070
+ };
1071
+ },
1072
+
1073
+ /**
1074
+ Remove a previously added helper method.
1075
+
1076
+ Example:
1077
+
1078
+ ```javascript
1079
+ Ember.Test.unregisterHelper('wait');
1080
+ ```
1081
+
1082
+ @public
1083
+ @method unregisterHelper
1084
+ @param {String} name The helper to remove.
1085
+ */
1086
+ unregisterHelper: function(name) {
1087
+ delete helpers[name];
1088
+ delete Test.Promise.prototype[name];
1089
+ },
1090
+
1091
+ /**
1092
+ Used to register callbacks to be fired whenever `App.injectTestHelpers`
1093
+ is called.
1094
+
1095
+ The callback will receive the current application as an argument.
1096
+
1097
+ Example:
1098
+
1099
+ ```javascript
1100
+ Ember.Test.onInjectHelpers(function() {
1101
+ Ember.$(document).ajaxSend(function() {
1102
+ Test.pendingAjaxRequests++;
1103
+ });
1104
+
1105
+ Ember.$(document).ajaxComplete(function() {
1106
+ Test.pendingAjaxRequests--;
1107
+ });
1108
+ });
1109
+ ```
1110
+
1111
+ @public
1112
+ @method onInjectHelpers
1113
+ @param {Function} callback The function to be called.
1114
+ */
1115
+ onInjectHelpers: function(callback) {
1116
+ injectHelpersCallbacks.push(callback);
1117
+ },
1118
+
1119
+ /**
1120
+ This returns a thenable tailored for testing. It catches failed
1121
+ `onSuccess` callbacks and invokes the `Ember.Test.adapter.exception`
1122
+ callback in the last chained then.
1123
+
1124
+ This method should be returned by async helpers such as `wait`.
1125
+
1126
+ @public
1127
+ @method promise
1128
+ @param {Function} resolver The function used to resolve the promise.
1129
+ */
1130
+ promise: function(resolver) {
1131
+ return new Test.Promise(resolver);
1132
+ },
1133
+
1134
+ /**
1135
+ Used to allow ember-testing to communicate with a specific testing
1136
+ framework.
1137
+
1138
+ You can manually set it before calling `App.setupForTesting()`.
1139
+
1140
+ Example:
1141
+
1142
+ ```javascript
1143
+ Ember.Test.adapter = MyCustomAdapter.create()
1144
+ ```
1145
+
1146
+ If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`.
1147
+
1148
+ @public
1149
+ @property adapter
1150
+ @type {Class} The adapter to be used.
1151
+ @default Ember.Test.QUnitAdapter
1152
+ */
1153
+ adapter: null,
1154
+
1155
+ /**
1156
+ Replacement for `Ember.RSVP.resolve`
1157
+ The only difference is this uses
1158
+ an instance of `Ember.Test.Promise`
1159
+
1160
+ @public
1161
+ @method resolve
1162
+ @param {Mixed} The value to resolve
1163
+ @since 1.2.0
1164
+ */
1165
+ resolve: function(val) {
1166
+ return Test.promise(function(resolve) {
1167
+ return resolve(val);
1168
+ });
1169
+ },
1170
+
1171
+ /**
1172
+ This allows ember-testing to play nicely with other asynchronous
1173
+ events, such as an application that is waiting for a CSS3
1174
+ transition or an IndexDB transaction.
1175
+
1176
+ For example:
1177
+
1178
+ ```javascript
1179
+ Ember.Test.registerWaiter(function() {
1180
+ return myPendingTransactions() == 0;
1181
+ });
1182
+ ```
1183
+ The `context` argument allows you to optionally specify the `this`
1184
+ with which your callback will be invoked.
1185
+
1186
+ For example:
1187
+
1188
+ ```javascript
1189
+ Ember.Test.registerWaiter(MyDB, MyDB.hasPendingTransactions);
1190
+ ```
1191
+
1192
+ @public
1193
+ @method registerWaiter
1194
+ @param {Object} context (optional)
1195
+ @param {Function} callback
1196
+ @since 1.2.0
1197
+ */
1198
+ registerWaiter: function(context, callback) {
1199
+ if (arguments.length === 1) {
1200
+ callback = context;
1201
+ context = null;
1202
+ }
1203
+ if (!this.waiters) {
1204
+ this.waiters = Ember.A();
1205
+ }
1206
+ this.waiters.push([context, callback]);
1207
+ },
1208
+ /**
1209
+ `unregisterWaiter` is used to unregister a callback that was
1210
+ registered with `registerWaiter`.
1211
+
1212
+ @public
1213
+ @method unregisterWaiter
1214
+ @param {Object} context (optional)
1215
+ @param {Function} callback
1216
+ @since 1.2.0
1217
+ */
1218
+ unregisterWaiter: function(context, callback) {
1219
+ var pair;
1220
+ if (!this.waiters) { return; }
1221
+ if (arguments.length === 1) {
1222
+ callback = context;
1223
+ context = null;
1224
+ }
1225
+ pair = [context, callback];
1226
+ this.waiters = Ember.A(this.waiters.filter(function(elt) {
1227
+ return compare(elt, pair)!==0;
1228
+ }));
1229
+ }
1230
+ };
1231
+
1232
+ function helper(app, name) {
1233
+ var fn = helpers[name].method;
1234
+ var meta = helpers[name].meta;
1235
+
1236
+ return function() {
1237
+ var args = slice.call(arguments);
1238
+ var lastPromise = Test.lastPromise;
1239
+
1240
+ args.unshift(app);
1241
+
1242
+ // some helpers are not async and
1243
+ // need to return a value immediately.
1244
+ // example: `find`
1245
+ if (!meta.wait) {
1246
+ return fn.apply(app, args);
1247
+ }
1248
+
1249
+ if (!lastPromise) {
1250
+ // It's the first async helper in current context
1251
+ lastPromise = fn.apply(app, args);
1252
+ } else {
1253
+ // wait for last helper's promise to resolve
1254
+ // and then execute
1255
+ run(function() {
1256
+ lastPromise = Test.resolve(lastPromise).then(function() {
1257
+ return fn.apply(app, args);
1258
+ });
1259
+ });
1260
+ }
1261
+
1262
+ return lastPromise;
1263
+ };
1264
+ }
1265
+
1266
+ function run(fn) {
1267
+ if (!emberRun.currentRunLoop) {
1268
+ emberRun(fn);
1269
+ } else {
1270
+ fn();
1271
+ }
1272
+ }
1273
+
1274
+ EmberApplication.reopen({
1275
+ /**
1276
+ This property contains the testing helpers for the current application. These
1277
+ are created once you call `injectTestHelpers` on your `Ember.Application`
1278
+ instance. The included helpers are also available on the `window` object by
1279
+ default, but can be used from this object on the individual application also.
1280
+
1281
+ @property testHelpers
1282
+ @type {Object}
1283
+ @default {}
1284
+ */
1285
+ testHelpers: {},
1286
+
1287
+ /**
1288
+ This property will contain the original methods that were registered
1289
+ on the `helperContainer` before `injectTestHelpers` is called.
1290
+
1291
+ When `removeTestHelpers` is called, these methods are restored to the
1292
+ `helperContainer`.
1293
+
1294
+ @property originalMethods
1295
+ @type {Object}
1296
+ @default {}
1297
+ @private
1298
+ @since 1.3.0
1299
+ */
1300
+ originalMethods: {},
1301
+
1302
+
1303
+ /**
1304
+ This property indicates whether or not this application is currently in
1305
+ testing mode. This is set when `setupForTesting` is called on the current
1306
+ application.
1307
+
1308
+ @property testing
1309
+ @type {Boolean}
1310
+ @default false
1311
+ @since 1.3.0
1312
+ */
1313
+ testing: false,
1314
+
1315
+ /**
1316
+ This hook defers the readiness of the application, so that you can start
1317
+ the app when your tests are ready to run. It also sets the router's
1318
+ location to 'none', so that the window's location will not be modified
1319
+ (preventing both accidental leaking of state between tests and interference
1320
+ with your testing framework).
1321
+
1322
+ Example:
1323
+
1324
+ ```
1325
+ App.setupForTesting();
1326
+ ```
1327
+
1328
+ @method setupForTesting
1329
+ */
1330
+ setupForTesting: function() {
1331
+ setupForTesting();
1332
+
1333
+ this.testing = true;
1334
+
1335
+ this.Router.reopen({
1336
+ location: 'none'
1337
+ });
1338
+ },
1339
+
1340
+ /**
1341
+ This will be used as the container to inject the test helpers into. By
1342
+ default the helpers are injected into `window`.
1343
+
1344
+ @property helperContainer
1345
+ @type {Object} The object to be used for test helpers.
1346
+ @default window
1347
+ @since 1.2.0
1348
+ */
1349
+ helperContainer: window,
1350
+
1351
+ /**
1352
+ This injects the test helpers into the `helperContainer` object. If an object is provided
1353
+ it will be used as the helperContainer. If `helperContainer` is not set it will default
1354
+ to `window`. If a function of the same name has already been defined it will be cached
1355
+ (so that it can be reset if the helper is removed with `unregisterHelper` or
1356
+ `removeTestHelpers`).
1357
+
1358
+ Any callbacks registered with `onInjectHelpers` will be called once the
1359
+ helpers have been injected.
1360
+
1361
+ Example:
1362
+ ```
1363
+ App.injectTestHelpers();
1364
+ ```
1365
+
1366
+ @method injectTestHelpers
1367
+ */
1368
+ injectTestHelpers: function(helperContainer) {
1369
+ if (helperContainer) { this.helperContainer = helperContainer; }
1370
+
1371
+ this.testHelpers = {};
1372
+ for (var name in helpers) {
1373
+ this.originalMethods[name] = this.helperContainer[name];
1374
+ this.testHelpers[name] = this.helperContainer[name] = helper(this, name);
1375
+ protoWrap(Test.Promise.prototype, name, helper(this, name), helpers[name].meta.wait);
1376
+ }
1377
+
1378
+ for(var i = 0, l = injectHelpersCallbacks.length; i < l; i++) {
1379
+ injectHelpersCallbacks[i](this);
1380
+ }
1381
+ },
1382
+
1383
+ /**
1384
+ This removes all helpers that have been registered, and resets and functions
1385
+ that were overridden by the helpers.
1386
+
1387
+ Example:
1388
+
1389
+ ```javascript
1390
+ App.removeTestHelpers();
1391
+ ```
1392
+
1393
+ @public
1394
+ @method removeTestHelpers
1395
+ */
1396
+ removeTestHelpers: function() {
1397
+ for (var name in helpers) {
1398
+ this.helperContainer[name] = this.originalMethods[name];
1399
+ delete this.testHelpers[name];
1400
+ delete this.originalMethods[name];
1401
+ }
1402
+ }
1403
+ });
1404
+
1405
+ // This method is no longer needed
1406
+ // But still here for backwards compatibility
1407
+ // of helper chaining
1408
+ function protoWrap(proto, name, callback, isAsync) {
1409
+ proto[name] = function() {
1410
+ var args = arguments;
1411
+ if (isAsync) {
1412
+ return callback.apply(this, args);
1413
+ } else {
1414
+ return this.then(function() {
1415
+ return callback.apply(this, args);
1416
+ });
1417
+ }
1418
+ };
1419
+ }
1420
+
1421
+ Test.Promise = function() {
1422
+ RSVP.Promise.apply(this, arguments);
1423
+ Test.lastPromise = this;
1424
+ };
1425
+
1426
+ Test.Promise.prototype = create(RSVP.Promise.prototype);
1427
+ Test.Promise.prototype.constructor = Test.Promise;
1428
+
1429
+ // Patch `then` to isolate async methods
1430
+ // specifically `Ember.Test.lastPromise`
1431
+ var originalThen = RSVP.Promise.prototype.then;
1432
+ Test.Promise.prototype.then = function(onSuccess, onFailure) {
1433
+ return originalThen.call(this, function(val) {
1434
+ return isolate(onSuccess, val);
1435
+ }, onFailure);
1436
+ };
1437
+
1438
+ // This method isolates nested async methods
1439
+ // so that they don't conflict with other last promises.
1440
+ //
1441
+ // 1. Set `Ember.Test.lastPromise` to null
1442
+ // 2. Invoke method
1443
+ // 3. Return the last promise created during method
1444
+ // 4. Restore `Ember.Test.lastPromise` to original value
1445
+ function isolate(fn, val) {
1446
+ var value, lastPromise;
1447
+
1448
+ // Reset lastPromise for nested helpers
1449
+ Test.lastPromise = null;
1450
+
1451
+ value = fn(val);
1452
+
1453
+ lastPromise = Test.lastPromise;
1454
+
1455
+ // If the method returned a promise
1456
+ // return that promise. If not,
1457
+ // return the last async helper's promise
1458
+ if ((value && (value instanceof Test.Promise)) || !lastPromise) {
1459
+ return value;
1460
+ } else {
1461
+ run(function() {
1462
+ lastPromise = Test.resolve(lastPromise).then(function() {
1463
+ return value;
1464
+ });
1465
+ });
1466
+ return lastPromise;
1467
+ }
1468
+ }
1469
+
1470
+ __exports__["default"] = Test;
1471
+ });
1472
+ requireModule("ember-testing");
1473
+
1474
+ })();