discourse/vendor/assets/javascripts/ember-qunit.js

1787 lines
59 KiB
JavaScript

(function() {
var define, requireModule, require, requirejs;
(function() {
var _isArray;
if (!Array.isArray) {
_isArray = function (x) {
return Object.prototype.toString.call(x) === "[object Array]";
};
} else {
_isArray = Array.isArray;
}
var registry = {}, seen = {}, state = {};
var FAILED = false;
define = function(name, deps, callback) {
if (!_isArray(deps)) {
callback = deps;
deps = [];
}
registry[name] = {
deps: deps,
callback: callback
};
};
function reify(deps, name, seen) {
var length = deps.length;
var reified = new Array(length);
var dep;
var exports;
for (var i = 0, l = length; i < l; i++) {
dep = deps[i];
if (dep === 'exports') {
exports = reified[i] = seen;
} else {
reified[i] = require(resolve(dep, name));
}
}
return {
deps: reified,
exports: exports
};
}
requirejs = require = requireModule = function(name) {
if (state[name] !== FAILED &&
seen.hasOwnProperty(name)) {
return seen[name];
}
if (!registry[name]) {
throw new Error('Could not find module ' + name);
}
var mod = registry[name];
var reified;
var module;
var loaded = false;
seen[name] = { }; // placeholder for run-time cycles
try {
reified = reify(mod.deps, name, seen[name]);
module = mod.callback.apply(this, reified.deps);
loaded = true;
} finally {
if (!loaded) {
state[name] = FAILED;
}
}
return reified.exports ? seen[name] : (seen[name] = module);
};
function resolve(child, name) {
if (child.charAt(0) !== '.') { return child; }
var parts = child.split('/');
var nameParts = name.split('/');
var parentBase;
if (nameParts.length === 1) {
parentBase = nameParts;
} else {
parentBase = nameParts.slice(0, -1);
}
for (var i = 0, l = parts.length; i < l; i++) {
var part = parts[i];
if (part === '..') { parentBase.pop(); }
else if (part === '.') { continue; }
else { parentBase.push(part); }
}
return parentBase.join('/');
}
requirejs.entries = requirejs._eak_seen = registry;
requirejs.clear = function(){
requirejs.entries = requirejs._eak_seen = registry = {};
seen = state = {};
};
})();
define('ember-qunit', ['exports', 'ember-qunit/module-for', 'ember-qunit/module-for-component', 'ember-qunit/module-for-model', 'ember-qunit/adapter', 'ember-test-helpers', 'qunit'], function (exports, _emberQunitModuleFor, _emberQunitModuleForComponent, _emberQunitModuleForModel, _emberQunitAdapter, _emberTestHelpers, _qunit) {
'use strict';
exports.module = _qunit.module;
exports.test = _qunit.test;
exports.skip = _qunit.skip;
exports.only = _qunit.only;
exports.moduleFor = _emberQunitModuleFor['default'];
exports.moduleForComponent = _emberQunitModuleForComponent['default'];
exports.moduleForModel = _emberQunitModuleForModel['default'];
exports.setResolver = _emberTestHelpers.setResolver;
exports.QUnitAdapter = _emberQunitAdapter['default'];
});
define('ember-qunit/adapter', ['exports', 'ember', 'qunit'], function (exports, _ember, _qunit) {
'use strict';
exports['default'] = _ember['default'].Test.Adapter.extend({
init: function init() {
this.doneCallbacks = [];
},
asyncStart: function asyncStart() {
this.doneCallbacks.push(_qunit['default'].config.current.assert.async());
},
asyncEnd: function asyncEnd() {
this.doneCallbacks.pop()();
},
exception: function exception(error) {
_qunit['default'].config.current.assert.ok(false, _ember['default'].inspect(error));
}
});
});
define('ember-qunit/module-for-component', ['exports', './qunit-module', 'ember-test-helpers'], function (exports, _qunitModule, _emberTestHelpers) {
'use strict';
exports['default'] = moduleForComponent;
function moduleForComponent(name, description, callbacks) {
_qunitModule.createModule(_emberTestHelpers.TestModuleForComponent, name, description, callbacks);
}
});
define('ember-qunit/module-for-model', ['exports', './qunit-module', 'ember-test-helpers'], function (exports, _qunitModule, _emberTestHelpers) {
'use strict';
exports['default'] = moduleForModel;
function moduleForModel(name, description, callbacks) {
_qunitModule.createModule(_emberTestHelpers.TestModuleForModel, name, description, callbacks);
}
});
define('ember-qunit/module-for', ['exports', './qunit-module', 'ember-test-helpers'], function (exports, _qunitModule, _emberTestHelpers) {
'use strict';
exports['default'] = moduleFor;
function moduleFor(name, description, callbacks) {
_qunitModule.createModule(_emberTestHelpers.TestModule, name, description, callbacks);
}
});
define('ember-qunit/qunit-module', ['exports', 'ember', 'qunit'], function (exports, _ember, _qunit) {
'use strict';
exports.createModule = createModule;
function beforeEachCallback(callbacks) {
if (typeof callbacks !== 'object') {
return;
}
if (!callbacks) {
return;
}
var beforeEach;
if (callbacks.beforeEach) {
beforeEach = callbacks.beforeEach;
delete callbacks.beforeEach;
}
return beforeEach;
}
function afterEachCallback(callbacks) {
if (typeof callbacks !== 'object') {
return;
}
if (!callbacks) {
return;
}
var afterEach;
if (callbacks.afterEach) {
afterEach = callbacks.afterEach;
delete callbacks.afterEach;
}
return afterEach;
}
function createModule(Constructor, name, description, callbacks) {
var _beforeEach = beforeEachCallback(callbacks || description);
var _afterEach = afterEachCallback(callbacks || description);
var module = new Constructor(name, description, callbacks);
_qunit.module(module.name, {
beforeEach: function beforeEach() {
var _this = this,
_arguments = arguments;
// provide the test context to the underlying module
module.setContext(this);
return module.setup.apply(module, arguments).then(function () {
if (_beforeEach) {
return _beforeEach.apply(_this, _arguments);
}
});
},
afterEach: function afterEach() {
var _arguments2 = arguments;
var result = undefined;
if (_afterEach) {
result = _afterEach.apply(this, arguments);
}
return _ember['default'].RSVP.resolve(result).then(function () {
return module.teardown.apply(module, _arguments2);
});
}
});
}
});
define('ember-test-helpers', ['exports', 'ember', 'ember-test-helpers/test-module', 'ember-test-helpers/test-module-for-acceptance', 'ember-test-helpers/test-module-for-integration', 'ember-test-helpers/test-module-for-component', 'ember-test-helpers/test-module-for-model', 'ember-test-helpers/test-context', 'ember-test-helpers/test-resolver'], function (exports, _ember, _emberTestHelpersTestModule, _emberTestHelpersTestModuleForAcceptance, _emberTestHelpersTestModuleForIntegration, _emberTestHelpersTestModuleForComponent, _emberTestHelpersTestModuleForModel, _emberTestHelpersTestContext, _emberTestHelpersTestResolver) {
'use strict';
_ember['default'].testing = true;
exports.TestModule = _emberTestHelpersTestModule['default'];
exports.TestModuleForAcceptance = _emberTestHelpersTestModuleForAcceptance['default'];
exports.TestModuleForIntegration = _emberTestHelpersTestModuleForIntegration['default'];
exports.TestModuleForComponent = _emberTestHelpersTestModuleForComponent['default'];
exports.TestModuleForModel = _emberTestHelpersTestModuleForModel['default'];
exports.getContext = _emberTestHelpersTestContext.getContext;
exports.setContext = _emberTestHelpersTestContext.setContext;
exports.unsetContext = _emberTestHelpersTestContext.unsetContext;
exports.setResolver = _emberTestHelpersTestResolver.setResolver;
});
define('ember-test-helpers/-legacy-overrides', ['exports', 'ember', './has-ember-version'], function (exports, _ember, _hasEmberVersion) {
'use strict';
exports.preGlimmerSetupIntegrationForComponent = preGlimmerSetupIntegrationForComponent;
function preGlimmerSetupIntegrationForComponent() {
var module = this;
var context = this.context;
this.actionHooks = {};
context.dispatcher = this.container.lookup('event_dispatcher:main') || _ember['default'].EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
context.actions = module.actionHooks;
(this.registry || this.container).register('component:-test-holder', _ember['default'].Component.extend());
context.render = function (template) {
// in case `this.render` is called twice, make sure to teardown the first invocation
module.teardownComponent();
if (!template) {
throw new Error("in a component integration test you must pass a template to `render()`");
}
if (_ember['default'].isArray(template)) {
template = template.join('');
}
if (typeof template === 'string') {
template = _ember['default'].Handlebars.compile(template);
}
module.component = module.container.lookupFactory('component:-test-holder').create({
layout: template
});
module.component.set('context', context);
module.component.set('controller', context);
_ember['default'].run(function () {
module.component.appendTo('#ember-testing');
});
context._element = module.component.element;
};
context.$ = function () {
return module.component.$.apply(module.component, arguments);
};
context.set = function (key, value) {
var ret = _ember['default'].run(function () {
return _ember['default'].set(context, key, value);
});
if (_hasEmberVersion['default'](2, 0)) {
return ret;
}
};
context.setProperties = function (hash) {
var ret = _ember['default'].run(function () {
return _ember['default'].setProperties(context, hash);
});
if (_hasEmberVersion['default'](2, 0)) {
return ret;
}
};
context.get = function (key) {
return _ember['default'].get(context, key);
};
context.getProperties = function () {
var args = Array.prototype.slice.call(arguments);
return _ember['default'].getProperties(context, args);
};
context.on = function (actionName, handler) {
module.actionHooks[actionName] = handler;
};
context.send = function (actionName) {
var hook = module.actionHooks[actionName];
if (!hook) {
throw new Error("integration testing template received unexpected action " + actionName);
}
hook.apply(module, Array.prototype.slice.call(arguments, 1));
};
context.clearRender = function () {
module.teardownComponent();
};
}
});
define('ember-test-helpers/abstract-test-module', ['exports', './wait', './test-context', 'ember'], function (exports, _wait, _testContext, _ember) {
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
// calling this `merge` here because we cannot
// actually assume it is like `Object.assign`
// with > 2 args
var merge = _ember['default'].assign || _ember['default'].merge;
var _default = (function () {
function _default(name, options) {
_classCallCheck(this, _default);
this.context = undefined;
this.name = name;
this.callbacks = options || {};
this.initSetupSteps();
this.initTeardownSteps();
}
_default.prototype.setup = function setup(assert) {
var _this = this;
return this.invokeSteps(this.setupSteps, this, assert).then(function () {
_this.contextualizeCallbacks();
return _this.invokeSteps(_this.contextualizedSetupSteps, _this.context, assert);
});
};
_default.prototype.teardown = function teardown(assert) {
var _this2 = this;
return this.invokeSteps(this.contextualizedTeardownSteps, this.context, assert).then(function () {
return _this2.invokeSteps(_this2.teardownSteps, _this2, assert);
}).then(function () {
_this2.cache = null;
_this2.cachedCalls = null;
});
};
_default.prototype.initSetupSteps = function initSetupSteps() {
this.setupSteps = [];
this.contextualizedSetupSteps = [];
if (this.callbacks.beforeSetup) {
this.setupSteps.push(this.callbacks.beforeSetup);
delete this.callbacks.beforeSetup;
}
this.setupSteps.push(this.setupContext);
this.setupSteps.push(this.setupTestElements);
this.setupSteps.push(this.setupAJAXListeners);
if (this.callbacks.setup) {
this.contextualizedSetupSteps.push(this.callbacks.setup);
delete this.callbacks.setup;
}
};
_default.prototype.invokeSteps = function invokeSteps(steps, context, assert) {
steps = steps.slice();
function nextStep() {
var step = steps.shift();
if (step) {
// guard against exceptions, for example missing components referenced from needs.
return new _ember['default'].RSVP.Promise(function (resolve) {
resolve(step.call(context, assert));
}).then(nextStep);
} else {
return _ember['default'].RSVP.resolve();
}
}
return nextStep();
};
_default.prototype.contextualizeCallbacks = function contextualizeCallbacks() {};
_default.prototype.initTeardownSteps = function initTeardownSteps() {
this.teardownSteps = [];
this.contextualizedTeardownSteps = [];
if (this.callbacks.teardown) {
this.contextualizedTeardownSteps.push(this.callbacks.teardown);
delete this.callbacks.teardown;
}
this.teardownSteps.push(this.teardownContext);
this.teardownSteps.push(this.teardownTestElements);
this.teardownSteps.push(this.teardownAJAXListeners);
if (this.callbacks.afterTeardown) {
this.teardownSteps.push(this.callbacks.afterTeardown);
delete this.callbacks.afterTeardown;
}
};
_default.prototype.setupTestElements = function setupTestElements() {
var testEl = document.querySelector('#ember-testing');
if (!testEl) {
var element = document.createElement('div');
element.setAttribute('id', 'ember-testing');
document.body.appendChild(element);
this.fixtureResetValue = '';
} else {
this.fixtureResetValue = testEl.innerHTML;
}
};
_default.prototype.setupContext = function setupContext(options) {
var context = this.getContext();
merge(context, {
dispatcher: null,
inject: {}
});
merge(context, options);
this.setToString();
_testContext.setContext(context);
this.context = context;
};
_default.prototype.setContext = function setContext(context) {
this.context = context;
};
_default.prototype.getContext = function getContext() {
if (this.context) {
return this.context;
}
return this.context = _testContext.getContext() || {};
};
_default.prototype.setToString = function setToString() {
var _this3 = this;
this.context.toString = function () {
if (_this3.subjectName) {
return 'test context for: ' + _this3.subjectName;
}
if (_this3.name) {
return 'test context for: ' + _this3.name;
}
};
};
_default.prototype.setupAJAXListeners = function setupAJAXListeners() {
_wait._setupAJAXHooks();
};
_default.prototype.teardownAJAXListeners = function teardownAJAXListeners() {
_wait._teardownAJAXHooks();
};
_default.prototype.teardownTestElements = function teardownTestElements() {
document.getElementById('ember-testing').innerHTML = this.fixtureResetValue;
// Ember 2.0.0 removed Ember.View as public API, so only do this when
// Ember.View is present
if (_ember['default'].View && _ember['default'].View.views) {
_ember['default'].View.views = {};
}
};
_default.prototype.teardownContext = function teardownContext() {
var context = this.context;
this.context = undefined;
_testContext.unsetContext();
if (context && context.dispatcher && !context.dispatcher.isDestroyed) {
_ember['default'].run(function () {
context.dispatcher.destroy();
});
}
};
return _default;
})();
exports['default'] = _default;
});
define('ember-test-helpers/build-registry', ['exports', 'ember'], function (exports, _ember) {
/* globals global, self, requirejs, require */
'use strict';
function exposeRegistryMethodsWithoutDeprecations(container) {
var methods = ['register', 'unregister', 'resolve', 'normalize', 'typeInjection', 'injection', 'factoryInjection', 'factoryTypeInjection', 'has', 'options', 'optionsForType'];
function exposeRegistryMethod(container, method) {
if (method in container) {
container[method] = function () {
return container._registry[method].apply(container._registry, arguments);
};
}
}
for (var i = 0, l = methods.length; i < l; i++) {
exposeRegistryMethod(container, methods[i]);
}
}
var Owner = (function () {
if (_ember['default']._RegistryProxyMixin && _ember['default']._ContainerProxyMixin) {
return _ember['default'].Object.extend(_ember['default']._RegistryProxyMixin, _ember['default']._ContainerProxyMixin);
}
return _ember['default'].Object.extend();
})();
exports['default'] = function (resolver) {
var fallbackRegistry, registry, container;
var namespace = _ember['default'].Object.create({
Resolver: { create: function create() {
return resolver;
} }
});
function register(name, factory) {
var thingToRegisterWith = registry || container;
if (!container.lookupFactory(name)) {
thingToRegisterWith.register(name, factory);
}
}
if (_ember['default'].Application.buildRegistry) {
fallbackRegistry = _ember['default'].Application.buildRegistry(namespace);
fallbackRegistry.register('component-lookup:main', _ember['default'].ComponentLookup);
registry = new _ember['default'].Registry({
fallback: fallbackRegistry
});
if (_ember['default'].ApplicationInstance && _ember['default'].ApplicationInstance.setupRegistry) {
_ember['default'].ApplicationInstance.setupRegistry(registry);
}
// these properties are set on the fallback registry by `buildRegistry`
// and on the primary registry within the ApplicationInstance constructor
// but we need to manually recreate them since ApplicationInstance's are not
// exposed externally
registry.normalizeFullName = fallbackRegistry.normalizeFullName;
registry.makeToString = fallbackRegistry.makeToString;
registry.describe = fallbackRegistry.describe;
var owner = Owner.create({
__registry__: registry,
__container__: null
});
container = registry.container({ owner: owner });
owner.__container__ = container;
exposeRegistryMethodsWithoutDeprecations(container);
} else {
container = _ember['default'].Application.buildContainer(namespace);
container.register('component-lookup:main', _ember['default'].ComponentLookup);
}
// Ember 1.10.0 did not properly add `view:toplevel` or `view:default`
// to the registry in Ember.Application.buildRegistry :(
//
// Ember 2.0.0 removed Ember.View as public API, so only do this when
// Ember.View is present
if (_ember['default'].View) {
register('view:toplevel', _ember['default'].View.extend());
}
// Ember 2.0.0 removed Ember._MetamorphView from the Ember global, so only
// do this when present
if (_ember['default']._MetamorphView) {
register('view:default', _ember['default']._MetamorphView);
}
var globalContext = typeof global === 'object' && global || self;
if (requirejs.entries['ember-data/setup-container']) {
// ember-data is a proper ember-cli addon since 2.3; if no 'import
// 'ember-data'' is present somewhere in the tests, there is also no `DS`
// available on the globalContext and hence ember-data wouldn't be setup
// correctly for the tests; that's why we import and call setupContainer
// here; also see https://github.com/emberjs/data/issues/4071 for context
var setupContainer = require('ember-data/setup-container')['default'];
setupContainer(registry || container);
} else if (globalContext.DS) {
var DS = globalContext.DS;
if (DS._setupContainer) {
DS._setupContainer(registry || container);
} else {
register('transform:boolean', DS.BooleanTransform);
register('transform:date', DS.DateTransform);
register('transform:number', DS.NumberTransform);
register('transform:string', DS.StringTransform);
register('serializer:-default', DS.JSONSerializer);
register('serializer:-rest', DS.RESTSerializer);
register('adapter:-rest', DS.RESTAdapter);
}
}
return {
registry: registry,
container: container
};
};
});
define('ember-test-helpers/has-ember-version', ['exports', 'ember'], function (exports, _ember) {
'use strict';
exports['default'] = hasEmberVersion;
function hasEmberVersion(major, minor) {
var numbers = _ember['default'].VERSION.split('-')[0].split('.');
var actualMajor = parseInt(numbers[0], 10);
var actualMinor = parseInt(numbers[1], 10);
return actualMajor > major || actualMajor === major && actualMinor >= minor;
}
});
define("ember-test-helpers/test-context", ["exports"], function (exports) {
"use strict";
exports.setContext = setContext;
exports.getContext = getContext;
exports.unsetContext = unsetContext;
var __test_context__;
function setContext(context) {
__test_context__ = context;
}
function getContext() {
return __test_context__;
}
function unsetContext() {
__test_context__ = undefined;
}
});
define('ember-test-helpers/test-module-for-acceptance', ['exports', './abstract-test-module', 'ember', './test-context'], function (exports, _abstractTestModule, _ember, _testContext) {
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _default = (function (_AbstractTestModule) {
_inherits(_default, _AbstractTestModule);
function _default() {
_classCallCheck(this, _default);
_AbstractTestModule.apply(this, arguments);
}
_default.prototype.setupContext = function setupContext() {
_AbstractTestModule.prototype.setupContext.call(this, { application: this.createApplication() });
};
_default.prototype.teardownContext = function teardownContext() {
_ember['default'].run(function () {
_testContext.getContext().application.destroy();
});
_AbstractTestModule.prototype.teardownContext.call(this);
};
_default.prototype.createApplication = function createApplication() {
var _callbacks = this.callbacks;
var Application = _callbacks.Application;
var config = _callbacks.config;
var application = undefined;
_ember['default'].run(function () {
application = Application.create(config);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
};
return _default;
})(_abstractTestModule['default']);
exports['default'] = _default;
});
define('ember-test-helpers/test-module-for-component', ['exports', './test-module', 'ember', './has-ember-version', './-legacy-overrides'], function (exports, _testModule, _ember, _hasEmberVersion, _legacyOverrides) {
'use strict';
exports.setupComponentIntegrationTest = _setupComponentIntegrationTest;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var ACTION_KEY = undefined;
if (_hasEmberVersion['default'](2, 0)) {
ACTION_KEY = 'actions';
} else {
ACTION_KEY = '_actions';
}
var isPreGlimmer = !_hasEmberVersion['default'](1, 13);
var getOwner = _ember['default'].getOwner;
var _default = (function (_TestModule) {
_inherits(_default, _TestModule);
function _default(componentName, description, callbacks) {
_classCallCheck(this, _default);
// Allow `description` to be omitted
if (!callbacks && typeof description === 'object') {
callbacks = description;
description = null;
} else if (!callbacks) {
callbacks = {};
}
var integrationOption = callbacks.integration;
_TestModule.call(this, 'component:' + componentName, description, callbacks);
this.componentName = componentName;
if (callbacks.needs || callbacks.unit || integrationOption === false) {
this.isUnitTest = true;
} else if (integrationOption) {
this.isUnitTest = false;
} else {
_ember['default'].deprecate("the component:" + componentName + " test module is implicitly running in unit test mode, " + "which will change to integration test mode by default in an upcoming version of " + "ember-test-helpers. Add `unit: true` or a `needs:[]` list to explicitly opt in to unit " + "test mode.", false, { id: 'ember-test-helpers.test-module-for-component.test-type', until: '0.6.0' });
this.isUnitTest = true;
}
if (!this.isUnitTest && !this.isLegacy) {
callbacks.integration = true;
}
if (this.isUnitTest || this.isLegacy) {
this.setupSteps.push(this.setupComponentUnitTest);
} else {
this.callbacks.subject = function () {
throw new Error("component integration tests do not support `subject()`. Instead, render the component as if it were HTML: `this.render('<my-component foo=true>');`. For more information, read: http://guides.emberjs.com/v2.2.0/testing/testing-components/");
};
this.setupSteps.push(this.setupComponentIntegrationTest);
this.teardownSteps.unshift(this.teardownComponent);
}
if (_ember['default'].View && _ember['default'].View.views) {
this.setupSteps.push(this._aliasViewRegistry);
this.teardownSteps.unshift(this._resetViewRegistry);
}
}
_default.prototype.initIntegration = function initIntegration(options) {
this.isLegacy = options.integration === 'legacy';
this.isIntegration = options.integration !== 'legacy';
};
_default.prototype._aliasViewRegistry = function _aliasViewRegistry() {
this._originalGlobalViewRegistry = _ember['default'].View.views;
var viewRegistry = this.container.lookup('-view-registry:main');
if (viewRegistry) {
_ember['default'].View.views = viewRegistry;
}
};
_default.prototype._resetViewRegistry = function _resetViewRegistry() {
_ember['default'].View.views = this._originalGlobalViewRegistry;
};
_default.prototype.setupComponentUnitTest = function setupComponentUnitTest() {
var _this = this;
var resolver = this.resolver;
var context = this.context;
var layoutName = 'template:components/' + this.componentName;
var layout = resolver.resolve(layoutName);
var thingToRegisterWith = this.registry || this.container;
if (layout) {
thingToRegisterWith.register(layoutName, layout);
thingToRegisterWith.injection(this.subjectName, 'layout', layoutName);
}
context.dispatcher = this.container.lookup('event_dispatcher:main') || _ember['default'].EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
context._element = null;
this.callbacks.render = function () {
var subject;
_ember['default'].run(function () {
subject = context.subject();
subject.appendTo('#ember-testing');
});
context._element = subject.element;
_this.teardownSteps.unshift(function () {
_ember['default'].run(function () {
_ember['default'].tryInvoke(subject, 'destroy');
});
});
};
this.callbacks.append = function () {
_ember['default'].deprecate('this.append() is deprecated. Please use this.render() or this.$() instead.', false, { id: 'ember-test-helpers.test-module-for-component.append', until: '0.6.0' });
return context.$();
};
context.$ = function () {
this.render();
var subject = this.subject();
return subject.$.apply(subject, arguments);
};
};
_default.prototype.setupComponentIntegrationTest = function setupComponentIntegrationTest() {
if (isPreGlimmer) {
return _legacyOverrides.preGlimmerSetupIntegrationForComponent.apply(this, arguments);
} else {
return _setupComponentIntegrationTest.apply(this, arguments);
}
};
_default.prototype.setupContext = function setupContext() {
_TestModule.prototype.setupContext.call(this);
// only setup the injection if we are running against a version
// of Ember that has `-view-registry:main` (Ember >= 1.12)
if (this.container.lookupFactory('-view-registry:main')) {
(this.registry || this.container).injection('component', '_viewRegistry', '-view-registry:main');
}
if (!this.isUnitTest && !this.isLegacy) {
this.context.factory = function () {};
}
};
_default.prototype.teardownComponent = function teardownComponent() {
var component = this.component;
if (component) {
_ember['default'].run(component, 'destroy');
this.component = null;
}
};
return _default;
})(_testModule['default']);
exports['default'] = _default;
function _setupComponentIntegrationTest() {
var module = this;
var context = this.context;
this.actionHooks = context[ACTION_KEY] = {};
context.dispatcher = this.container.lookup('event_dispatcher:main') || _ember['default'].EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
var hasRendered = false;
var OutletView = module.container.lookupFactory('view:-outlet');
var OutletTemplate = module.container.lookup('template:-outlet');
var toplevelView = module.component = OutletView.create();
var hasOutletTemplate = !!OutletTemplate;
var outletState = {
render: {
owner: getOwner ? getOwner(module.container) : undefined,
into: undefined,
outlet: 'main',
name: 'application',
controller: module.context,
ViewClass: undefined,
template: OutletTemplate
},
outlets: {}
};
var element = document.getElementById('ember-testing');
var templateId = 0;
if (hasOutletTemplate) {
_ember['default'].run(function () {
toplevelView.setOutletState(outletState);
});
}
context.render = function (template) {
if (!template) {
throw new Error("in a component integration test you must pass a template to `render()`");
}
if (_ember['default'].isArray(template)) {
template = template.join('');
}
if (typeof template === 'string') {
template = _ember['default'].Handlebars.compile(template);
}
var templateFullName = 'template:-undertest-' + ++templateId;
this.registry.register(templateFullName, template);
var stateToRender = {
owner: getOwner ? getOwner(module.container) : undefined,
into: undefined,
outlet: 'main',
name: 'index',
controller: module.context,
ViewClass: undefined,
template: module.container.lookup(templateFullName),
outlets: {}
};
if (hasOutletTemplate) {
stateToRender.name = 'index';
outletState.outlets.main = { render: stateToRender, outlets: {} };
} else {
stateToRender.name = 'application';
outletState = { render: stateToRender, outlets: {} };
}
_ember['default'].run(function () {
toplevelView.setOutletState(outletState);
});
if (!hasRendered) {
_ember['default'].run(module.component, 'appendTo', '#ember-testing');
hasRendered = true;
}
// ensure the element is based on the wrapping toplevel view
// Ember still wraps the main application template with a
// normal tagged view
context._element = element = document.querySelector('#ember-testing > .ember-view');
};
context.$ = function (selector) {
// emulates Ember internal behavor of `this.$` in a component
// https://github.com/emberjs/ember.js/blob/v2.5.1/packages/ember-views/lib/views/states/has_element.js#L18
return selector ? _ember['default'].$(selector, element) : _ember['default'].$(element);
};
context.set = function (key, value) {
var ret = _ember['default'].run(function () {
return _ember['default'].set(context, key, value);
});
if (_hasEmberVersion['default'](2, 0)) {
return ret;
}
};
context.setProperties = function (hash) {
var ret = _ember['default'].run(function () {
return _ember['default'].setProperties(context, hash);
});
if (_hasEmberVersion['default'](2, 0)) {
return ret;
}
};
context.get = function (key) {
return _ember['default'].get(context, key);
};
context.getProperties = function () {
var args = Array.prototype.slice.call(arguments);
return _ember['default'].getProperties(context, args);
};
context.on = function (actionName, handler) {
module.actionHooks[actionName] = handler;
};
context.send = function (actionName) {
var hook = module.actionHooks[actionName];
if (!hook) {
throw new Error("integration testing template received unexpected action " + actionName);
}
hook.apply(module.context, Array.prototype.slice.call(arguments, 1));
};
context.clearRender = function () {
_ember['default'].run(function () {
toplevelView.setOutletState({
render: {
owner: module.container,
into: undefined,
outlet: 'main',
name: 'application',
controller: module.context,
ViewClass: undefined,
template: undefined
},
outlets: {}
});
});
};
}
});
define('ember-test-helpers/test-module-for-integration', ['exports', 'ember', './abstract-test-module', './test-resolver', './build-registry', './has-ember-version', './-legacy-overrides', './test-module-for-component'], function (exports, _ember, _abstractTestModule, _testResolver, _buildRegistry, _hasEmberVersion, _legacyOverrides, _testModuleForComponent) {
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var ACTION_KEY = undefined;
if (_hasEmberVersion['default'](2, 0)) {
ACTION_KEY = 'actions';
} else {
ACTION_KEY = '_actions';
}
var isPreGlimmer = !_hasEmberVersion['default'](1, 13);
var _default = (function (_AbstractTestModule) {
_inherits(_default, _AbstractTestModule);
function _default() {
_classCallCheck(this, _default);
_AbstractTestModule.apply(this, arguments);
this.resolver = this.callbacks.resolver || _testResolver.getResolver();
}
_default.prototype.initSetupSteps = function initSetupSteps() {
this.setupSteps = [];
this.contextualizedSetupSteps = [];
if (this.callbacks.beforeSetup) {
this.setupSteps.push(this.callbacks.beforeSetup);
delete this.callbacks.beforeSetup;
}
this.setupSteps.push(this.setupContainer);
this.setupSteps.push(this.setupContext);
this.setupSteps.push(this.setupTestElements);
this.setupSteps.push(this.setupAJAXListeners);
this.setupSteps.push(this.setupComponentIntegrationTest);
if (_ember['default'].View && _ember['default'].View.views) {
this.setupSteps.push(this._aliasViewRegistry);
}
if (this.callbacks.setup) {
this.contextualizedSetupSteps.push(this.callbacks.setup);
delete this.callbacks.setup;
}
};
_default.prototype.initTeardownSteps = function initTeardownSteps() {
this.teardownSteps = [];
this.contextualizedTeardownSteps = [];
if (this.callbacks.teardown) {
this.contextualizedTeardownSteps.push(this.callbacks.teardown);
delete this.callbacks.teardown;
}
this.teardownSteps.push(this.teardownContainer);
this.teardownSteps.push(this.teardownContext);
this.teardownSteps.push(this.teardownAJAXListeners);
this.teardownSteps.push(this.teardownComponent);
if (_ember['default'].View && _ember['default'].View.views) {
this.teardownSteps.push(this._resetViewRegistry);
}
this.teardownSteps.push(this.teardownTestElements);
if (this.callbacks.afterTeardown) {
this.teardownSteps.push(this.callbacks.afterTeardown);
delete this.callbacks.afterTeardown;
}
};
_default.prototype.setupContainer = function setupContainer() {
var resolver = this.resolver;
var items = _buildRegistry['default'](resolver);
this.container = items.container;
this.registry = items.registry;
if (_hasEmberVersion['default'](1, 13)) {
var thingToRegisterWith = this.registry || this.container;
var router = resolver.resolve('router:main');
router = router || _ember['default'].Router.extend();
thingToRegisterWith.register('router:main', router);
}
};
_default.prototype.setupContext = function setupContext() {
var subjectName = this.subjectName;
var container = this.container;
var factory = function factory() {
return container.lookupFactory(subjectName);
};
_AbstractTestModule.prototype.setupContext.call(this, {
container: this.container,
registry: this.registry,
factory: factory,
register: function register() {
var target = this.registry || this.container;
return target.register.apply(target, arguments);
}
});
var context = this.context;
if (_ember['default'].setOwner) {
_ember['default'].setOwner(context, this.container.owner);
}
if (_ember['default'].inject) {
var keys = (Object.keys || _ember['default'].keys)(_ember['default'].inject);
keys.forEach(function (typeName) {
context.inject[typeName] = function (name, opts) {
var alias = opts && opts.as || name;
_ember['default'].run(function () {
_ember['default'].set(context, alias, context.container.lookup(typeName + ':' + name));
});
};
});
}
// only setup the injection if we are running against a version
// of Ember that has `-view-registry:main` (Ember >= 1.12)
if (this.container.lookupFactory('-view-registry:main')) {
(this.registry || this.container).injection('component', '_viewRegistry', '-view-registry:main');
}
};
_default.prototype.setupComponentIntegrationTest = function setupComponentIntegrationTest() {
if (isPreGlimmer) {
return _legacyOverrides.preGlimmerSetupIntegrationForComponent.apply(this, arguments);
} else {
return _testModuleForComponent.setupComponentIntegrationTest.apply(this, arguments);
}
};
_default.prototype.teardownComponent = function teardownComponent() {
var component = this.component;
if (component) {
_ember['default'].run(function () {
component.destroy();
});
}
};
_default.prototype.teardownContainer = function teardownContainer() {
var container = this.container;
_ember['default'].run(function () {
container.destroy();
});
};
// allow arbitrary named factories, like rspec let
_default.prototype.contextualizeCallbacks = function contextualizeCallbacks() {
var callbacks = this.callbacks;
var context = this.context;
this.cache = this.cache || {};
this.cachedCalls = this.cachedCalls || {};
var keys = (Object.keys || _ember['default'].keys)(callbacks);
var keysLength = keys.length;
if (keysLength) {
for (var i = 0; i < keysLength; i++) {
this._contextualizeCallback(context, keys[i], context);
}
}
};
_default.prototype._contextualizeCallback = function _contextualizeCallback(context, key, callbackContext) {
var _this = this;
var callbacks = this.callbacks;
var factory = context.factory;
context[key] = function (options) {
if (_this.cachedCalls[key]) {
return _this.cache[key];
}
var result = callbacks[key].call(callbackContext, options, factory());
_this.cache[key] = result;
_this.cachedCalls[key] = true;
return result;
};
};
_default.prototype._aliasViewRegistry = function _aliasViewRegistry() {
this._originalGlobalViewRegistry = _ember['default'].View.views;
var viewRegistry = this.container.lookup('-view-registry:main');
if (viewRegistry) {
_ember['default'].View.views = viewRegistry;
}
};
_default.prototype._resetViewRegistry = function _resetViewRegistry() {
_ember['default'].View.views = this._originalGlobalViewRegistry;
};
return _default;
})(_abstractTestModule['default']);
exports['default'] = _default;
});
define('ember-test-helpers/test-module-for-model', ['exports', './test-module', 'ember'], function (exports, _testModule, _ember) {
/* global DS, require, requirejs */ // added here to prevent an import from erroring when ED is not present
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _default = (function (_TestModule) {
_inherits(_default, _TestModule);
function _default(modelName, description, callbacks) {
_classCallCheck(this, _default);
_TestModule.call(this, 'model:' + modelName, description, callbacks);
this.modelName = modelName;
this.setupSteps.push(this.setupModel);
}
_default.prototype.setupModel = function setupModel() {
var container = this.container;
var defaultSubject = this.defaultSubject;
var callbacks = this.callbacks;
var modelName = this.modelName;
var adapterFactory = container.lookupFactory('adapter:application');
if (!adapterFactory) {
if (requirejs.entries['ember-data/adapters/json-api']) {
adapterFactory = require('ember-data/adapters/json-api')['default'];
}
// when ember-data/adapters/json-api is provided via ember-cli shims
// using Ember Data 1.x the actual JSONAPIAdapter isn't found, but the
// above require statement returns a bizzaro object with only a `default`
// property (circular reference actually)
if (!adapterFactory || !adapterFactory.create) {
adapterFactory = DS.JSONAPIAdapter || DS.FixtureAdapter;
}
var thingToRegisterWith = this.registry || this.container;
thingToRegisterWith.register('adapter:application', adapterFactory);
}
callbacks.store = function () {
var container = this.container;
return container.lookup('service:store') || container.lookup('store:main');
};
if (callbacks.subject === defaultSubject) {
callbacks.subject = function (options) {
var container = this.container;
return _ember['default'].run(function () {
var store = container.lookup('service:store') || container.lookup('store:main');
return store.createRecord(modelName, options);
});
};
}
};
return _default;
})(_testModule['default']);
exports['default'] = _default;
});
define('ember-test-helpers/test-module', ['exports', 'ember', './abstract-test-module', './test-resolver', './build-registry', './has-ember-version'], function (exports, _ember, _abstractTestModule, _testResolver, _buildRegistry, _hasEmberVersion) {
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _default = (function (_AbstractTestModule) {
_inherits(_default, _AbstractTestModule);
function _default(subjectName, description, callbacks) {
_classCallCheck(this, _default);
// Allow `description` to be omitted, in which case it should
// default to `subjectName`
if (!callbacks && typeof description === 'object') {
callbacks = description;
description = subjectName;
}
_AbstractTestModule.call(this, description || subjectName, callbacks);
this.subjectName = subjectName;
this.description = description || subjectName;
this.resolver = this.callbacks.resolver || _testResolver.getResolver();
if (this.callbacks.integration && this.callbacks.needs) {
throw new Error("cannot declare 'integration: true' and 'needs' in the same module");
}
if (this.callbacks.integration) {
this.initIntegration(callbacks);
delete callbacks.integration;
}
this.initSubject();
this.initNeeds();
}
_default.prototype.initIntegration = function initIntegration(options) {
if (options.integration === 'legacy') {
throw new Error('`integration: \'legacy\'` is only valid for component tests.');
}
this.isIntegration = true;
};
_default.prototype.initSubject = function initSubject() {
this.callbacks.subject = this.callbacks.subject || this.defaultSubject;
};
_default.prototype.initNeeds = function initNeeds() {
this.needs = [this.subjectName];
if (this.callbacks.needs) {
this.needs = this.needs.concat(this.callbacks.needs);
delete this.callbacks.needs;
}
};
_default.prototype.initSetupSteps = function initSetupSteps() {
this.setupSteps = [];
this.contextualizedSetupSteps = [];
if (this.callbacks.beforeSetup) {
this.setupSteps.push(this.callbacks.beforeSetup);
delete this.callbacks.beforeSetup;
}
this.setupSteps.push(this.setupContainer);
this.setupSteps.push(this.setupContext);
this.setupSteps.push(this.setupTestElements);
this.setupSteps.push(this.setupAJAXListeners);
if (this.callbacks.setup) {
this.contextualizedSetupSteps.push(this.callbacks.setup);
delete this.callbacks.setup;
}
};
_default.prototype.initTeardownSteps = function initTeardownSteps() {
this.teardownSteps = [];
this.contextualizedTeardownSteps = [];
if (this.callbacks.teardown) {
this.contextualizedTeardownSteps.push(this.callbacks.teardown);
delete this.callbacks.teardown;
}
this.teardownSteps.push(this.teardownSubject);
this.teardownSteps.push(this.teardownContainer);
this.teardownSteps.push(this.teardownContext);
this.teardownSteps.push(this.teardownTestElements);
this.teardownSteps.push(this.teardownAJAXListeners);
if (this.callbacks.afterTeardown) {
this.teardownSteps.push(this.callbacks.afterTeardown);
delete this.callbacks.afterTeardown;
}
};
_default.prototype.setupContainer = function setupContainer() {
if (this.isIntegration || this.isLegacy) {
this._setupIntegratedContainer();
} else {
this._setupIsolatedContainer();
}
};
_default.prototype.setupContext = function setupContext() {
var subjectName = this.subjectName;
var container = this.container;
var factory = function factory() {
return container.lookupFactory(subjectName);
};
_AbstractTestModule.prototype.setupContext.call(this, {
container: this.container,
registry: this.registry,
factory: factory,
register: function register() {
var target = this.registry || this.container;
return target.register.apply(target, arguments);
}
});
if (_ember['default'].setOwner) {
_ember['default'].setOwner(this.context, this.container.owner);
}
this.setupInject();
};
_default.prototype.setupInject = function setupInject() {
var module = this;
var context = this.context;
if (_ember['default'].inject) {
var keys = (Object.keys || _ember['default'].keys)(_ember['default'].inject);
keys.forEach(function (typeName) {
context.inject[typeName] = function (name, opts) {
var alias = opts && opts.as || name;
_ember['default'].run(function () {
_ember['default'].set(context, alias, module.container.lookup(typeName + ':' + name));
});
};
});
}
};
_default.prototype.teardownSubject = function teardownSubject() {
var subject = this.cache.subject;
if (subject) {
_ember['default'].run(function () {
_ember['default'].tryInvoke(subject, 'destroy');
});
}
};
_default.prototype.teardownContainer = function teardownContainer() {
var container = this.container;
_ember['default'].run(function () {
container.destroy();
});
};
_default.prototype.defaultSubject = function defaultSubject(options, factory) {
return factory.create(options);
};
// allow arbitrary named factories, like rspec let
_default.prototype.contextualizeCallbacks = function contextualizeCallbacks() {
var callbacks = this.callbacks;
var context = this.context;
this.cache = this.cache || {};
this.cachedCalls = this.cachedCalls || {};
var keys = (Object.keys || _ember['default'].keys)(callbacks);
var keysLength = keys.length;
if (keysLength) {
var deprecatedContext = this._buildDeprecatedContext(this, context);
for (var i = 0; i < keysLength; i++) {
this._contextualizeCallback(context, keys[i], deprecatedContext);
}
}
};
_default.prototype._contextualizeCallback = function _contextualizeCallback(context, key, callbackContext) {
var _this = this;
var callbacks = this.callbacks;
var factory = context.factory;
context[key] = function (options) {
if (_this.cachedCalls[key]) {
return _this.cache[key];
}
var result = callbacks[key].call(callbackContext, options, factory());
_this.cache[key] = result;
_this.cachedCalls[key] = true;
return result;
};
};
/*
Builds a version of the passed in context that contains deprecation warnings
for accessing properties that exist on the module.
*/
_default.prototype._buildDeprecatedContext = function _buildDeprecatedContext(module, context) {
var deprecatedContext = Object.create(context);
var keysForDeprecation = Object.keys(module);
for (var i = 0, l = keysForDeprecation.length; i < l; i++) {
this._proxyDeprecation(module, deprecatedContext, keysForDeprecation[i]);
}
return deprecatedContext;
};
/*
Defines a key on an object to act as a proxy for deprecating the original.
*/
_default.prototype._proxyDeprecation = function _proxyDeprecation(obj, proxy, key) {
if (typeof proxy[key] === 'undefined') {
Object.defineProperty(proxy, key, {
get: function get() {
_ember['default'].deprecate('Accessing the test module property "' + key + '" from a callback is deprecated.', false, { id: 'ember-test-helpers.test-module.callback-context', until: '0.6.0' });
return obj[key];
}
});
}
};
_default.prototype._setupContainer = function _setupContainer(isolated) {
var resolver = this.resolver;
var items = _buildRegistry['default'](!isolated ? resolver : Object.create(resolver, {
resolve: {
value: function value() {}
}
}));
this.container = items.container;
this.registry = items.registry;
if (_hasEmberVersion['default'](1, 13)) {
var thingToRegisterWith = this.registry || this.container;
var router = resolver.resolve('router:main');
router = router || _ember['default'].Router.extend();
thingToRegisterWith.register('router:main', router);
}
};
_default.prototype._setupIsolatedContainer = function _setupIsolatedContainer() {
var resolver = this.resolver;
this._setupContainer(true);
var thingToRegisterWith = this.registry || this.container;
for (var i = this.needs.length; i > 0; i--) {
var fullName = this.needs[i - 1];
var normalizedFullName = resolver.normalize(fullName);
thingToRegisterWith.register(fullName, resolver.resolve(normalizedFullName));
}
if (!this.registry) {
this.container.resolver = function () {};
}
};
_default.prototype._setupIntegratedContainer = function _setupIntegratedContainer() {
this._setupContainer();
};
return _default;
})(_abstractTestModule['default']);
exports['default'] = _default;
});
define('ember-test-helpers/test-resolver', ['exports'], function (exports) {
'use strict';
exports.setResolver = setResolver;
exports.getResolver = getResolver;
var __resolver__;
function setResolver(resolver) {
__resolver__ = resolver;
}
function getResolver() {
if (__resolver__ == null) {
throw new Error('you must set a resolver with `testResolver.set(resolver)`');
}
return __resolver__;
}
});
define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, _ember) {
/* globals self */
'use strict';
exports._teardownAJAXHooks = _teardownAJAXHooks;
exports._setupAJAXHooks = _setupAJAXHooks;
exports['default'] = wait;
var jQuery = _ember['default'].$;
var requests;
function incrementAjaxPendingRequests(_, xhr) {
requests.push(xhr);
}
function decrementAjaxPendingRequests(_, xhr) {
for (var i = 0; i < requests.length; i++) {
if (xhr === requests[i]) {
requests.splice(i, 1);
}
}
}
function _teardownAJAXHooks() {
if (!jQuery) {
return;
}
jQuery(document).off('ajaxSend', incrementAjaxPendingRequests);
jQuery(document).off('ajaxComplete', decrementAjaxPendingRequests);
}
function _setupAJAXHooks() {
requests = [];
if (!jQuery) {
return;
}
jQuery(document).on('ajaxSend', incrementAjaxPendingRequests);
jQuery(document).on('ajaxComplete', decrementAjaxPendingRequests);
}
var _internalCheckWaiters;
if (_ember['default'].__loader.registry['ember-testing/test/waiters']) {
_internalCheckWaiters = _ember['default'].__loader.require('ember-testing/test/waiters').checkWaiters;
}
function checkWaiters() {
if (_internalCheckWaiters) {
return _internalCheckWaiters();
} else if (_ember['default'].Test.waiters) {
if (_ember['default'].Test.waiters.any(function (_ref) {
var context = _ref[0];
var callback = _ref[1];
return !callback.call(context);
})) {
return true;
}
}
return false;
}
function wait(_options) {
var options = _options || {};
var waitForTimers = options.hasOwnProperty('waitForTimers') ? options.waitForTimers : true;
var waitForAJAX = options.hasOwnProperty('waitForAJAX') ? options.waitForAJAX : true;
var waitForWaiters = options.hasOwnProperty('waitForWaiters') ? options.waitForWaiters : true;
return new _ember['default'].RSVP.Promise(function (resolve) {
var watcher = self.setInterval(function () {
if (waitForTimers && (_ember['default'].run.hasScheduledTimers() || _ember['default'].run.currentRunLoop)) {
return;
}
if (waitForAJAX && requests && requests.length > 0) {
return;
}
if (waitForWaiters && checkWaiters()) {
return;
}
// Stop polling
self.clearInterval(watcher);
// Synchronously resolve the promise
_ember['default'].run(null, resolve);
}, 10);
});
}
});
define("qunit", ["exports"], function (exports) {
/* globals QUnit */
"use strict";
var _module = QUnit.module;
exports.module = _module;
var test = QUnit.test;
exports.test = test;
var skip = QUnit.skip;
exports.skip = skip;
var only = QUnit.only;
exports.only = only;
exports["default"] = QUnit;
});
define("ember", ["exports"], function(__exports__) {
__exports__["default"] = window.Ember;
});
var emberQunit = requireModule("ember-qunit");
window.moduleFor = emberQunit.moduleFor;
window.moduleForComponent = emberQunit.moduleForComponent;
window.moduleForModel = emberQunit.moduleForModel;
window.test = emberQunit.test;
window.setResolver = emberQunit.setResolver;
})();
//# sourceMappingURL=ember-qunit.map