-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16087 from rwjblue/visit-async
[BUGFIX beta] Ensure `App.visit` resolves when rendering completed.
- Loading branch information
Showing
7 changed files
with
121 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/ember-glimmer/tests/integration/render-settled-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { | ||
RenderingTestCase, | ||
moduleFor, | ||
strip | ||
} from 'internal-test-helpers'; | ||
import { renderSettled } from 'ember-glimmer'; | ||
import { all } from 'rsvp'; | ||
import { run } from 'ember-metal'; | ||
|
||
moduleFor('renderSettled', class extends RenderingTestCase { | ||
['@test resolves when no rendering is happening'](assert) { | ||
return renderSettled().then(() => { | ||
assert.ok(true, 'resolved even without rendering'); | ||
}); | ||
} | ||
|
||
['@test resolves renderers exist but no runloops are triggered'](assert) { | ||
this.render(strip`{{foo}}`, { foo: 'bar' }); | ||
|
||
return renderSettled().then(() => { | ||
assert.ok(true, 'resolved even without runloops'); | ||
}); | ||
} | ||
|
||
['@test does not create extraneous promises'](assert) { | ||
let first = renderSettled(); | ||
let second = renderSettled(); | ||
|
||
assert.strictEqual(first, second); | ||
|
||
return all([first, second]); | ||
} | ||
|
||
['@test resolves when rendering has completed (after property update)']() { | ||
this.render(strip`{{foo}}`, { foo: 'bar' }); | ||
|
||
this.assertText('bar'); | ||
this.component.set('foo', 'baz'); | ||
this.assertText('bar'); | ||
|
||
return renderSettled().then(() => { | ||
this.assertText('baz'); | ||
}); | ||
} | ||
|
||
['@test resolves in run loop when renderer has settled'](assert) { | ||
assert.expect(3); | ||
|
||
this.render(strip`{{foo}}`, { foo: 'bar' }); | ||
|
||
this.assertText('bar'); | ||
let promise; | ||
|
||
return run(() => { | ||
run.schedule('actions', null, () => { | ||
this.component.set('foo', 'set in actions'); | ||
|
||
promise = renderSettled().then(() => { | ||
this.assertText('set in afterRender'); | ||
}); | ||
|
||
run.schedule('afterRender', null, () => { | ||
this.component.set('foo', 'set in afterRender'); | ||
}); | ||
}); | ||
|
||
// still not updated here | ||
this.assertText('bar'); | ||
|
||
return promise; | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters