UNPKG

79.1 kBJavaScriptView Raw
1(function() {
2/*!
3 * @overview Ember - JavaScript Application Framework
4 * @copyright Copyright 2011-2020 Tilde Inc. and contributors
5 * Portions Copyright 2006-2011 Strobe Inc.
6 * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
7 * @license Licensed under MIT license
8 * See https://raw.github.com/emberjs/ember.js/master/LICENSE
9 * @version 3.21.3
10 */
11/*globals process */
12var define, require, Ember; // Used in @ember/-internals/environment/lib/global.js
13
14
15mainContext = this; // eslint-disable-line no-undef
16
17(function () {
18 var registry;
19 var seen;
20
21 function missingModule(name, referrerName) {
22 if (referrerName) {
23 throw new Error('Could not find module ' + name + ' required by: ' + referrerName);
24 } else {
25 throw new Error('Could not find module ' + name);
26 }
27 }
28
29 function internalRequire(_name, referrerName) {
30 var name = _name;
31 var mod = registry[name];
32
33 if (!mod) {
34 name = name + '/index';
35 mod = registry[name];
36 }
37
38 var exports = seen[name];
39
40 if (exports !== undefined) {
41 return exports;
42 }
43
44 exports = seen[name] = {};
45
46 if (!mod) {
47 missingModule(_name, referrerName);
48 }
49
50 var deps = mod.deps;
51 var callback = mod.callback;
52 var reified = new Array(deps.length);
53
54 for (var i = 0; i < deps.length; i++) {
55 if (deps[i] === 'exports') {
56 reified[i] = exports;
57 } else if (deps[i] === 'require') {
58 reified[i] = require;
59 } else {
60 reified[i] = internalRequire(deps[i], name);
61 }
62 }
63
64 callback.apply(this, reified);
65 return exports;
66 }
67
68 var isNode = typeof window === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
69
70 if (!isNode) {
71 Ember = this.Ember = this.Ember || {};
72 }
73
74 if (typeof Ember === 'undefined') {
75 Ember = {};
76 }
77
78 if (typeof Ember.__loader === 'undefined') {
79 registry = Object.create(null);
80 seen = Object.create(null);
81
82 define = function (name, deps, callback) {
83 var value = {};
84
85 if (!callback) {
86 value.deps = [];
87 value.callback = deps;
88 } else {
89 value.deps = deps;
90 value.callback = callback;
91 }
92
93 registry[name] = value;
94 };
95
96 require = function (name) {
97 return internalRequire(name, null);
98 }; // setup `require` module
99
100
101 require['default'] = require;
102
103 require.has = function registryHas(moduleName) {
104 return Boolean(registry[moduleName]) || Boolean(registry[moduleName + '/index']);
105 };
106
107 require._eak_seen = registry;
108 Ember.__loader = {
109 define: define,
110 require: require,
111 registry: registry
112 };
113 } else {
114 define = Ember.__loader.define;
115 require = Ember.__loader.require;
116 }
117})();
118define("@ember/debug/index", ["exports", "@ember/-internals/browser-environment", "@ember/error", "@ember/debug/lib/deprecate", "@ember/debug/lib/testing", "@ember/debug/lib/warn", "@ember/debug/lib/capture-render-tree"], function (_exports, _browserEnvironment, _error, _deprecate2, _testing, _warn2, _captureRenderTree) {
119 "use strict";
120
121 Object.defineProperty(_exports, "__esModule", {
122 value: true
123 });
124 Object.defineProperty(_exports, "registerDeprecationHandler", {
125 enumerable: true,
126 get: function () {
127 return _deprecate2.registerHandler;
128 }
129 });
130 Object.defineProperty(_exports, "isTesting", {
131 enumerable: true,
132 get: function () {
133 return _testing.isTesting;
134 }
135 });
136 Object.defineProperty(_exports, "setTesting", {
137 enumerable: true,
138 get: function () {
139 return _testing.setTesting;
140 }
141 });
142 Object.defineProperty(_exports, "registerWarnHandler", {
143 enumerable: true,
144 get: function () {
145 return _warn2.registerHandler;
146 }
147 });
148 Object.defineProperty(_exports, "captureRenderTree", {
149 enumerable: true,
150 get: function () {
151 return _captureRenderTree.default;
152 }
153 });
154 _exports._warnIfUsingStrippedFeatureFlags = _exports.getDebugFunction = _exports.setDebugFunction = _exports.deprecateFunc = _exports.runInDebug = _exports.debugFreeze = _exports.debugSeal = _exports.deprecate = _exports.debug = _exports.warn = _exports.info = _exports.assert = void 0;
155
156 // These are the default production build versions:
157 var noop = () => {};
158
159 var assert = noop;
160 _exports.assert = assert;
161 var info = noop;
162 _exports.info = info;
163 var warn = noop;
164 _exports.warn = warn;
165 var debug = noop;
166 _exports.debug = debug;
167 var deprecate = noop;
168 _exports.deprecate = deprecate;
169 var debugSeal = noop;
170 _exports.debugSeal = debugSeal;
171 var debugFreeze = noop;
172 _exports.debugFreeze = debugFreeze;
173 var runInDebug = noop;
174 _exports.runInDebug = runInDebug;
175 var setDebugFunction = noop;
176 _exports.setDebugFunction = setDebugFunction;
177 var getDebugFunction = noop;
178 _exports.getDebugFunction = getDebugFunction;
179
180 var deprecateFunc = function () {
181 return arguments[arguments.length - 1];
182 };
183
184 _exports.deprecateFunc = deprecateFunc;
185
186 if (true
187 /* DEBUG */
188 ) {
189 _exports.setDebugFunction = setDebugFunction = function (type, callback) {
190 switch (type) {
191 case 'assert':
192 return _exports.assert = assert = callback;
193
194 case 'info':
195 return _exports.info = info = callback;
196
197 case 'warn':
198 return _exports.warn = warn = callback;
199
200 case 'debug':
201 return _exports.debug = debug = callback;
202
203 case 'deprecate':
204 return _exports.deprecate = deprecate = callback;
205
206 case 'debugSeal':
207 return _exports.debugSeal = debugSeal = callback;
208
209 case 'debugFreeze':
210 return _exports.debugFreeze = debugFreeze = callback;
211
212 case 'runInDebug':
213 return _exports.runInDebug = runInDebug = callback;
214
215 case 'deprecateFunc':
216 return _exports.deprecateFunc = deprecateFunc = callback;
217 }
218 };
219
220 _exports.getDebugFunction = getDebugFunction = function (type) {
221 switch (type) {
222 case 'assert':
223 return assert;
224
225 case 'info':
226 return info;
227
228 case 'warn':
229 return warn;
230
231 case 'debug':
232 return debug;
233
234 case 'deprecate':
235 return deprecate;
236
237 case 'debugSeal':
238 return debugSeal;
239
240 case 'debugFreeze':
241 return debugFreeze;
242
243 case 'runInDebug':
244 return runInDebug;
245
246 case 'deprecateFunc':
247 return deprecateFunc;
248 }
249 };
250 }
251 /**
252 @module @ember/debug
253 */
254
255
256 if (true
257 /* DEBUG */
258 ) {
259 /**
260 Verify that a certain expectation is met, or throw a exception otherwise.
261 This is useful for communicating assumptions in the code to other human
262 readers as well as catching bugs that accidentally violates these
263 expectations.
264 Assertions are removed from production builds, so they can be freely added
265 for documentation and debugging purposes without worries of incuring any
266 performance penalty. However, because of that, they should not be used for
267 checks that could reasonably fail during normal usage. Furthermore, care
268 should be taken to avoid accidentally relying on side-effects produced from
269 evaluating the condition itself, since the code will not run in production.
270 ```javascript
271 import { assert } from '@ember/debug';
272 // Test for truthiness
273 assert('Must pass a string', typeof str === 'string');
274 // Fail unconditionally
275 assert('This code path should never be run');
276 ```
277 @method assert
278 @static
279 @for @ember/debug
280 @param {String} description Describes the expectation. This will become the
281 text of the Error thrown if the assertion fails.
282 @param {any} condition Must be truthy for the assertion to pass. If
283 falsy, an exception will be thrown.
284 @public
285 @since 1.0.0
286 */
287 setDebugFunction('assert', function assert(desc, test) {
288 if (!test) {
289 throw new _error.default(`Assertion Failed: ${desc}`);
290 }
291 });
292 /**
293 Display a debug notice.
294 Calls to this function are removed from production builds, so they can be
295 freely added for documentation and debugging purposes without worries of
296 incuring any performance penalty.
297 ```javascript
298 import { debug } from '@ember/debug';
299 debug('I\'m a debug notice!');
300 ```
301 @method debug
302 @for @ember/debug
303 @static
304 @param {String} message A debug message to display.
305 @public
306 */
307
308 setDebugFunction('debug', function debug(message) {
309 /* eslint-disable no-console */
310 if (console.debug) {
311 console.debug(`DEBUG: ${message}`);
312 } else {
313 console.log(`DEBUG: ${message}`);
314 }
315 /* eslint-ensable no-console */
316
317 });
318 /**
319 Display an info notice.
320 Calls to this function are removed from production builds, so they can be
321 freely added for documentation and debugging purposes without worries of
322 incuring any performance penalty.
323 @method info
324 @private
325 */
326
327 setDebugFunction('info', function info() {
328 console.info(...arguments);
329 /* eslint-disable-line no-console */
330 });
331 /**
332 @module @ember/debug
333 @public
334 */
335
336 /**
337 Alias an old, deprecated method with its new counterpart.
338 Display a deprecation warning with the provided message and a stack trace
339 (Chrome and Firefox only) when the assigned method is called.
340 Calls to this function are removed from production builds, so they can be
341 freely added for documentation and debugging purposes without worries of
342 incuring any performance penalty.
343 ```javascript
344 import { deprecateFunc } from '@ember/debug';
345 Ember.oldMethod = deprecateFunc('Please use the new, updated method', options, Ember.newMethod);
346 ```
347 @method deprecateFunc
348 @static
349 @for @ember/debug
350 @param {String} message A description of the deprecation.
351 @param {Object} [options] The options object for `deprecate`.
352 @param {Function} func The new function called to replace its deprecated counterpart.
353 @return {Function} A new function that wraps the original function with a deprecation warning
354 @private
355 */
356
357 setDebugFunction('deprecateFunc', function deprecateFunc(...args) {
358 if (args.length === 3) {
359 var [message, options, func] = args;
360 return function (...args) {
361 deprecate(message, false, options);
362 return func.apply(this, args);
363 };
364 } else {
365 var [_message, _func] = args;
366 return function () {
367 deprecate(_message);
368 return _func.apply(this, arguments);
369 };
370 }
371 });
372 /**
373 @module @ember/debug
374 @public
375 */
376
377 /**
378 Run a function meant for debugging.
379 Calls to this function are removed from production builds, so they can be
380 freely added for documentation and debugging purposes without worries of
381 incuring any performance penalty.
382 ```javascript
383 import Component from '@ember/component';
384 import { runInDebug } from '@ember/debug';
385 runInDebug(() => {
386 Component.reopen({
387 didInsertElement() {
388 console.log("I'm happy");
389 }
390 });
391 });
392 ```
393 @method runInDebug
394 @for @ember/debug
395 @static
396 @param {Function} func The function to be executed.
397 @since 1.5.0
398 @public
399 */
400
401 setDebugFunction('runInDebug', function runInDebug(func) {
402 func();
403 });
404 setDebugFunction('debugSeal', function debugSeal(obj) {
405 Object.seal(obj);
406 });
407 setDebugFunction('debugFreeze', function debugFreeze(obj) {
408 // re-freezing an already frozen object introduces a significant
409 // performance penalty on Chrome (tested through 59).
410 //
411 // See: https://bugs.chromium.org/p/v8/issues/detail?id=6450
412 if (!Object.isFrozen(obj)) {
413 Object.freeze(obj);
414 }
415 });
416 setDebugFunction('deprecate', _deprecate2.default);
417 setDebugFunction('warn', _warn2.default);
418 }
419
420 var _warnIfUsingStrippedFeatureFlags;
421
422 _exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags;
423
424 if (true
425 /* DEBUG */
426 && !(0, _testing.isTesting)()) {
427 if (typeof window !== 'undefined' && (_browserEnvironment.isFirefox || _browserEnvironment.isChrome) && window.addEventListener) {
428 window.addEventListener('load', () => {
429 if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) {
430 var downloadURL;
431
432 if (_browserEnvironment.isChrome) {
433 downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi';
434 } else if (_browserEnvironment.isFirefox) {
435 downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/';
436 }
437
438 debug(`For more advanced debugging, install the Ember Inspector from ${downloadURL}`);
439 }
440 }, false);
441 }
442 }
443});
444define("@ember/debug/lib/capture-render-tree", ["exports", "@glimmer/util"], function (_exports, _util) {
445 "use strict";
446
447 Object.defineProperty(_exports, "__esModule", {
448 value: true
449 });
450 _exports.default = captureRenderTree;
451
452 /**
453 @module @ember/debug
454 */
455
456 /**
457 Ember Inspector calls this function to capture the current render tree.
458
459 In production mode, this requires turning on `ENV._DEBUG_RENDER_TREE`
460 before loading Ember.
461
462 @private
463 @static
464 @method captureRenderTree
465 @for @ember/debug
466 @param app {ApplicationInstance} An `ApplicationInstance`.
467 @since 3.14.0
468 */
469 function captureRenderTree(app) {
470 var env = (0, _util.expect)(app.lookup('-environment:main'), 'BUG: owner is missing -environment:main');
471 var rendererType = env.isInteractive ? 'renderer:-dom' : 'renderer:-inert';
472 var renderer = (0, _util.expect)(app.lookup(rendererType), `BUG: owner is missing ${rendererType}`);
473 return renderer.debugRenderTree.capture();
474 }
475});
476define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment", "@ember/debug/index", "@ember/debug/lib/handlers"], function (_exports, _environment, _index, _handlers) {
477 "use strict";
478
479 Object.defineProperty(_exports, "__esModule", {
480 value: true
481 });
482 _exports.missingOptionsUntilDeprecation = _exports.missingOptionsIdDeprecation = _exports.missingOptionsDeprecation = _exports.registerHandler = _exports.default = void 0;
483
484 /**
485 @module @ember/debug
486 @public
487 */
488
489 /**
490 Allows for runtime registration of handler functions that override the default deprecation behavior.
491 Deprecations are invoked by calls to [@ember/debug/deprecate](/ember/release/classes/@ember%2Fdebug/methods/deprecate?anchor=deprecate).
492 The following example demonstrates its usage by registering a handler that throws an error if the
493 message contains the word "should", otherwise defers to the default handler.
494
495 ```javascript
496 import { registerDeprecationHandler } from '@ember/debug';
497
498 registerDeprecationHandler((message, options, next) => {
499 if (message.indexOf('should') !== -1) {
500 throw new Error(`Deprecation message with should: ${message}`);
501 } else {
502 // defer to whatever handler was registered before this one
503 next(message, options);
504 }
505 });
506 ```
507
508 The handler function takes the following arguments:
509
510 <ul>
511 <li> <code>message</code> - The message received from the deprecation call.</li>
512 <li> <code>options</code> - An object passed in with the deprecation call containing additional information including:</li>
513 <ul>
514 <li> <code>id</code> - An id of the deprecation in the form of <code>package-name.specific-deprecation</code>.</li>
515 <li> <code>until</code> - The Ember version number the feature and deprecation will be removed in.</li>
516 </ul>
517 <li> <code>next</code> - A function that calls into the previously registered handler.</li>
518 </ul>
519
520 @public
521 @static
522 @method registerDeprecationHandler
523 @for @ember/debug
524 @param handler {Function} A function to handle deprecation calls.
525 @since 2.1.0
526 */
527 var registerHandler = () => {};
528
529 _exports.registerHandler = registerHandler;
530 var missingOptionsDeprecation;
531 _exports.missingOptionsDeprecation = missingOptionsDeprecation;
532 var missingOptionsIdDeprecation;
533 _exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation;
534 var missingOptionsUntilDeprecation;
535 _exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation;
536
537 var deprecate = () => {};
538
539 if (true
540 /* DEBUG */
541 ) {
542 _exports.registerHandler = registerHandler = function registerHandler(handler) {
543 (0, _handlers.registerHandler)('deprecate', handler);
544 };
545
546 var formatMessage = function formatMessage(_message, options) {
547 var message = _message;
548
549 if (options && options.id) {
550 message = message + ` [deprecation id: ${options.id}]`;
551 }
552
553 if (options && options.url) {
554 message += ` See ${options.url} for more details.`;
555 }
556
557 return message;
558 };
559
560 registerHandler(function logDeprecationToConsole(message, options) {
561 var updatedMessage = formatMessage(message, options);
562 console.warn(`DEPRECATION: ${updatedMessage}`); // eslint-disable-line no-console
563 });
564 var captureErrorForStack;
565
566 if (new Error().stack) {
567 captureErrorForStack = () => new Error();
568 } else {
569 captureErrorForStack = () => {
570 try {
571 __fail__.fail();
572 } catch (e) {
573 return e;
574 }
575 };
576 }
577
578 registerHandler(function logDeprecationStackTrace(message, options, next) {
579 if (_environment.ENV.LOG_STACKTRACE_ON_DEPRECATION) {
580 var stackStr = '';
581 var error = captureErrorForStack();
582 var stack;
583
584 if (error.stack) {
585 if (error['arguments']) {
586 // Chrome
587 stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.<anonymous>\s*\(([^)]+)\)/gm, '{anonymous}($1)').split('\n');
588 stack.shift();
589 } else {
590 // Firefox
591 stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n');
592 }
593
594 stackStr = `\n ${stack.slice(2).join('\n ')}`;
595 }
596
597 var updatedMessage = formatMessage(message, options);
598 console.warn(`DEPRECATION: ${updatedMessage}${stackStr}`); // eslint-disable-line no-console
599 } else {
600 next(message, options);
601 }
602 });
603 registerHandler(function raiseOnDeprecation(message, options, next) {
604 if (_environment.ENV.RAISE_ON_DEPRECATION) {
605 var updatedMessage = formatMessage(message);
606 throw new Error(updatedMessage);
607 } else {
608 next(message, options);
609 }
610 });
611 _exports.missingOptionsDeprecation = missingOptionsDeprecation = 'When calling `deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.';
612 _exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation = 'When calling `deprecate` you must provide `id` in options.';
613 _exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation = 'When calling `deprecate` you must provide `until` in options.';
614 /**
615 @module @ember/debug
616 @public
617 */
618
619 /**
620 Display a deprecation warning with the provided message and a stack trace
621 (Chrome and Firefox only).
622 * In a production build, this method is defined as an empty function (NOP).
623 Uses of this method in Ember itself are stripped from the ember.prod.js build.
624 @method deprecate
625 @for @ember/debug
626 @param {String} message A description of the deprecation.
627 @param {Boolean} test A boolean. If falsy, the deprecation will be displayed.
628 @param {Object} options
629 @param {String} options.id A unique id for this deprecation. The id can be
630 used by Ember debugging tools to change the behavior (raise, log or silence)
631 for that specific deprecation. The id should be namespaced by dots, e.g.
632 "view.helper.select".
633 @param {string} options.until The version of Ember when this deprecation
634 warning will be removed.
635 @param {String} [options.url] An optional url to the transition guide on the
636 emberjs.com website.
637 @static
638 @public
639 @since 1.0.0
640 */
641
642 deprecate = function deprecate(message, test, options) {
643 (0, _index.assert)(missingOptionsDeprecation, Boolean(options && (options.id || options.until)));
644 (0, _index.assert)(missingOptionsIdDeprecation, Boolean(options.id));
645 (0, _index.assert)(missingOptionsUntilDeprecation, Boolean(options.until));
646 (0, _handlers.invoke)('deprecate', message, test, options);
647 };
648 }
649
650 var _default = deprecate;
651 _exports.default = _default;
652});
653define("@ember/debug/lib/handlers", ["exports"], function (_exports) {
654 "use strict";
655
656 Object.defineProperty(_exports, "__esModule", {
657 value: true
658 });
659 _exports.invoke = _exports.registerHandler = _exports.HANDLERS = void 0;
660 var HANDLERS = {};
661 _exports.HANDLERS = HANDLERS;
662
663 var registerHandler = () => {};
664
665 _exports.registerHandler = registerHandler;
666
667 var invoke = () => {};
668
669 _exports.invoke = invoke;
670
671 if (true
672 /* DEBUG */
673 ) {
674 _exports.registerHandler = registerHandler = function registerHandler(type, callback) {
675 var nextHandler = HANDLERS[type] || (() => {});
676
677 HANDLERS[type] = (message, options) => {
678 callback(message, options, nextHandler);
679 };
680 };
681
682 _exports.invoke = invoke = function invoke(type, message, test, options) {
683 if (test) {
684 return;
685 }
686
687 var handlerForType = HANDLERS[type];
688
689 if (handlerForType) {
690 handlerForType(message, options);
691 }
692 };
693 }
694});
695define("@ember/debug/lib/testing", ["exports"], function (_exports) {
696 "use strict";
697
698 Object.defineProperty(_exports, "__esModule", {
699 value: true
700 });
701 _exports.isTesting = isTesting;
702 _exports.setTesting = setTesting;
703 var testing = false;
704
705 function isTesting() {
706 return testing;
707 }
708
709 function setTesting(value) {
710 testing = Boolean(value);
711 }
712});
713define("@ember/debug/lib/warn", ["exports", "@ember/debug/index", "@ember/debug/lib/handlers"], function (_exports, _index, _handlers) {
714 "use strict";
715
716 Object.defineProperty(_exports, "__esModule", {
717 value: true
718 });
719 _exports.missingOptionsDeprecation = _exports.missingOptionsIdDeprecation = _exports.registerHandler = _exports.default = void 0;
720
721 var registerHandler = () => {};
722
723 _exports.registerHandler = registerHandler;
724
725 var warn = () => {};
726
727 var missingOptionsDeprecation;
728 _exports.missingOptionsDeprecation = missingOptionsDeprecation;
729 var missingOptionsIdDeprecation;
730 /**
731 @module @ember/debug
732 */
733
734 _exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation;
735
736 if (true
737 /* DEBUG */
738 ) {
739 /**
740 Allows for runtime registration of handler functions that override the default warning behavior.
741 Warnings are invoked by calls made to [@ember/debug/warn](/ember/release/classes/@ember%2Fdebug/methods/warn?anchor=warn).
742 The following example demonstrates its usage by registering a handler that does nothing overriding Ember's
743 default warning behavior.
744 ```javascript
745 import { registerWarnHandler } from '@ember/debug';
746 // next is not called, so no warnings get the default behavior
747 registerWarnHandler(() => {});
748 ```
749 The handler function takes the following arguments:
750 <ul>
751 <li> <code>message</code> - The message received from the warn call. </li>
752 <li> <code>options</code> - An object passed in with the warn call containing additional information including:</li>
753 <ul>
754 <li> <code>id</code> - An id of the warning in the form of <code>package-name.specific-warning</code>.</li>
755 </ul>
756 <li> <code>next</code> - A function that calls into the previously registered handler.</li>
757 </ul>
758 @public
759 @static
760 @method registerWarnHandler
761 @for @ember/debug
762 @param handler {Function} A function to handle warnings.
763 @since 2.1.0
764 */
765 _exports.registerHandler = registerHandler = function registerHandler(handler) {
766 (0, _handlers.registerHandler)('warn', handler);
767 };
768
769 registerHandler(function logWarning(message) {
770 /* eslint-disable no-console */
771 console.warn(`WARNING: ${message}`);
772 /* eslint-enable no-console */
773 });
774 _exports.missingOptionsDeprecation = missingOptionsDeprecation = 'When calling `warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.';
775 _exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation = 'When calling `warn` you must provide `id` in options.';
776 /**
777 Display a warning with the provided message.
778 * In a production build, this method is defined as an empty function (NOP).
779 Uses of this method in Ember itself are stripped from the ember.prod.js build.
780 ```javascript
781 import { warn } from '@ember/debug';
782 import tomsterCount from './tomster-counter'; // a module in my project
783 // Log a warning if we have more than 3 tomsters
784 warn('Too many tomsters!', tomsterCount <= 3, {
785 id: 'ember-debug.too-many-tomsters'
786 });
787 ```
788 @method warn
789 @for @ember/debug
790 @static
791 @param {String} message A warning to display.
792 @param {Boolean} test An optional boolean. If falsy, the warning
793 will be displayed.
794 @param {Object} options An object that can be used to pass a unique
795 `id` for this warning. The `id` can be used by Ember debugging tools
796 to change the behavior (raise, log, or silence) for that specific warning.
797 The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped"
798 @public
799 @since 1.0.0
800 */
801
802 warn = function warn(message, test, options) {
803 if (arguments.length === 2 && typeof test === 'object') {
804 options = test;
805 test = false;
806 }
807
808 (0, _index.assert)(missingOptionsDeprecation, Boolean(options));
809 (0, _index.assert)(missingOptionsIdDeprecation, Boolean(options && options.id));
810 (0, _handlers.invoke)('warn', message, test, options);
811 };
812 }
813
814 var _default = warn;
815 _exports.default = _default;
816});
817define("ember-testing/index", ["exports", "ember-testing/lib/test", "ember-testing/lib/adapters/adapter", "ember-testing/lib/setup_for_testing", "ember-testing/lib/adapters/qunit", "ember-testing/lib/support", "ember-testing/lib/ext/application", "ember-testing/lib/ext/rsvp", "ember-testing/lib/helpers", "ember-testing/lib/initializers"], function (_exports, _test, _adapter, _setup_for_testing, _qunit, _support, _application, _rsvp, _helpers, _initializers) {
818 "use strict";
819
820 Object.defineProperty(_exports, "__esModule", {
821 value: true
822 });
823 Object.defineProperty(_exports, "Test", {
824 enumerable: true,
825 get: function () {
826 return _test.default;
827 }
828 });
829 Object.defineProperty(_exports, "Adapter", {
830 enumerable: true,
831 get: function () {
832 return _adapter.default;
833 }
834 });
835 Object.defineProperty(_exports, "setupForTesting", {
836 enumerable: true,
837 get: function () {
838 return _setup_for_testing.default;
839 }
840 });
841 Object.defineProperty(_exports, "QUnitAdapter", {
842 enumerable: true,
843 get: function () {
844 return _qunit.default;
845 }
846 });
847});
848define("ember-testing/lib/adapters/adapter", ["exports", "@ember/-internals/runtime"], function (_exports, _runtime) {
849 "use strict";
850
851 Object.defineProperty(_exports, "__esModule", {
852 value: true
853 });
854 _exports.default = void 0;
855
856 function K() {
857 return this;
858 }
859 /**
860 @module @ember/test
861 */
862
863 /**
864 The primary purpose of this class is to create hooks that can be implemented
865 by an adapter for various test frameworks.
866
867 @class TestAdapter
868 @public
869 */
870
871
872 var _default = _runtime.Object.extend({
873 /**
874 This callback will be called whenever an async operation is about to start.
875 Override this to call your framework's methods that handle async
876 operations.
877 @public
878 @method asyncStart
879 */
880 asyncStart: K,
881
882 /**
883 This callback will be called whenever an async operation has completed.
884 @public
885 @method asyncEnd
886 */
887 asyncEnd: K,
888
889 /**
890 Override this method with your testing framework's false assertion.
891 This function is called whenever an exception occurs causing the testing
892 promise to fail.
893 QUnit example:
894 ```javascript
895 exception: function(error) {
896 ok(false, error);
897 };
898 ```
899 @public
900 @method exception
901 @param {String} error The exception to be raised.
902 */
903 exception(error) {
904 throw error;
905 }
906
907 });
908
909 _exports.default = _default;
910});
911define("ember-testing/lib/adapters/qunit", ["exports", "@ember/-internals/utils", "ember-testing/lib/adapters/adapter"], function (_exports, _utils, _adapter) {
912 "use strict";
913
914 Object.defineProperty(_exports, "__esModule", {
915 value: true
916 });
917 _exports.default = void 0;
918
919 /* globals QUnit */
920
921 /**
922 @module ember
923 */
924
925 /**
926 This class implements the methods defined by TestAdapter for the
927 QUnit testing framework.
928
929 @class QUnitAdapter
930 @namespace Ember.Test
931 @extends TestAdapter
932 @public
933 */
934 var _default = _adapter.default.extend({
935 init() {
936 this.doneCallbacks = [];
937 },
938
939 asyncStart() {
940 if (typeof QUnit.stop === 'function') {
941 // very old QUnit version
942 QUnit.stop();
943 } else {
944 this.doneCallbacks.push(QUnit.config.current ? QUnit.config.current.assert.async() : null);
945 }
946 },
947
948 asyncEnd() {
949 // checking for QUnit.stop here (even though we _need_ QUnit.start) because
950 // QUnit.start() still exists in QUnit 2.x (it just throws an error when calling
951 // inside a test context)
952 if (typeof QUnit.stop === 'function') {
953 QUnit.start();
954 } else {
955 var done = this.doneCallbacks.pop(); // This can be null if asyncStart() was called outside of a test
956
957 if (done) {
958 done();
959 }
960 }
961 },
962
963 exception(error) {
964 QUnit.config.current.assert.ok(false, (0, _utils.inspect)(error));
965 }
966
967 });
968
969 _exports.default = _default;
970});
971define("ember-testing/lib/events", ["exports", "@ember/runloop", "@ember/polyfills", "ember-testing/lib/helpers/-is-form-control"], function (_exports, _runloop, _polyfills, _isFormControl) {
972 "use strict";
973
974 Object.defineProperty(_exports, "__esModule", {
975 value: true
976 });
977 _exports.focus = focus;
978 _exports.fireEvent = fireEvent;
979 var DEFAULT_EVENT_OPTIONS = {
980 canBubble: true,
981 cancelable: true
982 };
983 var KEYBOARD_EVENT_TYPES = ['keydown', 'keypress', 'keyup'];
984 var MOUSE_EVENT_TYPES = ['click', 'mousedown', 'mouseup', 'dblclick', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover'];
985
986 function focus(el) {
987 if (!el) {
988 return;
989 }
990
991 if (el.isContentEditable || (0, _isFormControl.default)(el)) {
992 var type = el.getAttribute('type');
993
994 if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') {
995 (0, _runloop.run)(null, function () {
996 var browserIsNotFocused = document.hasFocus && !document.hasFocus(); // makes `document.activeElement` be `element`. If the browser is focused, it also fires a focus event
997
998 el.focus(); // Firefox does not trigger the `focusin` event if the window
999 // does not have focus. If the document does not have focus then
1000 // fire `focusin` event as well.
1001
1002 if (browserIsNotFocused) {
1003 // if the browser is not focused the previous `el.focus()` didn't fire an event, so we simulate it
1004 fireEvent(el, 'focus', {
1005 bubbles: false
1006 });
1007 fireEvent(el, 'focusin');
1008 }
1009 });
1010 }
1011 }
1012 }
1013
1014 function fireEvent(element, type, options = {}) {
1015 if (!element) {
1016 return;
1017 }
1018
1019 var event;
1020
1021 if (KEYBOARD_EVENT_TYPES.indexOf(type) > -1) {
1022 event = buildKeyboardEvent(type, options);
1023 } else if (MOUSE_EVENT_TYPES.indexOf(type) > -1) {
1024 var rect = element.getBoundingClientRect();
1025 var x = rect.left + 1;
1026 var y = rect.top + 1;
1027 var simulatedCoordinates = {
1028 screenX: x + 5,
1029 screenY: y + 95,
1030 clientX: x,
1031 clientY: y
1032 };
1033 event = buildMouseEvent(type, (0, _polyfills.assign)(simulatedCoordinates, options));
1034 } else {
1035 event = buildBasicEvent(type, options);
1036 }
1037
1038 element.dispatchEvent(event);
1039 }
1040
1041 function buildBasicEvent(type, options = {}) {
1042 var event = document.createEvent('Events'); // Event.bubbles is read only
1043
1044 var bubbles = options.bubbles !== undefined ? options.bubbles : true;
1045 var cancelable = options.cancelable !== undefined ? options.cancelable : true;
1046 delete options.bubbles;
1047 delete options.cancelable;
1048 event.initEvent(type, bubbles, cancelable);
1049 (0, _polyfills.assign)(event, options);
1050 return event;
1051 }
1052
1053 function buildMouseEvent(type, options = {}) {
1054 var event;
1055
1056 try {
1057 event = document.createEvent('MouseEvents');
1058 var eventOpts = (0, _polyfills.assign)({}, DEFAULT_EVENT_OPTIONS, options);
1059 event.initMouseEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.detail, eventOpts.screenX, eventOpts.screenY, eventOpts.clientX, eventOpts.clientY, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.button, eventOpts.relatedTarget);
1060 } catch (e) {
1061 event = buildBasicEvent(type, options);
1062 }
1063
1064 return event;
1065 }
1066
1067 function buildKeyboardEvent(type, options = {}) {
1068 var event;
1069
1070 try {
1071 event = document.createEvent('KeyEvents');
1072 var eventOpts = (0, _polyfills.assign)({}, DEFAULT_EVENT_OPTIONS, options);
1073 event.initKeyEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.keyCode, eventOpts.charCode);
1074 } catch (e) {
1075 event = buildBasicEvent(type, options);
1076 }
1077
1078 return event;
1079 }
1080});
1081define("ember-testing/lib/ext/application", ["@ember/application", "ember-testing/lib/setup_for_testing", "ember-testing/lib/test/helpers", "ember-testing/lib/test/promise", "ember-testing/lib/test/run", "ember-testing/lib/test/on_inject_helpers", "ember-testing/lib/test/adapter"], function (_application, _setup_for_testing, _helpers, _promise, _run, _on_inject_helpers, _adapter) {
1082 "use strict";
1083
1084 _application.default.reopen({
1085 /**
1086 This property contains the testing helpers for the current application. These
1087 are created once you call `injectTestHelpers` on your `Application`
1088 instance. The included helpers are also available on the `window` object by
1089 default, but can be used from this object on the individual application also.
1090 @property testHelpers
1091 @type {Object}
1092 @default {}
1093 @public
1094 */
1095 testHelpers: {},
1096
1097 /**
1098 This property will contain the original methods that were registered
1099 on the `helperContainer` before `injectTestHelpers` is called.
1100 When `removeTestHelpers` is called, these methods are restored to the
1101 `helperContainer`.
1102 @property originalMethods
1103 @type {Object}
1104 @default {}
1105 @private
1106 @since 1.3.0
1107 */
1108 originalMethods: {},
1109
1110 /**
1111 This property indicates whether or not this application is currently in
1112 testing mode. This is set when `setupForTesting` is called on the current
1113 application.
1114 @property testing
1115 @type {Boolean}
1116 @default false
1117 @since 1.3.0
1118 @public
1119 */
1120 testing: false,
1121
1122 /**
1123 This hook defers the readiness of the application, so that you can start
1124 the app when your tests are ready to run. It also sets the router's
1125 location to 'none', so that the window's location will not be modified
1126 (preventing both accidental leaking of state between tests and interference
1127 with your testing framework). `setupForTesting` should only be called after
1128 setting a custom `router` class (for example `App.Router = Router.extend(`).
1129 Example:
1130 ```
1131 App.setupForTesting();
1132 ```
1133 @method setupForTesting
1134 @public
1135 */
1136 setupForTesting() {
1137 (0, _setup_for_testing.default)();
1138 this.testing = true;
1139 this.resolveRegistration('router:main').reopen({
1140 location: 'none'
1141 });
1142 },
1143
1144 /**
1145 This will be used as the container to inject the test helpers into. By
1146 default the helpers are injected into `window`.
1147 @property helperContainer
1148 @type {Object} The object to be used for test helpers.
1149 @default window
1150 @since 1.2.0
1151 @private
1152 */
1153 helperContainer: null,
1154
1155 /**
1156 This injects the test helpers into the `helperContainer` object. If an object is provided
1157 it will be used as the helperContainer. If `helperContainer` is not set it will default
1158 to `window`. If a function of the same name has already been defined it will be cached
1159 (so that it can be reset if the helper is removed with `unregisterHelper` or
1160 `removeTestHelpers`).
1161 Any callbacks registered with `onInjectHelpers` will be called once the
1162 helpers have been injected.
1163 Example:
1164 ```
1165 App.injectTestHelpers();
1166 ```
1167 @method injectTestHelpers
1168 @public
1169 */
1170 injectTestHelpers(helperContainer) {
1171 if (helperContainer) {
1172 this.helperContainer = helperContainer;
1173 } else {
1174 this.helperContainer = window;
1175 }
1176
1177 this.reopen({
1178 willDestroy() {
1179 this._super(...arguments);
1180
1181 this.removeTestHelpers();
1182 }
1183
1184 });
1185 this.testHelpers = {};
1186
1187 for (var name in _helpers.helpers) {
1188 this.originalMethods[name] = this.helperContainer[name];
1189 this.testHelpers[name] = this.helperContainer[name] = helper(this, name);
1190 protoWrap(_promise.default.prototype, name, helper(this, name), _helpers.helpers[name].meta.wait);
1191 }
1192
1193 (0, _on_inject_helpers.invokeInjectHelpersCallbacks)(this);
1194 },
1195
1196 /**
1197 This removes all helpers that have been registered, and resets and functions
1198 that were overridden by the helpers.
1199 Example:
1200 ```javascript
1201 App.removeTestHelpers();
1202 ```
1203 @public
1204 @method removeTestHelpers
1205 */
1206 removeTestHelpers() {
1207 if (!this.helperContainer) {
1208 return;
1209 }
1210
1211 for (var name in _helpers.helpers) {
1212 this.helperContainer[name] = this.originalMethods[name];
1213 delete _promise.default.prototype[name];
1214 delete this.testHelpers[name];
1215 delete this.originalMethods[name];
1216 }
1217 }
1218
1219 }); // This method is no longer needed
1220 // But still here for backwards compatibility
1221 // of helper chaining
1222
1223
1224 function protoWrap(proto, name, callback, isAsync) {
1225 proto[name] = function (...args) {
1226 if (isAsync) {
1227 return callback.apply(this, args);
1228 } else {
1229 return this.then(function () {
1230 return callback.apply(this, args);
1231 });
1232 }
1233 };
1234 }
1235
1236 function helper(app, name) {
1237 var fn = _helpers.helpers[name].method;
1238 var meta = _helpers.helpers[name].meta;
1239
1240 if (!meta.wait) {
1241 return (...args) => fn.apply(app, [app, ...args]);
1242 }
1243
1244 return (...args) => {
1245 var lastPromise = (0, _run.default)(() => (0, _promise.resolve)((0, _promise.getLastPromise)())); // wait for last helper's promise to resolve and then
1246 // execute. To be safe, we need to tell the adapter we're going
1247 // asynchronous here, because fn may not be invoked before we
1248 // return.
1249
1250 (0, _adapter.asyncStart)();
1251 return lastPromise.then(() => fn.apply(app, [app, ...args])).finally(_adapter.asyncEnd);
1252 };
1253 }
1254});
1255define("ember-testing/lib/ext/rsvp", ["exports", "@ember/-internals/runtime", "@ember/runloop", "@ember/debug", "ember-testing/lib/test/adapter"], function (_exports, _runtime, _runloop, _debug, _adapter) {
1256 "use strict";
1257
1258 Object.defineProperty(_exports, "__esModule", {
1259 value: true
1260 });
1261 _exports.default = void 0;
1262
1263 _runtime.RSVP.configure('async', function (callback, promise) {
1264 // if schedule will cause autorun, we need to inform adapter
1265 if ((0, _debug.isTesting)() && !_runloop.backburner.currentInstance) {
1266 (0, _adapter.asyncStart)();
1267
1268 _runloop.backburner.schedule('actions', () => {
1269 (0, _adapter.asyncEnd)();
1270 callback(promise);
1271 });
1272 } else {
1273 _runloop.backburner.schedule('actions', () => callback(promise));
1274 }
1275 });
1276
1277 var _default = _runtime.RSVP;
1278 _exports.default = _default;
1279});
1280define("ember-testing/lib/helpers", ["ember-testing/lib/test/helpers", "ember-testing/lib/helpers/and_then", "ember-testing/lib/helpers/click", "ember-testing/lib/helpers/current_path", "ember-testing/lib/helpers/current_route_name", "ember-testing/lib/helpers/current_url", "ember-testing/lib/helpers/fill_in", "ember-testing/lib/helpers/find", "ember-testing/lib/helpers/find_with_assert", "ember-testing/lib/helpers/key_event", "ember-testing/lib/helpers/pause_test", "ember-testing/lib/helpers/trigger_event", "ember-testing/lib/helpers/visit", "ember-testing/lib/helpers/wait"], function (_helpers, _and_then, _click, _current_path, _current_route_name, _current_url, _fill_in, _find, _find_with_assert, _key_event, _pause_test, _trigger_event, _visit, _wait) {
1281 "use strict";
1282
1283 (0, _helpers.registerAsyncHelper)('visit', _visit.default);
1284 (0, _helpers.registerAsyncHelper)('click', _click.default);
1285 (0, _helpers.registerAsyncHelper)('keyEvent', _key_event.default);
1286 (0, _helpers.registerAsyncHelper)('fillIn', _fill_in.default);
1287 (0, _helpers.registerAsyncHelper)('wait', _wait.default);
1288 (0, _helpers.registerAsyncHelper)('andThen', _and_then.default);
1289 (0, _helpers.registerAsyncHelper)('pauseTest', _pause_test.pauseTest);
1290 (0, _helpers.registerAsyncHelper)('triggerEvent', _trigger_event.default);
1291 (0, _helpers.registerHelper)('find', _find.default);
1292 (0, _helpers.registerHelper)('findWithAssert', _find_with_assert.default);
1293 (0, _helpers.registerHelper)('currentRouteName', _current_route_name.default);
1294 (0, _helpers.registerHelper)('currentPath', _current_path.default);
1295 (0, _helpers.registerHelper)('currentURL', _current_url.default);
1296 (0, _helpers.registerHelper)('resumeTest', _pause_test.resumeTest);
1297});
1298define("ember-testing/lib/helpers/-is-form-control", ["exports"], function (_exports) {
1299 "use strict";
1300
1301 Object.defineProperty(_exports, "__esModule", {
1302 value: true
1303 });
1304 _exports.default = isFormControl;
1305 var FORM_CONTROL_TAGS = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'];
1306 /**
1307 @private
1308 @param {Element} element the element to check
1309 @returns {boolean} `true` when the element is a form control, `false` otherwise
1310 */
1311
1312 function isFormControl(element) {
1313 var {
1314 tagName,
1315 type
1316 } = element;
1317
1318 if (type === 'hidden') {
1319 return false;
1320 }
1321
1322 return FORM_CONTROL_TAGS.indexOf(tagName) > -1;
1323 }
1324});
1325define("ember-testing/lib/helpers/and_then", ["exports"], function (_exports) {
1326 "use strict";
1327
1328 Object.defineProperty(_exports, "__esModule", {
1329 value: true
1330 });
1331 _exports.default = andThen;
1332
1333 function andThen(app, callback) {
1334 return app.testHelpers.wait(callback(app));
1335 }
1336});
1337define("ember-testing/lib/helpers/click", ["exports", "ember-testing/lib/events"], function (_exports, _events) {
1338 "use strict";
1339
1340 Object.defineProperty(_exports, "__esModule", {
1341 value: true
1342 });
1343 _exports.default = click;
1344
1345 /**
1346 @module ember
1347 */
1348
1349 /**
1350 Clicks an element and triggers any actions triggered by the element's `click`
1351 event.
1352
1353 Example:
1354
1355 ```javascript
1356 click('.some-jQuery-selector').then(function() {
1357 // assert something
1358 });
1359 ```
1360
1361 @method click
1362 @param {String} selector jQuery selector for finding element on the DOM
1363 @param {Object} context A DOM Element, Document, or jQuery to use as context
1364 @return {RSVP.Promise<undefined>}
1365 @public
1366 */
1367 function click(app, selector, context) {
1368 var $el = app.testHelpers.findWithAssert(selector, context);
1369 var el = $el[0];
1370 (0, _events.fireEvent)(el, 'mousedown');
1371 (0, _events.focus)(el);
1372 (0, _events.fireEvent)(el, 'mouseup');
1373 (0, _events.fireEvent)(el, 'click');
1374 return app.testHelpers.wait();
1375 }
1376});
1377define("ember-testing/lib/helpers/current_path", ["exports", "@ember/-internals/metal"], function (_exports, _metal) {
1378 "use strict";
1379
1380 Object.defineProperty(_exports, "__esModule", {
1381 value: true
1382 });
1383 _exports.default = currentPath;
1384
1385 /**
1386 @module ember
1387 */
1388
1389 /**
1390 Returns the current path.
1391
1392 Example:
1393
1394 ```javascript
1395 function validateURL() {
1396 equal(currentPath(), 'some.path.index', "correct path was transitioned into.");
1397 }
1398
1399 click('#some-link-id').then(validateURL);
1400 ```
1401
1402 @method currentPath
1403 @return {Object} The currently active path.
1404 @since 1.5.0
1405 @public
1406 */
1407 function currentPath(app) {
1408 var routingService = app.__container__.lookup('service:-routing');
1409
1410 return (0, _metal.get)(routingService, 'currentPath');
1411 }
1412});
1413define("ember-testing/lib/helpers/current_route_name", ["exports", "@ember/-internals/metal"], function (_exports, _metal) {
1414 "use strict";
1415
1416 Object.defineProperty(_exports, "__esModule", {
1417 value: true
1418 });
1419 _exports.default = currentRouteName;
1420
1421 /**
1422 @module ember
1423 */
1424
1425 /**
1426 Returns the currently active route name.
1427
1428 Example:
1429
1430 ```javascript
1431 function validateRouteName() {
1432 equal(currentRouteName(), 'some.path', "correct route was transitioned into.");
1433 }
1434 visit('/some/path').then(validateRouteName)
1435 ```
1436
1437 @method currentRouteName
1438 @return {Object} The name of the currently active route.
1439 @since 1.5.0
1440 @public
1441 */
1442 function currentRouteName(app) {
1443 var routingService = app.__container__.lookup('service:-routing');
1444
1445 return (0, _metal.get)(routingService, 'currentRouteName');
1446 }
1447});
1448define("ember-testing/lib/helpers/current_url", ["exports", "@ember/-internals/metal"], function (_exports, _metal) {
1449 "use strict";
1450
1451 Object.defineProperty(_exports, "__esModule", {
1452 value: true
1453 });
1454 _exports.default = currentURL;
1455
1456 /**
1457 @module ember
1458 */
1459
1460 /**
1461 Returns the current URL.
1462
1463 Example:
1464
1465 ```javascript
1466 function validateURL() {
1467 equal(currentURL(), '/some/path', "correct URL was transitioned into.");
1468 }
1469
1470 click('#some-link-id').then(validateURL);
1471 ```
1472
1473 @method currentURL
1474 @return {Object} The currently active URL.
1475 @since 1.5.0
1476 @public
1477 */
1478 function currentURL(app) {
1479 var router = app.__container__.lookup('router:main');
1480
1481 return (0, _metal.get)(router, 'location').getURL();
1482 }
1483});
1484define("ember-testing/lib/helpers/fill_in", ["exports", "ember-testing/lib/events", "ember-testing/lib/helpers/-is-form-control"], function (_exports, _events, _isFormControl) {
1485 "use strict";
1486
1487 Object.defineProperty(_exports, "__esModule", {
1488 value: true
1489 });
1490 _exports.default = fillIn;
1491
1492 /**
1493 @module ember
1494 */
1495
1496 /**
1497 Fills in an input element with some text.
1498
1499 Example:
1500
1501 ```javascript
1502 fillIn('#email', 'you@example.com').then(function() {
1503 // assert something
1504 });
1505 ```
1506
1507 @method fillIn
1508 @param {String} selector jQuery selector finding an input element on the DOM
1509 to fill text with
1510 @param {String} text text to place inside the input element
1511 @return {RSVP.Promise<undefined>}
1512 @public
1513 */
1514 function fillIn(app, selector, contextOrText, text) {
1515 var $el, el, context;
1516
1517 if (text === undefined) {
1518 text = contextOrText;
1519 } else {
1520 context = contextOrText;
1521 }
1522
1523 $el = app.testHelpers.findWithAssert(selector, context);
1524 el = $el[0];
1525 (0, _events.focus)(el);
1526
1527 if ((0, _isFormControl.default)(el)) {
1528 el.value = text;
1529 } else {
1530 el.innerHTML = text;
1531 }
1532
1533 (0, _events.fireEvent)(el, 'input');
1534 (0, _events.fireEvent)(el, 'change');
1535 return app.testHelpers.wait();
1536 }
1537});
1538define("ember-testing/lib/helpers/find", ["exports", "@ember/-internals/metal", "@ember/debug", "@ember/-internals/views"], function (_exports, _metal, _debug, _views) {
1539 "use strict";
1540
1541 Object.defineProperty(_exports, "__esModule", {
1542 value: true
1543 });
1544 _exports.default = find;
1545
1546 /**
1547 @module ember
1548 */
1549
1550 /**
1551 Finds an element in the context of the app's container element. A simple alias
1552 for `app.$(selector)`.
1553
1554 Example:
1555
1556 ```javascript
1557 var $el = find('.my-selector');
1558 ```
1559
1560 With the `context` param:
1561
1562 ```javascript
1563 var $el = find('.my-selector', '.parent-element-class');
1564 ```
1565
1566 @method find
1567 @param {String} selector jQuery selector for element lookup
1568 @param {String} [context] (optional) jQuery selector that will limit the selector
1569 argument to find only within the context's children
1570 @return {Object} DOM element representing the results of the query
1571 @public
1572 */
1573 function find(app, selector, context) {
1574 if (_views.jQueryDisabled) {
1575 (true && !(false) && (0, _debug.assert)('If jQuery is disabled, please import and use helpers from @ember/test-helpers [https://github.com/emberjs/ember-test-helpers]. Note: `find` is not an available helper.'));
1576 }
1577
1578 var $el;
1579 context = context || (0, _metal.get)(app, 'rootElement');
1580 $el = app.$(selector, context);
1581 return $el;
1582 }
1583});
1584define("ember-testing/lib/helpers/find_with_assert", ["exports"], function (_exports) {
1585 "use strict";
1586
1587 Object.defineProperty(_exports, "__esModule", {
1588 value: true
1589 });
1590 _exports.default = findWithAssert;
1591
1592 /**
1593 @module ember
1594 */
1595
1596 /**
1597 Like `find`, but throws an error if the element selector returns no results.
1598
1599 Example:
1600
1601 ```javascript
1602 var $el = findWithAssert('.doesnt-exist'); // throws error
1603 ```
1604
1605 With the `context` param:
1606
1607 ```javascript
1608 var $el = findWithAssert('.selector-id', '.parent-element-class'); // assert will pass
1609 ```
1610
1611 @method findWithAssert
1612 @param {String} selector jQuery selector string for finding an element within
1613 the DOM
1614 @param {String} [context] (optional) jQuery selector that will limit the
1615 selector argument to find only within the context's children
1616 @return {Object} jQuery object representing the results of the query
1617 @throws {Error} throws error if object returned has a length of 0
1618 @public
1619 */
1620 function findWithAssert(app, selector, context) {
1621 var $el = app.testHelpers.find(selector, context);
1622
1623 if ($el.length === 0) {
1624 throw new Error('Element ' + selector + ' not found.');
1625 }
1626
1627 return $el;
1628 }
1629});
1630define("ember-testing/lib/helpers/key_event", ["exports"], function (_exports) {
1631 "use strict";
1632
1633 Object.defineProperty(_exports, "__esModule", {
1634 value: true
1635 });
1636 _exports.default = keyEvent;
1637
1638 /**
1639 @module ember
1640 */
1641
1642 /**
1643 Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode
1644 Example:
1645 ```javascript
1646 keyEvent('.some-jQuery-selector', 'keypress', 13).then(function() {
1647 // assert something
1648 });
1649 ```
1650 @method keyEvent
1651 @param {String} selector jQuery selector for finding element on the DOM
1652 @param {String} type the type of key event, e.g. `keypress`, `keydown`, `keyup`
1653 @param {Number} keyCode the keyCode of the simulated key event
1654 @return {RSVP.Promise<undefined>}
1655 @since 1.5.0
1656 @public
1657 */
1658 function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) {
1659 var context, type;
1660
1661 if (keyCode === undefined) {
1662 context = null;
1663 keyCode = typeOrKeyCode;
1664 type = contextOrType;
1665 } else {
1666 context = contextOrType;
1667 type = typeOrKeyCode;
1668 }
1669
1670 return app.testHelpers.triggerEvent(selector, context, type, {
1671 keyCode,
1672 which: keyCode
1673 });
1674 }
1675});
1676define("ember-testing/lib/helpers/pause_test", ["exports", "@ember/-internals/runtime", "@ember/debug"], function (_exports, _runtime, _debug) {
1677 "use strict";
1678
1679 Object.defineProperty(_exports, "__esModule", {
1680 value: true
1681 });
1682 _exports.resumeTest = resumeTest;
1683 _exports.pauseTest = pauseTest;
1684
1685 /**
1686 @module ember
1687 */
1688 var resume;
1689 /**
1690 Resumes a test paused by `pauseTest`.
1691
1692 @method resumeTest
1693 @return {void}
1694 @public
1695 */
1696
1697 function resumeTest() {
1698 (true && !(resume) && (0, _debug.assert)('Testing has not been paused. There is nothing to resume.', resume));
1699 resume();
1700 resume = undefined;
1701 }
1702 /**
1703 Pauses the current test - this is useful for debugging while testing or for test-driving.
1704 It allows you to inspect the state of your application at any point.
1705 Example (The test will pause before clicking the button):
1706
1707 ```javascript
1708 visit('/')
1709 return pauseTest();
1710 click('.btn');
1711 ```
1712
1713 You may want to turn off the timeout before pausing.
1714
1715 qunit (timeout available to use as of 2.4.0):
1716
1717 ```
1718 visit('/');
1719 assert.timeout(0);
1720 return pauseTest();
1721 click('.btn');
1722 ```
1723
1724 mocha (timeout happens automatically as of ember-mocha v0.14.0):
1725
1726 ```
1727 visit('/');
1728 this.timeout(0);
1729 return pauseTest();
1730 click('.btn');
1731 ```
1732
1733
1734 @since 1.9.0
1735 @method pauseTest
1736 @return {Object} A promise that will never resolve
1737 @public
1738 */
1739
1740
1741 function pauseTest() {
1742 (0, _debug.info)('Testing paused. Use `resumeTest()` to continue.');
1743 return new _runtime.RSVP.Promise(resolve => {
1744 resume = resolve;
1745 }, 'TestAdapter paused promise');
1746 }
1747});
1748define("ember-testing/lib/helpers/trigger_event", ["exports", "ember-testing/lib/events"], function (_exports, _events) {
1749 "use strict";
1750
1751 Object.defineProperty(_exports, "__esModule", {
1752 value: true
1753 });
1754 _exports.default = triggerEvent;
1755
1756 /**
1757 @module ember
1758 */
1759
1760 /**
1761 Triggers the given DOM event on the element identified by the provided selector.
1762 Example:
1763 ```javascript
1764 triggerEvent('#some-elem-id', 'blur');
1765 ```
1766 This is actually used internally by the `keyEvent` helper like so:
1767 ```javascript
1768 triggerEvent('#some-elem-id', 'keypress', { keyCode: 13 });
1769 ```
1770 @method triggerEvent
1771 @param {String} selector jQuery selector for finding element on the DOM
1772 @param {String} [context] jQuery selector that will limit the selector
1773 argument to find only within the context's children
1774 @param {String} type The event type to be triggered.
1775 @param {Object} [options] The options to be passed to jQuery.Event.
1776 @return {RSVP.Promise<undefined>}
1777 @since 1.5.0
1778 @public
1779 */
1780 function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) {
1781 var arity = arguments.length;
1782 var context, type, options;
1783
1784 if (arity === 3) {
1785 // context and options are optional, so this is
1786 // app, selector, type
1787 context = null;
1788 type = contextOrType;
1789 options = {};
1790 } else if (arity === 4) {
1791 // context and options are optional, so this is
1792 if (typeof typeOrOptions === 'object') {
1793 // either
1794 // app, selector, type, options
1795 context = null;
1796 type = contextOrType;
1797 options = typeOrOptions;
1798 } else {
1799 // or
1800 // app, selector, context, type
1801 context = contextOrType;
1802 type = typeOrOptions;
1803 options = {};
1804 }
1805 } else {
1806 context = contextOrType;
1807 type = typeOrOptions;
1808 options = possibleOptions;
1809 }
1810
1811 var $el = app.testHelpers.findWithAssert(selector, context);
1812 var el = $el[0];
1813 (0, _events.fireEvent)(el, type, options);
1814 return app.testHelpers.wait();
1815 }
1816});
1817define("ember-testing/lib/helpers/visit", ["exports", "@ember/runloop"], function (_exports, _runloop) {
1818 "use strict";
1819
1820 Object.defineProperty(_exports, "__esModule", {
1821 value: true
1822 });
1823 _exports.default = visit;
1824
1825 /**
1826 Loads a route, sets up any controllers, and renders any templates associated
1827 with the route as though a real user had triggered the route change while
1828 using your app.
1829
1830 Example:
1831
1832 ```javascript
1833 visit('posts/index').then(function() {
1834 // assert something
1835 });
1836 ```
1837
1838 @method visit
1839 @param {String} url the name of the route
1840 @return {RSVP.Promise<undefined>}
1841 @public
1842 */
1843 function visit(app, url) {
1844 var router = app.__container__.lookup('router:main');
1845
1846 var shouldHandleURL = false;
1847 app.boot().then(() => {
1848 router.location.setURL(url);
1849
1850 if (shouldHandleURL) {
1851 (0, _runloop.run)(app.__deprecatedInstance__, 'handleURL', url);
1852 }
1853 });
1854
1855 if (app._readinessDeferrals > 0) {
1856 router.initialURL = url;
1857 (0, _runloop.run)(app, 'advanceReadiness');
1858 delete router.initialURL;
1859 } else {
1860 shouldHandleURL = true;
1861 }
1862
1863 return app.testHelpers.wait();
1864 }
1865});
1866define("ember-testing/lib/helpers/wait", ["exports", "ember-testing/lib/test/waiters", "@ember/-internals/runtime", "@ember/runloop", "ember-testing/lib/test/pending_requests"], function (_exports, _waiters, _runtime, _runloop, _pending_requests) {
1867 "use strict";
1868
1869 Object.defineProperty(_exports, "__esModule", {
1870 value: true
1871 });
1872 _exports.default = wait;
1873
1874 /**
1875 @module ember
1876 */
1877
1878 /**
1879 Causes the run loop to process any pending events. This is used to ensure that
1880 any async operations from other helpers (or your assertions) have been processed.
1881
1882 This is most often used as the return value for the helper functions (see 'click',
1883 'fillIn','visit',etc). However, there is a method to register a test helper which
1884 utilizes this method without the need to actually call `wait()` in your helpers.
1885
1886 The `wait` helper is built into `registerAsyncHelper` by default. You will not need
1887 to `return app.testHelpers.wait();` - the wait behavior is provided for you.
1888
1889 Example:
1890
1891 ```javascript
1892 import { registerAsyncHelper } from '@ember/test';
1893
1894 registerAsyncHelper('loginUser', function(app, username, password) {
1895 visit('secured/path/here')
1896 .fillIn('#username', username)
1897 .fillIn('#password', password)
1898 .click('.submit');
1899 });
1900 ```
1901
1902 @method wait
1903 @param {Object} value The value to be returned.
1904 @return {RSVP.Promise<any>} Promise that resolves to the passed value.
1905 @public
1906 @since 1.0.0
1907 */
1908 function wait(app, value) {
1909 return new _runtime.RSVP.Promise(function (resolve) {
1910 var router = app.__container__.lookup('router:main'); // Every 10ms, poll for the async thing to have finished
1911
1912
1913 var watcher = setInterval(() => {
1914 // 1. If the router is loading, keep polling
1915 var routerIsLoading = router._routerMicrolib && Boolean(router._routerMicrolib.activeTransition);
1916
1917 if (routerIsLoading) {
1918 return;
1919 } // 2. If there are pending Ajax requests, keep polling
1920
1921
1922 if ((0, _pending_requests.pendingRequests)()) {
1923 return;
1924 } // 3. If there are scheduled timers or we are inside of a run loop, keep polling
1925
1926
1927 if ((0, _runloop.hasScheduledTimers)() || (0, _runloop.getCurrentRunLoop)()) {
1928 return;
1929 }
1930
1931 if ((0, _waiters.checkWaiters)()) {
1932 return;
1933 } // Stop polling
1934
1935
1936 clearInterval(watcher); // Synchronously resolve the promise
1937
1938 (0, _runloop.run)(null, resolve, value);
1939 }, 10);
1940 });
1941 }
1942});
1943define("ember-testing/lib/initializers", ["@ember/application"], function (_application) {
1944 "use strict";
1945
1946 var name = 'deferReadiness in `testing` mode';
1947 (0, _application.onLoad)('Ember.Application', function (Application) {
1948 if (!Application.initializers[name]) {
1949 Application.initializer({
1950 name: name,
1951
1952 initialize(application) {
1953 if (application.testing) {
1954 application.deferReadiness();
1955 }
1956 }
1957
1958 });
1959 }
1960 });
1961});
1962define("ember-testing/lib/setup_for_testing", ["exports", "@ember/debug", "@ember/-internals/views", "ember-testing/lib/test/adapter", "ember-testing/lib/test/pending_requests", "ember-testing/lib/adapters/adapter", "ember-testing/lib/adapters/qunit"], function (_exports, _debug, _views, _adapter, _pending_requests, _adapter2, _qunit) {
1963 "use strict";
1964
1965 Object.defineProperty(_exports, "__esModule", {
1966 value: true
1967 });
1968 _exports.default = setupForTesting;
1969
1970 /* global self */
1971
1972 /**
1973 Sets Ember up for testing. This is useful to perform
1974 basic setup steps in order to unit test.
1975
1976 Use `App.setupForTesting` to perform integration tests (full
1977 application testing).
1978
1979 @method setupForTesting
1980 @namespace Ember
1981 @since 1.5.0
1982 @private
1983 */
1984 function setupForTesting() {
1985 (0, _debug.setTesting)(true);
1986 var adapter = (0, _adapter.getAdapter)(); // if adapter is not manually set default to QUnit
1987
1988 if (!adapter) {
1989 (0, _adapter.setAdapter)(typeof self.QUnit === 'undefined' ? _adapter2.default.create() : _qunit.default.create());
1990 }
1991
1992 if (!_views.jQueryDisabled) {
1993 (0, _views.jQuery)(document).off('ajaxSend', _pending_requests.incrementPendingRequests);
1994 (0, _views.jQuery)(document).off('ajaxComplete', _pending_requests.decrementPendingRequests);
1995 (0, _pending_requests.clearPendingRequests)();
1996 (0, _views.jQuery)(document).on('ajaxSend', _pending_requests.incrementPendingRequests);
1997 (0, _views.jQuery)(document).on('ajaxComplete', _pending_requests.decrementPendingRequests);
1998 }
1999 }
2000});
2001define("ember-testing/lib/support", ["@ember/debug", "@ember/-internals/views", "@ember/-internals/browser-environment"], function (_debug, _views, _browserEnvironment) {
2002 "use strict";
2003
2004 /**
2005 @module ember
2006 */
2007 var $ = _views.jQuery;
2008 /**
2009 This method creates a checkbox and triggers the click event to fire the
2010 passed in handler. It is used to correct for a bug in older versions
2011 of jQuery (e.g 1.8.3).
2012
2013 @private
2014 @method testCheckboxClick
2015 */
2016
2017 function testCheckboxClick(handler) {
2018 var input = document.createElement('input');
2019 $(input).attr('type', 'checkbox').css({
2020 position: 'absolute',
2021 left: '-1000px',
2022 top: '-1000px'
2023 }).appendTo('body').on('click', handler).trigger('click').remove();
2024 }
2025
2026 if (_browserEnvironment.hasDOM && !_views.jQueryDisabled) {
2027 $(function () {
2028 /*
2029 Determine whether a checkbox checked using jQuery's "click" method will have
2030 the correct value for its checked property.
2031 If we determine that the current jQuery version exhibits this behavior,
2032 patch it to work correctly as in the commit for the actual fix:
2033 https://github.com/jquery/jquery/commit/1fb2f92.
2034 */
2035 testCheckboxClick(function () {
2036 if (!this.checked && !$.event.special.click) {
2037 $.event.special.click = {
2038 // For checkbox, fire native event so checked state will be right
2039 trigger() {
2040 if (this.nodeName === 'INPUT' && this.type === 'checkbox' && this.click) {
2041 this.click();
2042 return false;
2043 }
2044 }
2045
2046 };
2047 }
2048 }); // Try again to verify that the patch took effect or blow up.
2049
2050 testCheckboxClick(function () {
2051 (true && (0, _debug.warn)("clicked checkboxes should be checked! the jQuery patch didn't work", this.checked, {
2052 id: 'ember-testing.test-checkbox-click'
2053 }));
2054 });
2055 });
2056 }
2057});
2058define("ember-testing/lib/test", ["exports", "ember-testing/lib/test/helpers", "ember-testing/lib/test/on_inject_helpers", "ember-testing/lib/test/promise", "ember-testing/lib/test/waiters", "ember-testing/lib/test/adapter"], function (_exports, _helpers, _on_inject_helpers, _promise, _waiters, _adapter) {
2059 "use strict";
2060
2061 Object.defineProperty(_exports, "__esModule", {
2062 value: true
2063 });
2064 _exports.default = void 0;
2065
2066 /**
2067 @module ember
2068 */
2069
2070 /**
2071 This is a container for an assortment of testing related functionality:
2072
2073 * Choose your default test adapter (for your framework of choice).
2074 * Register/Unregister additional test helpers.
2075 * Setup callbacks to be fired when the test helpers are injected into
2076 your application.
2077
2078 @class Test
2079 @namespace Ember
2080 @public
2081 */
2082 var Test = {
2083 /**
2084 Hash containing all known test helpers.
2085 @property _helpers
2086 @private
2087 @since 1.7.0
2088 */
2089 _helpers: _helpers.helpers,
2090 registerHelper: _helpers.registerHelper,
2091 registerAsyncHelper: _helpers.registerAsyncHelper,
2092 unregisterHelper: _helpers.unregisterHelper,
2093 onInjectHelpers: _on_inject_helpers.onInjectHelpers,
2094 Promise: _promise.default,
2095 promise: _promise.promise,
2096 resolve: _promise.resolve,
2097 registerWaiter: _waiters.registerWaiter,
2098 unregisterWaiter: _waiters.unregisterWaiter,
2099 checkWaiters: _waiters.checkWaiters
2100 };
2101 /**
2102 Used to allow ember-testing to communicate with a specific testing
2103 framework.
2104
2105 You can manually set it before calling `App.setupForTesting()`.
2106
2107 Example:
2108
2109 ```javascript
2110 Ember.Test.adapter = MyCustomAdapter.create()
2111 ```
2112
2113 If you do not set it, ember-testing will default to `Ember.Test.QUnitAdapter`.
2114
2115 @public
2116 @for Ember.Test
2117 @property adapter
2118 @type {Class} The adapter to be used.
2119 @default Ember.Test.QUnitAdapter
2120 */
2121
2122 Object.defineProperty(Test, 'adapter', {
2123 get: _adapter.getAdapter,
2124 set: _adapter.setAdapter
2125 });
2126 var _default = Test;
2127 _exports.default = _default;
2128});
2129define("ember-testing/lib/test/adapter", ["exports", "@ember/-internals/error-handling"], function (_exports, _errorHandling) {
2130 "use strict";
2131
2132 Object.defineProperty(_exports, "__esModule", {
2133 value: true
2134 });
2135 _exports.getAdapter = getAdapter;
2136 _exports.setAdapter = setAdapter;
2137 _exports.asyncStart = asyncStart;
2138 _exports.asyncEnd = asyncEnd;
2139 var adapter;
2140
2141 function getAdapter() {
2142 return adapter;
2143 }
2144
2145 function setAdapter(value) {
2146 adapter = value;
2147
2148 if (value && typeof value.exception === 'function') {
2149 (0, _errorHandling.setDispatchOverride)(adapterDispatch);
2150 } else {
2151 (0, _errorHandling.setDispatchOverride)(null);
2152 }
2153 }
2154
2155 function asyncStart() {
2156 if (adapter) {
2157 adapter.asyncStart();
2158 }
2159 }
2160
2161 function asyncEnd() {
2162 if (adapter) {
2163 adapter.asyncEnd();
2164 }
2165 }
2166
2167 function adapterDispatch(error) {
2168 adapter.exception(error);
2169 console.error(error.stack); // eslint-disable-line no-console
2170 }
2171});
2172define("ember-testing/lib/test/helpers", ["exports", "ember-testing/lib/test/promise"], function (_exports, _promise) {
2173 "use strict";
2174
2175 Object.defineProperty(_exports, "__esModule", {
2176 value: true
2177 });
2178 _exports.registerHelper = registerHelper;
2179 _exports.registerAsyncHelper = registerAsyncHelper;
2180 _exports.unregisterHelper = unregisterHelper;
2181 _exports.helpers = void 0;
2182 var helpers = {};
2183 /**
2184 @module @ember/test
2185 */
2186
2187 /**
2188 `registerHelper` is used to register a test helper that will be injected
2189 when `App.injectTestHelpers` is called.
2190
2191 The helper method will always be called with the current Application as
2192 the first parameter.
2193
2194 For example:
2195
2196 ```javascript
2197 import { registerHelper } from '@ember/test';
2198 import { run } from '@ember/runloop';
2199
2200 registerHelper('boot', function(app) {
2201 run(app, app.advanceReadiness);
2202 });
2203 ```
2204
2205 This helper can later be called without arguments because it will be
2206 called with `app` as the first parameter.
2207
2208 ```javascript
2209 import Application from '@ember/application';
2210
2211 App = Application.create();
2212 App.injectTestHelpers();
2213 boot();
2214 ```
2215
2216 @public
2217 @for @ember/test
2218 @static
2219 @method registerHelper
2220 @param {String} name The name of the helper method to add.
2221 @param {Function} helperMethod
2222 @param options {Object}
2223 */
2224
2225 _exports.helpers = helpers;
2226
2227 function registerHelper(name, helperMethod) {
2228 helpers[name] = {
2229 method: helperMethod,
2230 meta: {
2231 wait: false
2232 }
2233 };
2234 }
2235 /**
2236 `registerAsyncHelper` is used to register an async test helper that will be injected
2237 when `App.injectTestHelpers` is called.
2238
2239 The helper method will always be called with the current Application as
2240 the first parameter.
2241
2242 For example:
2243
2244 ```javascript
2245 import { registerAsyncHelper } from '@ember/test';
2246 import { run } from '@ember/runloop';
2247
2248 registerAsyncHelper('boot', function(app) {
2249 run(app, app.advanceReadiness);
2250 });
2251 ```
2252
2253 The advantage of an async helper is that it will not run
2254 until the last async helper has completed. All async helpers
2255 after it will wait for it complete before running.
2256
2257
2258 For example:
2259
2260 ```javascript
2261 import { registerAsyncHelper } from '@ember/test';
2262
2263 registerAsyncHelper('deletePost', function(app, postId) {
2264 click('.delete-' + postId);
2265 });
2266
2267 // ... in your test
2268 visit('/post/2');
2269 deletePost(2);
2270 visit('/post/3');
2271 deletePost(3);
2272 ```
2273
2274 @public
2275 @for @ember/test
2276 @method registerAsyncHelper
2277 @param {String} name The name of the helper method to add.
2278 @param {Function} helperMethod
2279 @since 1.2.0
2280 */
2281
2282
2283 function registerAsyncHelper(name, helperMethod) {
2284 helpers[name] = {
2285 method: helperMethod,
2286 meta: {
2287 wait: true
2288 }
2289 };
2290 }
2291 /**
2292 Remove a previously added helper method.
2293
2294 Example:
2295
2296 ```javascript
2297 import { unregisterHelper } from '@ember/test';
2298
2299 unregisterHelper('wait');
2300 ```
2301
2302 @public
2303 @method unregisterHelper
2304 @static
2305 @for @ember/test
2306 @param {String} name The helper to remove.
2307 */
2308
2309
2310 function unregisterHelper(name) {
2311 delete helpers[name];
2312 delete _promise.default.prototype[name];
2313 }
2314});
2315define("ember-testing/lib/test/on_inject_helpers", ["exports"], function (_exports) {
2316 "use strict";
2317
2318 Object.defineProperty(_exports, "__esModule", {
2319 value: true
2320 });
2321 _exports.onInjectHelpers = onInjectHelpers;
2322 _exports.invokeInjectHelpersCallbacks = invokeInjectHelpersCallbacks;
2323 _exports.callbacks = void 0;
2324 var callbacks = [];
2325 /**
2326 Used to register callbacks to be fired whenever `App.injectTestHelpers`
2327 is called.
2328
2329 The callback will receive the current application as an argument.
2330
2331 Example:
2332
2333 ```javascript
2334 import $ from 'jquery';
2335
2336 Ember.Test.onInjectHelpers(function() {
2337 $(document).ajaxSend(function() {
2338 Test.pendingRequests++;
2339 });
2340
2341 $(document).ajaxComplete(function() {
2342 Test.pendingRequests--;
2343 });
2344 });
2345 ```
2346
2347 @public
2348 @for Ember.Test
2349 @method onInjectHelpers
2350 @param {Function} callback The function to be called.
2351 */
2352
2353 _exports.callbacks = callbacks;
2354
2355 function onInjectHelpers(callback) {
2356 callbacks.push(callback);
2357 }
2358
2359 function invokeInjectHelpersCallbacks(app) {
2360 for (var i = 0; i < callbacks.length; i++) {
2361 callbacks[i](app);
2362 }
2363 }
2364});
2365define("ember-testing/lib/test/pending_requests", ["exports"], function (_exports) {
2366 "use strict";
2367
2368 Object.defineProperty(_exports, "__esModule", {
2369 value: true
2370 });
2371 _exports.pendingRequests = pendingRequests;
2372 _exports.clearPendingRequests = clearPendingRequests;
2373 _exports.incrementPendingRequests = incrementPendingRequests;
2374 _exports.decrementPendingRequests = decrementPendingRequests;
2375 var requests = [];
2376
2377 function pendingRequests() {
2378 return requests.length;
2379 }
2380
2381 function clearPendingRequests() {
2382 requests.length = 0;
2383 }
2384
2385 function incrementPendingRequests(_, xhr) {
2386 requests.push(xhr);
2387 }
2388
2389 function decrementPendingRequests(_, xhr) {
2390 setTimeout(function () {
2391 for (var i = 0; i < requests.length; i++) {
2392 if (xhr === requests[i]) {
2393 requests.splice(i, 1);
2394 break;
2395 }
2396 }
2397 }, 0);
2398 }
2399});
2400define("ember-testing/lib/test/promise", ["exports", "@ember/-internals/runtime", "ember-testing/lib/test/run"], function (_exports, _runtime, _run) {
2401 "use strict";
2402
2403 Object.defineProperty(_exports, "__esModule", {
2404 value: true
2405 });
2406 _exports.promise = promise;
2407 _exports.resolve = resolve;
2408 _exports.getLastPromise = getLastPromise;
2409 _exports.default = void 0;
2410 var lastPromise;
2411
2412 class TestPromise extends _runtime.RSVP.Promise {
2413 constructor() {
2414 super(...arguments);
2415 lastPromise = this;
2416 }
2417
2418 then(_onFulfillment, ...args) {
2419 var onFulfillment = typeof _onFulfillment === 'function' ? result => isolate(_onFulfillment, result) : undefined;
2420 return super.then(onFulfillment, ...args);
2421 }
2422
2423 }
2424 /**
2425 This returns a thenable tailored for testing. It catches failed
2426 `onSuccess` callbacks and invokes the `Ember.Test.adapter.exception`
2427 callback in the last chained then.
2428
2429 This method should be returned by async helpers such as `wait`.
2430
2431 @public
2432 @for Ember.Test
2433 @method promise
2434 @param {Function} resolver The function used to resolve the promise.
2435 @param {String} label An optional string for identifying the promise.
2436 */
2437
2438
2439 _exports.default = TestPromise;
2440
2441 function promise(resolver, label) {
2442 var fullLabel = `Ember.Test.promise: ${label || '<Unknown Promise>'}`;
2443 return new TestPromise(resolver, fullLabel);
2444 }
2445 /**
2446 Replacement for `Ember.RSVP.resolve`
2447 The only difference is this uses
2448 an instance of `Ember.Test.Promise`
2449
2450 @public
2451 @for Ember.Test
2452 @method resolve
2453 @param {Mixed} The value to resolve
2454 @since 1.2.0
2455 */
2456
2457
2458 function resolve(result, label) {
2459 return TestPromise.resolve(result, label);
2460 }
2461
2462 function getLastPromise() {
2463 return lastPromise;
2464 } // This method isolates nested async methods
2465 // so that they don't conflict with other last promises.
2466 //
2467 // 1. Set `Ember.Test.lastPromise` to null
2468 // 2. Invoke method
2469 // 3. Return the last promise created during method
2470
2471
2472 function isolate(onFulfillment, result) {
2473 // Reset lastPromise for nested helpers
2474 lastPromise = null;
2475 var value = onFulfillment(result);
2476 var promise = lastPromise;
2477 lastPromise = null; // If the method returned a promise
2478 // return that promise. If not,
2479 // return the last async helper's promise
2480
2481 if (value && value instanceof TestPromise || !promise) {
2482 return value;
2483 } else {
2484 return (0, _run.default)(() => resolve(promise).then(() => value));
2485 }
2486 }
2487});
2488define("ember-testing/lib/test/run", ["exports", "@ember/runloop"], function (_exports, _runloop) {
2489 "use strict";
2490
2491 Object.defineProperty(_exports, "__esModule", {
2492 value: true
2493 });
2494 _exports.default = run;
2495
2496 function run(fn) {
2497 if (!(0, _runloop.getCurrentRunLoop)()) {
2498 return (0, _runloop.run)(fn);
2499 } else {
2500 return fn();
2501 }
2502 }
2503});
2504define("ember-testing/lib/test/waiters", ["exports"], function (_exports) {
2505 "use strict";
2506
2507 Object.defineProperty(_exports, "__esModule", {
2508 value: true
2509 });
2510 _exports.registerWaiter = registerWaiter;
2511 _exports.unregisterWaiter = unregisterWaiter;
2512 _exports.checkWaiters = checkWaiters;
2513
2514 /**
2515 @module @ember/test
2516 */
2517 var contexts = [];
2518 var callbacks = [];
2519 /**
2520 This allows ember-testing to play nicely with other asynchronous
2521 events, such as an application that is waiting for a CSS3
2522 transition or an IndexDB transaction. The waiter runs periodically
2523 after each async helper (i.e. `click`, `andThen`, `visit`, etc) has executed,
2524 until the returning result is truthy. After the waiters finish, the next async helper
2525 is executed and the process repeats.
2526
2527 For example:
2528
2529 ```javascript
2530 import { registerWaiter } from '@ember/test';
2531
2532 registerWaiter(function() {
2533 return myPendingTransactions() === 0;
2534 });
2535 ```
2536 The `context` argument allows you to optionally specify the `this`
2537 with which your callback will be invoked.
2538
2539 For example:
2540
2541 ```javascript
2542 import { registerWaiter } from '@ember/test';
2543
2544 registerWaiter(MyDB, MyDB.hasPendingTransactions);
2545 ```
2546
2547 @public
2548 @for @ember/test
2549 @static
2550 @method registerWaiter
2551 @param {Object} context (optional)
2552 @param {Function} callback
2553 @since 1.2.0
2554 */
2555
2556 function registerWaiter(context, callback) {
2557 if (arguments.length === 1) {
2558 callback = context;
2559 context = null;
2560 }
2561
2562 if (indexOf(context, callback) > -1) {
2563 return;
2564 }
2565
2566 contexts.push(context);
2567 callbacks.push(callback);
2568 }
2569 /**
2570 `unregisterWaiter` is used to unregister a callback that was
2571 registered with `registerWaiter`.
2572
2573 @public
2574 @for @ember/test
2575 @static
2576 @method unregisterWaiter
2577 @param {Object} context (optional)
2578 @param {Function} callback
2579 @since 1.2.0
2580 */
2581
2582
2583 function unregisterWaiter(context, callback) {
2584 if (!callbacks.length) {
2585 return;
2586 }
2587
2588 if (arguments.length === 1) {
2589 callback = context;
2590 context = null;
2591 }
2592
2593 var i = indexOf(context, callback);
2594
2595 if (i === -1) {
2596 return;
2597 }
2598
2599 contexts.splice(i, 1);
2600 callbacks.splice(i, 1);
2601 }
2602 /**
2603 Iterates through each registered test waiter, and invokes
2604 its callback. If any waiter returns false, this method will return
2605 true indicating that the waiters have not settled yet.
2606
2607 This is generally used internally from the acceptance/integration test
2608 infrastructure.
2609
2610 @public
2611 @for @ember/test
2612 @static
2613 @method checkWaiters
2614 */
2615
2616
2617 function checkWaiters() {
2618 if (!callbacks.length) {
2619 return false;
2620 }
2621
2622 for (var i = 0; i < callbacks.length; i++) {
2623 var context = contexts[i];
2624 var callback = callbacks[i];
2625
2626 if (!callback.call(context)) {
2627 return true;
2628 }
2629 }
2630
2631 return false;
2632 }
2633
2634 function indexOf(context, callback) {
2635 for (var i = 0; i < callbacks.length; i++) {
2636 if (callbacks[i] === callback && contexts[i] === context) {
2637 return i;
2638 }
2639 }
2640
2641 return -1;
2642 }
2643});
2644
2645 var testing = require('ember-testing');
2646 Ember.Test = testing.Test;
2647 Ember.Test.Adapter = testing.Adapter;
2648 Ember.Test.QUnitAdapter = testing.QUnitAdapter;
2649 Ember.setupForTesting = testing.setupForTesting;
2650
2651}());
2652//# sourceMappingURL=ember-testing.map