mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] context tests: make them deterministic
We learn something new every day, and today is no exception. Promise.all of a pending promise does not actually resolve as fast as possible after the initial promise is completed, but a small delay after, because it is put on the macrotask queue or something like that (I assume) closes #480
This commit is contained in:
@@ -106,7 +106,7 @@ describe("Context", () => {
|
||||
expect(fixture.innerHTML).toBe("<div><span>321</span><span>321</span></div>");
|
||||
});
|
||||
|
||||
test("two async components on two levels are updated in parallel", async () => {
|
||||
test("two async components on two levels are updated (mostly) in parallel", async () => {
|
||||
const testContext = new Context({ value: 123 });
|
||||
const def = makeDeferred();
|
||||
const steps: string[] = [];
|
||||
@@ -151,6 +151,11 @@ describe("Context", () => {
|
||||
);
|
||||
def.resolve();
|
||||
await nextTick();
|
||||
// we need to wait for an extra tick because it could happen (even though it
|
||||
// is rare) that the second batch of renderings is not done yet, because
|
||||
// the initial promise has been given to the macrotask queue, so a small
|
||||
// delay happens.
|
||||
await nextTick();
|
||||
expect(steps).toEqual(["render", "render", "render"]);
|
||||
expect(fixture.innerHTML).toBe(
|
||||
"<div><span><p>321</p></span><div><span><p>321</p></span><span><p>321</p></span></div></div>"
|
||||
|
||||
Reference in New Issue
Block a user