mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Fix Wizard unit tests
This commit is contained in:
parent
8f70829e8e
commit
3bd5ac8015
@ -3,12 +3,12 @@ import { registerHelpers } from 'discourse-common/lib/helpers';
|
|||||||
export default {
|
export default {
|
||||||
name: 'load-helpers',
|
name: 'load-helpers',
|
||||||
|
|
||||||
initialize(container, registry) {
|
initialize(application) {
|
||||||
Object.keys(requirejs.entries).forEach(entry => {
|
Object.keys(requirejs.entries).forEach(entry => {
|
||||||
if ((/\/helpers\//).test(entry)) {
|
if ((/\/helpers\//).test(entry)) {
|
||||||
require(entry, null, null, true);
|
require(entry, null, null, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerHelpers(registry);
|
registerHelpers(application);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { componentTest } from 'wizard/test/helpers/component-test';
|
import { componentTest } from 'wizard/test/helpers/component-test';
|
||||||
|
|
||||||
moduleForComponent('invite-list', { integration: true });
|
moduleForComponent('invite-list', { integration: true });
|
||||||
|
|
||||||
componentTest('can add users', {
|
componentTest('can add users', {
|
||||||
@ -59,5 +58,4 @@ componentTest('can add users', {
|
|||||||
assert.ok(this.$('.users-list .invite-list-user').length === 0, 'removed the user');
|
assert.ok(this.$('.users-list .invite-list-user').length === 0, 'removed the user');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import initializer from 'wizard/initializers/load-helpers';
|
import initializer from 'wizard/initializers/load-helpers';
|
||||||
|
|
||||||
|
|
||||||
export function componentTest(name, opts) {
|
export function componentTest(name, opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
test(name, function(assert) {
|
test(name, function(assert) {
|
||||||
initializer.initialize(this.container, this.registry);
|
initializer.initialize(this.registry);
|
||||||
|
|
||||||
if (opts.setup) {
|
if (opts.setup) {
|
||||||
opts.setup.call(this);
|
opts.setup.call(this);
|
||||||
|
@ -8,7 +8,7 @@ export default function() {
|
|||||||
Ember.run(() => app = Wizard.create({ rootElement: '#ember-testing' }));
|
Ember.run(() => app = Wizard.create({ rootElement: '#ember-testing' }));
|
||||||
|
|
||||||
if (!started) {
|
if (!started) {
|
||||||
initializer.initialize(app.__container__, app.registry);
|
initializer.initialize(app);
|
||||||
app.start();
|
app.start();
|
||||||
started = true;
|
started = true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import WizardField from 'wizard/models/wizard-field';
|
import WizardField from 'wizard/models/wizard-field';
|
||||||
|
|
||||||
module("model:wizard-field");
|
moduleFor("model:wizard-field");
|
||||||
|
|
||||||
test('basic state', assert => {
|
test('basic state', assert => {
|
||||||
const w = WizardField.create({ type: 'text' });
|
const w = WizardField.create({ type: 'text' });
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
//= require pretender
|
//= require pretender
|
||||||
//= require ./wizard-pretender
|
//= require ./wizard-pretender
|
||||||
|
|
||||||
|
|
||||||
// Trick JSHint into allow document.write
|
// Trick JSHint into allow document.write
|
||||||
var d = document;
|
var d = document;
|
||||||
d.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
|
d.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
|
||||||
@ -44,10 +45,9 @@ QUnit.testDone(function() {
|
|||||||
server.shutdown();
|
server.shutdown();
|
||||||
});
|
});
|
||||||
|
|
||||||
require('wizard/test/helpers/start-app').default();
|
var _testApp = require('wizard/test/helpers/start-app').default();
|
||||||
|
var _buildResolver = require('discourse-common/resolver').buildResolver;
|
||||||
var buildResolver = require('discourse-common/resolver').buildResolver;
|
window.setResolver(_buildResolver('wizard').create({ namespace: _testApp }));
|
||||||
window.setResolver(buildResolver('wizard').create());
|
|
||||||
|
|
||||||
Object.keys(requirejs.entries).forEach(function(entry) {
|
Object.keys(requirejs.entries).forEach(function(entry) {
|
||||||
if ((/\-test/).test(entry)) {
|
if ((/\-test/).test(entry)) {
|
||||||
|
642
vendor/assets/javascripts/ember-qunit.js
vendored
642
vendor/assets/javascripts/ember-qunit.js
vendored
@ -301,24 +301,163 @@ define('ember-qunit/test', ['exports', 'ember-qunit/test-wrapper', 'qunit'], fun
|
|||||||
exports['default'] = test;
|
exports['default'] = test;
|
||||||
|
|
||||||
});
|
});
|
||||||
define('ember-test-helpers', ['exports', 'ember', 'ember-test-helpers/test-module', '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, TestModule, TestModuleForComponent, TestModuleForModel, test_context, test_resolver) {
|
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, TestModule, TestModuleForAcceptance, TestModuleForIntegration, TestModuleForComponent, TestModuleForModel, test_context, test_resolver) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
Ember['default'].testing = true;
|
Ember['default'].testing = true;
|
||||||
|
|
||||||
exports.TestModule = TestModule['default'];
|
exports.TestModule = TestModule['default'];
|
||||||
|
exports.TestModuleForAcceptance = TestModuleForAcceptance['default'];
|
||||||
|
exports.TestModuleForIntegration = TestModuleForIntegration['default'];
|
||||||
exports.TestModuleForComponent = TestModuleForComponent['default'];
|
exports.TestModuleForComponent = TestModuleForComponent['default'];
|
||||||
exports.TestModuleForModel = TestModuleForModel['default'];
|
exports.TestModuleForModel = TestModuleForModel['default'];
|
||||||
exports.getContext = test_context.getContext;
|
exports.getContext = test_context.getContext;
|
||||||
exports.setContext = test_context.setContext;
|
exports.setContext = test_context.setContext;
|
||||||
exports.setResolver = test_resolver.setResolver;
|
exports.setResolver = test_resolver.setResolver;
|
||||||
|
|
||||||
|
});
|
||||||
|
define('ember-test-helpers/abstract-test-module', ['exports', 'klassy', 'ember-test-helpers/wait', 'ember-test-helpers/test-context', 'ember'], function (exports, klassy, wait, test_context, Ember) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
exports['default'] = klassy.Klass.extend({
|
||||||
|
init(name, options) {
|
||||||
|
this.name = name;
|
||||||
|
this.callbacks = options || {};
|
||||||
|
|
||||||
|
this.initSetupSteps();
|
||||||
|
this.initTeardownSteps();
|
||||||
|
},
|
||||||
|
|
||||||
|
setup(assert) {
|
||||||
|
return this.invokeSteps(this.setupSteps, this, assert).then(() => {
|
||||||
|
this.contextualizeCallbacks();
|
||||||
|
return this.invokeSteps(this.contextualizedSetupSteps, this.context, assert);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
teardown(assert) {
|
||||||
|
return this.invokeSteps(this.contextualizedTeardownSteps, this.context, assert).then(() => {
|
||||||
|
return this.invokeSteps(this.teardownSteps, this, assert);
|
||||||
|
}).then(() => {
|
||||||
|
this.cache = null;
|
||||||
|
this.cachedCalls = null;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
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((resolve) => {
|
||||||
|
resolve(step.call(context, assert));
|
||||||
|
}).then(nextStep);
|
||||||
|
} else {
|
||||||
|
return Ember['default'].RSVP.resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nextStep();
|
||||||
|
},
|
||||||
|
|
||||||
|
contextualizeCallbacks() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setupTestElements() {
|
||||||
|
if (Ember['default'].$('#ember-testing').length === 0) {
|
||||||
|
Ember['default'].$('<div id="ember-testing"/>').appendTo(document.body);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setupContext(options) {
|
||||||
|
var config = Ember['default'].merge({
|
||||||
|
dispatcher: null,
|
||||||
|
inject: {}
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
test_context.setContext(config);
|
||||||
|
},
|
||||||
|
|
||||||
|
setupAJAXListeners() {
|
||||||
|
wait._setupAJAXHooks();
|
||||||
|
},
|
||||||
|
|
||||||
|
teardownAJAXListeners() {
|
||||||
|
wait._teardownAJAXHooks();
|
||||||
|
},
|
||||||
|
|
||||||
|
teardownTestElements() {
|
||||||
|
Ember['default'].$('#ember-testing').empty();
|
||||||
|
|
||||||
|
// 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 = {};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
teardownContext() {
|
||||||
|
var context = this.context;
|
||||||
|
this.context = undefined;
|
||||||
|
test_context.unsetContext();
|
||||||
|
|
||||||
|
if (context && context.dispatcher && !context.dispatcher.isDestroyed) {
|
||||||
|
Ember['default'].run(function() {
|
||||||
|
context.dispatcher.destroy();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
define('ember-test-helpers/build-registry', ['exports', 'ember'], function (exports, Ember) {
|
define('ember-test-helpers/build-registry', ['exports', 'ember'], function (exports, Ember) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/* globals global, self, requirejs, require */
|
||||||
|
|
||||||
function exposeRegistryMethodsWithoutDeprecations(container) {
|
function exposeRegistryMethodsWithoutDeprecations(container) {
|
||||||
var methods = [
|
var methods = [
|
||||||
'register',
|
'register',
|
||||||
@ -415,7 +554,15 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
|
|||||||
}
|
}
|
||||||
|
|
||||||
var globalContext = typeof global === 'object' && global || self;
|
var globalContext = typeof global === 'object' && global || self;
|
||||||
if (globalContext.DS) {
|
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;
|
var DS = globalContext.DS;
|
||||||
if (DS._setupContainer) {
|
if (DS._setupContainer) {
|
||||||
DS._setupContainer(registry || container);
|
DS._setupContainer(registry || container);
|
||||||
@ -473,7 +620,39 @@ define('ember-test-helpers/test-context', ['exports'], function (exports) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-helpers/test-module', 'ember', 'ember-test-helpers/test-resolver'], function (exports, TestModule, Ember, test_resolver) {
|
define('ember-test-helpers/test-module-for-acceptance', ['exports', 'ember-test-helpers/abstract-test-module', 'ember', 'ember-test-helpers/test-context'], function (exports, AbstractTestModule, Ember, test_context) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
exports['default'] = AbstractTestModule['default'].extend({
|
||||||
|
setupContext() {
|
||||||
|
this._super({ application: this.createApplication() });
|
||||||
|
},
|
||||||
|
|
||||||
|
teardownContext() {
|
||||||
|
Ember['default'].run(() => {
|
||||||
|
test_context.getContext().application.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
this._super();
|
||||||
|
},
|
||||||
|
|
||||||
|
createApplication() {
|
||||||
|
let { Application, config } = this.callbacks;
|
||||||
|
let application;
|
||||||
|
|
||||||
|
Ember['default'].run(() => {
|
||||||
|
application = Application.create(config);
|
||||||
|
application.setupForTesting();
|
||||||
|
application.injectTestHelpers();
|
||||||
|
});
|
||||||
|
|
||||||
|
return application;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-helpers/test-module', 'ember', 'ember-test-helpers/test-resolver', 'ember-test-helpers/has-ember-version'], function (exports, TestModule, Ember, test_resolver, hasEmberVersion) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -521,7 +700,7 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
|
|||||||
this.setupSteps.push(this.setupComponentUnitTest);
|
this.setupSteps.push(this.setupComponentUnitTest);
|
||||||
} else {
|
} else {
|
||||||
this.callbacks.subject = function() {
|
this.callbacks.subject = function() {
|
||||||
throw new Error("component integration tests do not support `subject()`.");
|
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.setupSteps.push(this.setupComponentIntegrationTest);
|
||||||
this.teardownSteps.unshift(this.teardownComponent);
|
this.teardownSteps.unshift(this.teardownComponent);
|
||||||
@ -635,15 +814,23 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
|
|||||||
};
|
};
|
||||||
|
|
||||||
context.set = function(key, value) {
|
context.set = function(key, value) {
|
||||||
Ember['default'].run(function() {
|
var ret = Ember['default'].run(function() {
|
||||||
Ember['default'].set(context, key, value);
|
return Ember['default'].set(context, key, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (hasEmberVersion['default'](2,0)) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
context.setProperties = function(hash) {
|
context.setProperties = function(hash) {
|
||||||
Ember['default'].run(function() {
|
var ret = Ember['default'].run(function() {
|
||||||
Ember['default'].setProperties(context, hash);
|
return Ember['default'].setProperties(context, hash);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (hasEmberVersion['default'](2,0)) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
context.get = function(key) {
|
context.get = function(key) {
|
||||||
@ -658,6 +845,7 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
|
|||||||
context.on = function(actionName, handler) {
|
context.on = function(actionName, handler) {
|
||||||
module.actionHooks[actionName] = handler;
|
module.actionHooks[actionName] = handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
context.send = function(actionName) {
|
context.send = function(actionName) {
|
||||||
var hook = module.actionHooks[actionName];
|
var hook = module.actionHooks[actionName];
|
||||||
if (!hook) {
|
if (!hook) {
|
||||||
@ -665,6 +853,10 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
|
|||||||
}
|
}
|
||||||
hook.apply(module, Array.prototype.slice.call(arguments, 1));
|
hook.apply(module, Array.prototype.slice.call(arguments, 1));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
context.clearRender = function() {
|
||||||
|
module.teardownComponent();
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
setupContext: function() {
|
setupContext: function() {
|
||||||
@ -691,11 +883,275 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
define('ember-test-helpers/test-module-for-integration', ['exports', 'ember', 'ember-test-helpers/test-context', 'ember-test-helpers/abstract-test-module', 'ember-test-helpers/test-resolver', 'ember-test-helpers/build-registry', 'ember-test-helpers/has-ember-version'], function (exports, Ember, test_context, AbstractTestModule, test_resolver, buildRegistry, hasEmberVersion) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
exports['default'] = AbstractTestModule['default'].extend({
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setupContainer() {
|
||||||
|
var resolver = test_resolver.getResolver();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setupContext() {
|
||||||
|
var subjectName = this.subjectName;
|
||||||
|
var container = this.container;
|
||||||
|
|
||||||
|
var factory = function() {
|
||||||
|
return container.lookupFactory(subjectName);
|
||||||
|
};
|
||||||
|
|
||||||
|
this._super({
|
||||||
|
container: this.container,
|
||||||
|
registry: this.registry,
|
||||||
|
factory: factory,
|
||||||
|
register() {
|
||||||
|
var target = this.registry || this.container;
|
||||||
|
return target.register.apply(target, arguments);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
var context = this.context = test_context.getContext();
|
||||||
|
|
||||||
|
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'].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');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setupComponentIntegrationTest: function() {
|
||||||
|
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) {
|
||||||
|
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.$ = 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();
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
teardownComponent: function() {
|
||||||
|
var component = this.component;
|
||||||
|
if (component) {
|
||||||
|
Ember['default'].run(function() {
|
||||||
|
component.destroy();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
teardownContainer() {
|
||||||
|
var container = this.container;
|
||||||
|
Ember['default'].run(function() {
|
||||||
|
container.destroy();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// allow arbitrary named factories, like rspec let
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_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;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
_aliasViewRegistry: function() {
|
||||||
|
this._originalGlobalViewRegistry = Ember['default'].View.views;
|
||||||
|
var viewRegistry = this.container.lookup('-view-registry:main');
|
||||||
|
|
||||||
|
if (viewRegistry) {
|
||||||
|
Ember['default'].View.views = viewRegistry;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_resetViewRegistry: function() {
|
||||||
|
Ember['default'].View.views = this._originalGlobalViewRegistry;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
define('ember-test-helpers/test-module-for-model', ['exports', 'ember-test-helpers/test-module', 'ember'], function (exports, TestModule, Ember) {
|
define('ember-test-helpers/test-module-for-model', ['exports', 'ember-test-helpers/test-module', 'ember'], function (exports, TestModule, Ember) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/* global DS, require, requirejs */ // added here to prevent an import from erroring when ED is not present
|
||||||
|
|
||||||
exports['default'] = TestModule['default'].extend({
|
exports['default'] = TestModule['default'].extend({
|
||||||
init: function(modelName, description, callbacks) {
|
init: function(modelName, description, callbacks) {
|
||||||
this.modelName = modelName;
|
this.modelName = modelName;
|
||||||
@ -713,7 +1169,17 @@ define('ember-test-helpers/test-module-for-model', ['exports', 'ember-test-helpe
|
|||||||
|
|
||||||
var adapterFactory = container.lookupFactory('adapter:application');
|
var adapterFactory = container.lookupFactory('adapter:application');
|
||||||
if (!adapterFactory) {
|
if (!adapterFactory) {
|
||||||
adapterFactory = DS.JSONAPIAdapter || DS.FixtureAdapter;
|
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;
|
var thingToRegisterWith = this.registry || this.container;
|
||||||
thingToRegisterWith.register('adapter:application', adapterFactory);
|
thingToRegisterWith.register('adapter:application', adapterFactory);
|
||||||
@ -739,11 +1205,11 @@ define('ember-test-helpers/test-module-for-model', ['exports', 'ember-test-helpe
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helpers/test-context', 'klassy', 'ember-test-helpers/test-resolver', 'ember-test-helpers/build-registry', 'ember-test-helpers/has-ember-version', 'ember-test-helpers/wait'], function (exports, Ember, test_context, klassy, test_resolver, buildRegistry, hasEmberVersion, wait) {
|
define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helpers/test-context', 'ember-test-helpers/abstract-test-module', 'ember-test-helpers/test-resolver', 'ember-test-helpers/build-registry', 'ember-test-helpers/has-ember-version'], function (exports, Ember, test_context, AbstractTestModule, test_resolver, buildRegistry, hasEmberVersion) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
exports['default'] = klassy.Klass.extend({
|
exports['default'] = AbstractTestModule['default'].extend({
|
||||||
init: function(subjectName, description, callbacks) {
|
init: function(subjectName, description, callbacks) {
|
||||||
// Allow `description` to be omitted, in which case it should
|
// Allow `description` to be omitted, in which case it should
|
||||||
// default to `subjectName`
|
// default to `subjectName`
|
||||||
@ -834,44 +1300,6 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setup: function() {
|
|
||||||
var self = this;
|
|
||||||
return self.invokeSteps(self.setupSteps).then(function() {
|
|
||||||
self.contextualizeCallbacks();
|
|
||||||
return self.invokeSteps(self.contextualizedSetupSteps, self.context);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
teardown: function() {
|
|
||||||
var self = this;
|
|
||||||
return self.invokeSteps(self.contextualizedTeardownSteps, self.context).then(function() {
|
|
||||||
return self.invokeSteps(self.teardownSteps);
|
|
||||||
}).then(function() {
|
|
||||||
self.cache = null;
|
|
||||||
self.cachedCalls = null;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
invokeSteps: function(steps, _context) {
|
|
||||||
var context = _context;
|
|
||||||
if (!context) {
|
|
||||||
context = this;
|
|
||||||
}
|
|
||||||
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(ok) {
|
|
||||||
ok(step.call(context));
|
|
||||||
}).then(nextStep);
|
|
||||||
} else {
|
|
||||||
return Ember['default'].RSVP.resolve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nextStep();
|
|
||||||
},
|
|
||||||
|
|
||||||
setupContainer: function() {
|
setupContainer: function() {
|
||||||
if (this.isIntegration || this.isLegacy) {
|
if (this.isIntegration || this.isLegacy) {
|
||||||
this._setupIntegratedContainer();
|
this._setupIntegratedContainer();
|
||||||
@ -888,16 +1316,14 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
|
|||||||
return container.lookupFactory(subjectName);
|
return container.lookupFactory(subjectName);
|
||||||
};
|
};
|
||||||
|
|
||||||
test_context.setContext({
|
this._super({
|
||||||
container: this.container,
|
container: this.container,
|
||||||
registry: this.registry,
|
registry: this.registry,
|
||||||
factory: factory,
|
factory: factory,
|
||||||
dispatcher: null,
|
|
||||||
register: function() {
|
register: function() {
|
||||||
var target = this.registry || this.container;
|
var target = this.registry || this.container;
|
||||||
return target.register.apply(target, arguments);
|
return target.register.apply(target, arguments);
|
||||||
},
|
},
|
||||||
inject: {}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var context = this.context = test_context.getContext();
|
var context = this.context = test_context.getContext();
|
||||||
@ -917,16 +1343,6 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setupTestElements: function() {
|
|
||||||
if (Ember['default'].$('#ember-testing').length === 0) {
|
|
||||||
Ember['default'].$('<div id="ember-testing"/>').appendTo(document.body);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setupAJAXListeners: function() {
|
|
||||||
wait._setupAJAXHooks();
|
|
||||||
},
|
|
||||||
|
|
||||||
teardownSubject: function() {
|
teardownSubject: function() {
|
||||||
var subject = this.cache.subject;
|
var subject = this.cache.subject;
|
||||||
|
|
||||||
@ -944,63 +1360,73 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
teardownContext: function() {
|
|
||||||
var context = this.context;
|
|
||||||
this.context = undefined;
|
|
||||||
test_context.unsetContext();
|
|
||||||
|
|
||||||
if (context.dispatcher && !context.dispatcher.isDestroyed) {
|
|
||||||
Ember['default'].run(function() {
|
|
||||||
context.dispatcher.destroy();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
teardownTestElements: function() {
|
|
||||||
Ember['default'].$('#ember-testing').empty();
|
|
||||||
|
|
||||||
// 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 = {};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
teardownAJAXListeners: function() {
|
|
||||||
wait._teardownAJAXHooks();
|
|
||||||
},
|
|
||||||
|
|
||||||
defaultSubject: function(options, factory) {
|
defaultSubject: function(options, factory) {
|
||||||
return factory.create(options);
|
return factory.create(options);
|
||||||
},
|
},
|
||||||
|
|
||||||
// allow arbitrary named factories, like rspec let
|
// allow arbitrary named factories, like rspec let
|
||||||
contextualizeCallbacks: function() {
|
contextualizeCallbacks: function() {
|
||||||
var _this = this;
|
|
||||||
var callbacks = this.callbacks;
|
var callbacks = this.callbacks;
|
||||||
var context = this.context;
|
var context = this.context;
|
||||||
var factory = context.factory;
|
|
||||||
|
|
||||||
this.cache = this.cache || {};
|
this.cache = this.cache || {};
|
||||||
this.cachedCalls = this.cachedCalls || {};
|
this.cachedCalls = this.cachedCalls || {};
|
||||||
|
|
||||||
var keys = (Object.keys || Ember['default'].keys)(callbacks);
|
var keys = (Object.keys || Ember['default'].keys)(callbacks);
|
||||||
|
var keysLength = keys.length;
|
||||||
|
|
||||||
for (var i = 0, l = keys.length; i < l; i++) {
|
if (keysLength) {
|
||||||
(function(key) {
|
var deprecatedContext = this._buildDeprecatedContext(this, context);
|
||||||
|
for (var i = 0; i < keysLength; i++) {
|
||||||
|
this._contextualizeCallback(context, keys[i], deprecatedContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
context[key] = function(options) {
|
_contextualizeCallback: function(context, key, callbackContext) {
|
||||||
if (_this.cachedCalls[key]) { return _this.cache[key]; }
|
var _this = this;
|
||||||
|
var callbacks = this.callbacks;
|
||||||
|
var factory = context.factory;
|
||||||
|
|
||||||
var result = callbacks[key].call(_this, options, factory());
|
context[key] = function(options) {
|
||||||
|
if (_this.cachedCalls[key]) { return _this.cache[key]; }
|
||||||
|
|
||||||
_this.cache[key] = result;
|
var result = callbacks[key].call(callbackContext, options, factory());
|
||||||
_this.cachedCalls[key] = true;
|
|
||||||
|
|
||||||
return result;
|
_this.cache[key] = result;
|
||||||
};
|
_this.cachedCalls[key] = true;
|
||||||
|
|
||||||
})(keys[i]);
|
return result;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Builds a version of the passed in context that contains deprecation warnings
|
||||||
|
for accessing properties that exist on the module.
|
||||||
|
*/
|
||||||
|
_buildDeprecatedContext: function(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.
|
||||||
|
*/
|
||||||
|
_proxyDeprecation: function(obj, proxy, key) {
|
||||||
|
if (typeof proxy[key] === 'undefined') {
|
||||||
|
Object.defineProperty(proxy, key, {
|
||||||
|
get: function() {
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1062,7 +1488,10 @@ define('ember-test-helpers/test-resolver', ['exports'], function (exports) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getResolver() {
|
function getResolver() {
|
||||||
if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
|
if (__resolver__ == null) {
|
||||||
|
throw new Error('you must set a resolver with `testResolver.set(resolver)`');
|
||||||
|
}
|
||||||
|
|
||||||
return __resolver__;
|
return __resolver__;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1074,6 +1503,8 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
|
|||||||
exports._teardownAJAXHooks = _teardownAJAXHooks;
|
exports._teardownAJAXHooks = _teardownAJAXHooks;
|
||||||
exports._setupAJAXHooks = _setupAJAXHooks;
|
exports._setupAJAXHooks = _setupAJAXHooks;
|
||||||
|
|
||||||
|
/* globals jQuery, self */
|
||||||
|
|
||||||
var requests;
|
var requests;
|
||||||
function incrementAjaxPendingRequests(_, xhr) {
|
function incrementAjaxPendingRequests(_, xhr) {
|
||||||
requests.push(xhr);
|
requests.push(xhr);
|
||||||
@ -1103,6 +1534,7 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
|
|||||||
var options = _options || {};
|
var options = _options || {};
|
||||||
var waitForTimers = options.hasOwnProperty('waitForTimers') ? options.waitForTimers : true;
|
var waitForTimers = options.hasOwnProperty('waitForTimers') ? options.waitForTimers : true;
|
||||||
var waitForAJAX = options.hasOwnProperty('waitForAJAX') ? options.waitForAJAX : 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) {
|
return new Ember['default'].RSVP.Promise(function(resolve) {
|
||||||
var watcher = self.setInterval(function() {
|
var watcher = self.setInterval(function() {
|
||||||
@ -1114,6 +1546,12 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (waitForWaiters && Ember['default'].Test.waiters && Ember['default'].Test.waiters.any(([context, callback]) => {
|
||||||
|
return !callback.call(context);
|
||||||
|
})) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Stop polling
|
// Stop polling
|
||||||
self.clearInterval(watcher);
|
self.clearInterval(watcher);
|
||||||
|
|
||||||
@ -1310,4 +1748,4 @@ window.test = emberQunit.test;
|
|||||||
window.setResolver = emberQunit.setResolver;
|
window.setResolver = emberQunit.setResolver;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
//# sourceMappingURL=ember-qunit.map
|
//# sourceMappingURL=ember-qunit.map
|
||||||
|
4334
vendor/assets/javascripts/qunit.js
vendored
Normal file
4334
vendor/assets/javascripts/qunit.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user