Skip to content

Commit

Permalink
Merge pull request #11864 from stefanpenner/ensure-test-helpers-are-a…
Browse files Browse the repository at this point in the history
…uto-cleanedup

[BUGFIX release] ensure testHelpers are removed when the app is destr…
  • Loading branch information
mixonic committed Jul 23, 2015
2 parents 9549f06 + 876aeea commit 665c733
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/ember-testing/lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,13 @@ EmberApplication.reopen({
this.helperContainer = window;
}

this.reopen({
willDestroy() {
this._super(...arguments);
this.removeTestHelpers();
}
});

this.testHelpers = {};
for (var name in helpers) {
this.originalMethods[name] = this.helperContainer[name];
Expand Down
26 changes: 25 additions & 1 deletion packages/ember-testing/tests/acceptance_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ QUnit.module('ember-testing Acceptance', {
},

teardown() {
App.removeTestHelpers();
Test.unregisterHelper('slowHelper');
jQuery('#ember-testing-container, #ember-testing').remove();
run(App, App.destroy);
Expand Down Expand Up @@ -379,3 +378,28 @@ QUnit.test('visiting a URL and then visiting a second URL with a transition shou
equal(currentURL(), '/comments', 'Redirected to Comments URL');
});
});

QUnit.module('ember-testing Acceptance – teardown');

QUnit.test('that the setup/teardown happens correct', function() {
expect(2);

jQuery('<style>#ember-testing-container { position: absolute; background: white; bottom: 0; right: 0; width: 640px; height: 384px; overflow: auto; z-index: 9999; border: 1px solid #ccc; } #ember-testing { zoom: 50%; }</style>').appendTo('head');
jQuery('<div id="ember-testing-container"><div id="ember-testing"></div></div>').appendTo('body');

run(function() {
indexHitCount = 0;
App = EmberApplication.create({
rootElement: '#ember-testing'
});
});
App.injectTestHelpers();

jQuery('#ember-testing-container, #ember-testing').remove();
ok(typeof Test.Promise.prototype.click === 'function');
run(App, App.destroy);
equal(Test.Promise.prototype.click, undefined);
App = null;
Test.adapter = originalAdapter;
indexHitCount = 0;
});

0 comments on commit 665c733

Please sign in to comment.