-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
will-destroy does not invoke re-rendering #18
Comments
You need to add an import { settled } from '@ember/test-helpers';
// trigger destroying. should change text.
this.set('show', false);
await settled();
This is because setting the state does not synchronously update anything, it schedules a rerender that we must wait for. |
Thank you @pzuraq! I added an ...
// did-insert invokes re-rendering correctly, now the message is "Hello".
assert.strictEqual(find('[data-dummy]').innerText, 'Hello');
// trigger destroy. should change text.
this.set('show', false);
await settled();
// will-destroy does not invoke re-rendering. message supposed to be "World".
assert.strictEqual(find('[data-dummy]').innerText, 'Hello');
await click('[data-button]');
// if the changeText function is called by other ways, it works seamlessly.
assert.strictEqual(find('[data-dummy]').innerText, 'World');
... Also, I created this test case is because I had this issue while developing components in the app, but not having the issue while writing tests. The test case here is just a proof of concept that this issue exists. |
Ah, for sure. Can you PR this test case to this repo? That way we can add it permanently to make sure that this doesn't happen again. |
@pzuraq see #19 (comment) |
This happened when I tried to write a HOC with a parent passing a function to its child, and the function gets called when the child is inserted and going to be destroyed. I made an integration test to demonstrate the issue.
Also attached some dependencies info here.
The text was updated successfully, but these errors were encountered: