From f0d30380b304cd46a181eb44ccfc65e5f64beda8 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Sat, 30 Jan 2016 18:53:40 -0500 Subject: [PATCH 1/3] Add `clearRender` method to allow testing of willDestroyElement. --- .../test-module-for-component.js | 4 +++ .../test-module-for-integration.js | 4 +++ tests/test-module-for-component-test.js | 25 +++++++++++++++++-- tests/test-module-for-integration-test.js | 22 ++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/lib/ember-test-helpers/test-module-for-component.js b/lib/ember-test-helpers/test-module-for-component.js index ab163442b..5e40a68b0 100644 --- a/lib/ember-test-helpers/test-module-for-component.js +++ b/lib/ember-test-helpers/test-module-for-component.js @@ -200,6 +200,10 @@ export default TestModule.extend({ } hook.apply(module, Array.prototype.slice.call(arguments, 1)); }; + + context.clearRender = function() { + module.teardownComponent(); + }; }, setupContext: function() { diff --git a/lib/ember-test-helpers/test-module-for-integration.js b/lib/ember-test-helpers/test-module-for-integration.js index f3959569c..06dac9014 100644 --- a/lib/ember-test-helpers/test-module-for-integration.js +++ b/lib/ember-test-helpers/test-module-for-integration.js @@ -191,6 +191,10 @@ export default AbstractTestModule.extend({ } hook.apply(module, Array.prototype.slice.call(arguments, 1)); }; + + context.clearRender = function() { + module.teardownComponent(); + }; }, teardownComponent: function() { diff --git a/tests/test-module-for-component-test.js b/tests/test-module-for-component-test.js index 53dbb7b94..76fe2d050 100644 --- a/tests/test-module-for-component-test.js +++ b/tests/test-module-for-component-test.js @@ -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'); - } - + } }) }); } @@ -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)) { diff --git a/tests/test-module-for-integration-test.js b/tests/test-module-for-integration-test.js index eb340ba7a..e06342af7 100644 --- a/tests/test-module-for-integration-test.js +++ b/tests/test-module-for-integration-test.js @@ -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'); +}); From d4ae2469c991a65c2ca938e07d5dc7a38cf44045 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Sat, 30 Jan 2016 19:19:29 -0500 Subject: [PATCH 2/3] Use valid SPDX license names. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 73af0f99c..ad5110e49 100644 --- a/package.json +++ b/package.json @@ -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", From e7f65296b627903ebc75741ca5b9412ad83f6b48 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Sat, 30 Jan 2016 19:23:48 -0500 Subject: [PATCH 3/3] Update `npm` upon install. "stable" is getting npm 3.3.12, which is pretty broken. This updates to latest stable... --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a765b5aa6..522e73ab8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: - 'stable' install: + - npm install -g npm - npm install -g bower - npm install --no-optional - bower install