Skip to content

Commit 665c733

Browse files
committed
Merge pull request #11864 from stefanpenner/ensure-test-helpers-are-auto-cleanedup
[BUGFIX release] ensure testHelpers are removed when the app is destr…
2 parents 9549f06 + 876aeea commit 665c733

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Diff for: packages/ember-testing/lib/test.js

+7
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ EmberApplication.reopen({
423423
this.helperContainer = window;
424424
}
425425

426+
this.reopen({
427+
willDestroy() {
428+
this._super(...arguments);
429+
this.removeTestHelpers();
430+
}
431+
});
432+
426433
this.testHelpers = {};
427434
for (var name in helpers) {
428435
this.originalMethods[name] = this.helperContainer[name];

Diff for: packages/ember-testing/tests/acceptance_test.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ QUnit.module('ember-testing Acceptance', {
9797
},
9898

9999
teardown() {
100-
App.removeTestHelpers();
101100
Test.unregisterHelper('slowHelper');
102101
jQuery('#ember-testing-container, #ember-testing').remove();
103102
run(App, App.destroy);
@@ -379,3 +378,28 @@ QUnit.test('visiting a URL and then visiting a second URL with a transition shou
379378
equal(currentURL(), '/comments', 'Redirected to Comments URL');
380379
});
381380
});
381+
382+
QUnit.module('ember-testing Acceptance – teardown');
383+
384+
QUnit.test('that the setup/teardown happens correct', function() {
385+
expect(2);
386+
387+
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');
388+
jQuery('<div id="ember-testing-container"><div id="ember-testing"></div></div>').appendTo('body');
389+
390+
run(function() {
391+
indexHitCount = 0;
392+
App = EmberApplication.create({
393+
rootElement: '#ember-testing'
394+
});
395+
});
396+
App.injectTestHelpers();
397+
398+
jQuery('#ember-testing-container, #ember-testing').remove();
399+
ok(typeof Test.Promise.prototype.click === 'function');
400+
run(App, App.destroy);
401+
equal(Test.Promise.prototype.click, undefined);
402+
App = null;
403+
Test.adapter = originalAdapter;
404+
indexHitCount = 0;
405+
});

0 commit comments

Comments
 (0)