Skip to content

Commit

Permalink
Merge pull request #104 from tsing80/fix-teardownstep
Browse files Browse the repository at this point in the history
prepend tear down steps like tearDownForComponent in the begining of tearDownSteps array
  • Loading branch information
rwjblue committed Oct 9, 2015
2 parents 50ada04 + 28bedfc commit 9f961d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ember-test-helpers/test-module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export default TestModule.extend({
throw new Error("component integration tests do not support `subject()`.");
};
this.setupSteps.push(this.setupComponentIntegrationTest);
this.teardownSteps.push(this.teardownComponent);
this.teardownSteps.unshift(this.teardownComponent);
}

if (Ember.View && Ember.View.views) {
this.setupSteps.push(this._aliasViewRegistry);
this.teardownSteps.push(this._resetViewRegistry);
this.teardownSteps.unshift(this._resetViewRegistry);
}
},

Expand Down
23 changes: 23 additions & 0 deletions tests/test-module-for-integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,26 @@ test('can inject a service directly into test context, with aliased name', funct
this.set('hornedBeast.sparkliness', 'amazing');
equal(this.$('.x-foo').text().trim(), "amazing");
});

moduleForComponent('Component Integration Tests: willDestoryElement', {
integration: true,
beforeSetup: function() {
setResolverRegistry({
'component:my-component': Ember.Component.extend({
willDestroyElement: function() {
var stateIndicatesInDOM = (this._state === 'inDOM');
var actuallyInDOM = Ember.$.contains(document, this.$()[0]);

ok((actuallyInDOM === true) && (actuallyInDOM === stateIndicatesInDOM), 'component should still be in the DOM');
}

})
});
}
});

test('still in DOM in willDestroyElement', function() {
expect(1);
this.render("{{my-component}}");

});

0 comments on commit 9f961d7

Please sign in to comment.