Scene test: pin the stand-down of a replaced rebuild deterministically
All checks were successful
Build pull request / Build pull request (pull_request) Successful in 3m44s
All checks were successful
Build pull request / Build pull request (pull_request) Successful in 3m44s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1b101c2889
commit
a61252e664
1 changed files with 13 additions and 0 deletions
|
|
@ -200,6 +200,19 @@ describe('startBackgroundScene follows the sky state', () => {
|
|||
expect(live.dispose).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('a rebuild for a sky that was replaced while its key was awaited builds nothing: only the newest sky is built', async () => {
|
||||
createRidgeScene.mockReturnValueOnce(fakeScene()).mockReturnValueOnce(fakeScene());
|
||||
createRidgeScene.mockReturnValue(fakeScene());
|
||||
const scene = await startBackgroundScene(config, caps, { canvas });
|
||||
setSkyState('day');
|
||||
setSkyState('dusk');
|
||||
await flush();
|
||||
// The initial build and one rebuild, for dusk; day's rebuild stood down before building anything.
|
||||
expect(createRidgeScene).toHaveBeenCalledTimes(2);
|
||||
expect(hex(createRidgeScene.mock.calls[1][0].sky.top)).toBe(hex(ridgeSkyFor('dusk').top));
|
||||
scene?.dispose();
|
||||
});
|
||||
|
||||
// A second sky change `ticks` microtasks after the first. True when it landed mid-build: the build for the first
|
||||
// change finished, was found stale and dropped (never shown), and only the newest sky was announced.
|
||||
const changeAfter = async (ticks: number) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue