More ember-qunit fixes
This commit is contained in:
parent
6a1c05a268
commit
7d560ea3d5
|
@ -36,22 +36,10 @@ export default function(name, opts) {
|
||||||
this.registry.register('store:main', store, { instantiate: false });
|
this.registry.register('store:main', store, { instantiate: false });
|
||||||
|
|
||||||
if (opts.setup) {
|
if (opts.setup) {
|
||||||
if (Ember.VERSION[0] === "2") {
|
|
||||||
// use closure actions instead
|
|
||||||
this.on = (actionName, fn) => this.set(actionName, fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
opts.setup.call(this, store);
|
opts.setup.call(this, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
// TODO: This shouldn't be necessary
|
|
||||||
this.owner = {
|
|
||||||
hasRegistration: (...args) => this.registry.has(...args),
|
|
||||||
lookup: (...args) => this.container.lookup(...args),
|
|
||||||
_lookupFactory: (...args) => this.container.lookupFactory(...args)
|
|
||||||
};
|
|
||||||
|
|
||||||
return this.render(opts.template);
|
return this.render(opts.template);
|
||||||
});
|
});
|
||||||
andThen(() => opts.test.call(this, assert));
|
andThen(() => opts.test.call(this, assert));
|
||||||
|
|
|
@ -159,8 +159,12 @@ define('ember-qunit/only', ['exports', 'ember-qunit/test-wrapper', 'qunit'], fun
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function only(testName, callback) {
|
function only(/* testName, expected, callback, async */) {
|
||||||
testWrapper['default'](testName, callback, qunit.only);
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) {
|
||||||
|
args[_key] = arguments[_key];
|
||||||
|
}
|
||||||
|
args.unshift(qunit.only);
|
||||||
|
testWrapper['default'].apply(null, args);
|
||||||
}
|
}
|
||||||
exports['default'] = only;
|
exports['default'] = only;
|
||||||
|
|
||||||
|
@ -240,7 +244,12 @@ define('ember-qunit/test-wrapper', ['exports', 'ember', 'ember-test-helpers'], f
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function testWrapper(testName, callback, qunit) {
|
function testWrapper(qunit /*, testName, expected, callback, async */) {
|
||||||
|
var callback;
|
||||||
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; ++_key) {
|
||||||
|
args[_key - 1] = arguments[_key];
|
||||||
|
}
|
||||||
|
|
||||||
function wrapper() {
|
function wrapper() {
|
||||||
var context = ember_test_helpers.getContext();
|
var context = ember_test_helpers.getContext();
|
||||||
|
|
||||||
|
@ -267,7 +276,13 @@ define('ember-qunit/test-wrapper', ['exports', 'ember', 'ember-test-helpers'], f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
qunit(testName, wrapper);
|
if (args.length === 2) {
|
||||||
|
callback = args.splice(1, 1, wrapper)[0];
|
||||||
|
} else {
|
||||||
|
callback = args.splice(2, 1, wrapper)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
qunit.apply(null, args);
|
||||||
}
|
}
|
||||||
exports['default'] = testWrapper;
|
exports['default'] = testWrapper;
|
||||||
|
|
||||||
|
@ -276,8 +291,12 @@ define('ember-qunit/test', ['exports', 'ember-qunit/test-wrapper', 'qunit'], fun
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function test(testName, callback) {
|
function test(/* testName, expected, callback, async */) {
|
||||||
testWrapper['default'](testName, callback, qunit.test);
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) {
|
||||||
|
args[_key] = arguments[_key];
|
||||||
|
}
|
||||||
|
args.unshift(qunit.test);
|
||||||
|
testWrapper['default'].apply(null, args);
|
||||||
}
|
}
|
||||||
exports['default'] = test;
|
exports['default'] = test;
|
||||||
|
|
||||||
|
@ -459,6 +478,8 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
exports['default'] = TestModule['default'].extend({
|
exports['default'] = TestModule['default'].extend({
|
||||||
|
isComponentTestModule: true,
|
||||||
|
|
||||||
init: function(componentName, description, callbacks) {
|
init: function(componentName, description, callbacks) {
|
||||||
// Allow `description` to be omitted
|
// Allow `description` to be omitted
|
||||||
if (!callbacks && typeof description === 'object') {
|
if (!callbacks && typeof description === 'object') {
|
||||||
|
@ -486,17 +507,17 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
|
||||||
this.isUnitTest = true;
|
this.isUnitTest = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isUnitTest) {
|
|
||||||
callbacks.integration = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (description) {
|
if (description) {
|
||||||
this._super.call(this, 'component:' + componentName, description, callbacks);
|
this._super.call(this, 'component:' + componentName, description, callbacks);
|
||||||
} else {
|
} else {
|
||||||
this._super.call(this, 'component:' + componentName, callbacks);
|
this._super.call(this, 'component:' + componentName, callbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isUnitTest) {
|
if (!this.isUnitTest && !this.isLegacy) {
|
||||||
|
callbacks.integration = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isUnitTest || this.isLegacy) {
|
||||||
this.setupSteps.push(this.setupComponentUnitTest);
|
this.setupSteps.push(this.setupComponentUnitTest);
|
||||||
} else {
|
} else {
|
||||||
this.callbacks.subject = function() {
|
this.callbacks.subject = function() {
|
||||||
|
@ -655,7 +676,7 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
|
||||||
(this.registry || this.container).injection('component', '_viewRegistry', '-view-registry:main');
|
(this.registry || this.container).injection('component', '_viewRegistry', '-view-registry:main');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isUnitTest) {
|
if (!this.isUnitTest && !this.isLegacy) {
|
||||||
this.context.factory = function() {};
|
this.context.factory = function() {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -741,7 +762,16 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.callbacks.integration) {
|
if (this.callbacks.integration) {
|
||||||
this.isIntegration = callbacks.integration;
|
if (this.isComponentTestModule) {
|
||||||
|
this.isLegacy = (callbacks.integration === 'legacy');
|
||||||
|
this.isIntegration = (callbacks.integration !== 'legacy');
|
||||||
|
} else {
|
||||||
|
if (callbacks.integration === 'legacy') {
|
||||||
|
throw new Error('`integration: \'legacy\'` is only valid for component tests.');
|
||||||
|
}
|
||||||
|
this.isIntegration = true;
|
||||||
|
}
|
||||||
|
|
||||||
delete callbacks.integration;
|
delete callbacks.integration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,7 +873,7 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
|
||||||
},
|
},
|
||||||
|
|
||||||
setupContainer: function() {
|
setupContainer: function() {
|
||||||
if (this.isIntegration) {
|
if (this.isIntegration || this.isLegacy) {
|
||||||
this._setupIntegratedContainer();
|
this._setupIntegratedContainer();
|
||||||
} else {
|
} else {
|
||||||
this._setupIsolatedContainer();
|
this._setupIsolatedContainer();
|
||||||
|
@ -974,9 +1004,14 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_setupContainer: function() {
|
_setupContainer: function(isolated) {
|
||||||
var resolver = test_resolver.getResolver();
|
var resolver = test_resolver.getResolver();
|
||||||
var items = buildRegistry['default'](resolver);
|
|
||||||
|
var items = buildRegistry['default'](!isolated ? resolver : Object.create(resolver, {
|
||||||
|
resolve: {
|
||||||
|
value: function() {}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
this.container = items.container;
|
this.container = items.container;
|
||||||
this.registry = items.registry;
|
this.registry = items.registry;
|
||||||
|
@ -991,7 +1026,7 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
|
||||||
|
|
||||||
_setupIsolatedContainer: function() {
|
_setupIsolatedContainer: function() {
|
||||||
var resolver = test_resolver.getResolver();
|
var resolver = test_resolver.getResolver();
|
||||||
this._setupContainer();
|
this._setupContainer(true);
|
||||||
|
|
||||||
var thingToRegisterWith = this.registry || this.container;
|
var thingToRegisterWith = this.registry || this.container;
|
||||||
|
|
||||||
|
@ -1001,9 +1036,7 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
|
||||||
thingToRegisterWith.register(fullName, resolver.resolve(normalizedFullName));
|
thingToRegisterWith.register(fullName, resolver.resolve(normalizedFullName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.registry) {
|
if (!this.registry) {
|
||||||
this.registry.fallback.resolver = function() {};
|
|
||||||
} else {
|
|
||||||
this.container.resolver = function() {};
|
this.container.resolver = function() {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue