Skip to content

Commit

Permalink
Merge pull request #196 from canufeel/fix/unit-deprecation
Browse files Browse the repository at this point in the history
Deprecation Warning thrown with `needs:[]`
  • Loading branch information
rwjblue authored Feb 14, 2017
2 parents c488adc + d533e82 commit 356dde4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/ember-test-helpers/test-module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ export default class extends TestModule {
}

let integrationOption = callbacks.integration;
let hasNeeds = Array.isArray(callbacks.needs);

super('component:' + componentName, description, callbacks);

this.componentName = componentName;

if (callbacks.needs || callbacks.unit || integrationOption === false) {
if (hasNeeds || callbacks.unit || integrationOption === false) {
this.isUnitTest = true;
} else if (integrationOption) {
this.isUnitTest = false;
Expand Down
25 changes: 25 additions & 0 deletions tests/test-module-for-component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var $ = Ember.$;

var Service = Ember.Service || Ember.Object;

const TEST_TYPE_DEPRECATION_ID = 'ember-test-helpers.test-module-for-component.test-type';

function moduleForComponent(name, description, callbacks) {
var module = new TestModuleForComponent(name, description, callbacks);
if (module.isIntegration) {
Expand Down Expand Up @@ -298,6 +300,29 @@ test('it allows missing callbacks', function() {
ok(true, 'no errors are thrown');
});

let deprecations = [];
QUnit.module('moduleForComponent: will not raise deprecation if needs is specified', {
beforeEach() {
originalDeprecate = Ember.deprecate;
Ember.deprecate = function() {
if (arguments.length === 3) {
deprecations.push(arguments[2].id);
}
}
},
afterEach() {
Ember.deprecate = originalDeprecate;
deprecations = [];
}
});

test('deprecation is not raised', function() {
setupRegistry();
testModule = new TestModuleForComponent('pretty-color', { needs: ['x:foo'] });
ok(deprecations.indexOf(TEST_TYPE_DEPRECATION_ID) === -1, `deprecation with id "${TEST_TYPE_DEPRECATION_ID}" should not be raised if needs is provided`);
ok(testModule.isUnitTest);
});

QUnit.module('moduleForComponent: can be invoked with the component name and description', {
beforeEach(assert) {
var done = assert.async();
Expand Down

0 comments on commit 356dde4

Please sign in to comment.