Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clearRender method to allow testing of willDestroyElement. #147

Merged
merged 3 commits into from
Jan 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_js:
- 'stable'

install:
- npm install -g npm
- npm install -g bower
- npm install --no-optional
- bower install
Expand Down
4 changes: 4 additions & 0 deletions lib/ember-test-helpers/test-module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ export default TestModule.extend({
}
hook.apply(module, Array.prototype.slice.call(arguments, 1));
};

context.clearRender = function() {
module.teardownComponent();
};
},

setupContext: function() {
Expand Down
4 changes: 4 additions & 0 deletions lib/ember-test-helpers/test-module-for-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ export default AbstractTestModule.extend({
}
hook.apply(module, Array.prototype.slice.call(arguments, 1));
};

context.clearRender = function() {
module.teardownComponent();
};
},

teardownComponent: function() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"Ryan Florence",
"Adolfo Builes"
],
"license": "Apache Version 2.0 and MIT",
"license": "(MIT OR Apache-2.0)",
"readmeFilename": "README.md",
"devDependencies": {
"broccoli-babel-transpiler": "^5.4.5",
Expand Down
25 changes: 23 additions & 2 deletions tests/test-module-for-component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,7 @@ moduleForComponent('Component Integration Tests: willDestoryElement', {
var actuallyInDOM = Ember.$.contains(document, this.$()[0]);

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

}
})
});
}
Expand All @@ -594,7 +593,29 @@ moduleForComponent('Component Integration Tests: willDestoryElement', {
test('still in DOM in willDestroyElement', function() {
expect(1);
this.render("{{my-component}}");
});

moduleForComponent('Component Integration Tests: force willDestroyElement via clearRender', {
integration: true,
beforeSetup: function() {
setResolverRegistry({});
}
});

test('still in DOM in willDestroyElement', function() {
expect(1);

let willDestroyCalled = false;
this.register('component:x-button', Ember.Component.extend({
willDestroyElement: function() {
willDestroyCalled = true;
}
}));

this.render("{{x-button}}");
this.clearRender();

ok(willDestroyCalled, 'can add assertions after willDestroyElement is called');
});

if (!hasEmberVersion(2,0)) {
Expand Down
22 changes: 22 additions & 0 deletions tests/test-module-for-integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,25 @@ test('still in DOM in willDestroyElement', function() {
this.render("{{my-component}}");

});

moduleForIntegration('TestModuleForIntegration: force willDestroyElement via clearRender', {
beforeSetup: function() {
setResolverRegistry({});
}
});

test('still in DOM in willDestroyElement', function() {
expect(1);

let willDestroyCalled = false;
this.register('component:x-button', Ember.Component.extend({
willDestroyElement: function() {
willDestroyCalled = true;
}
}));

this.render("{{x-button}}");
this.clearRender();

ok(willDestroyCalled, 'can add assertions after willDestroyElement is called');
});