parent
ed6765fbf6
commit
cda988217d
@ -1,30 +1,56 @@ |
|||||||
import { expect, test } from "vitest"; |
import { describe, expect, test } from "vitest"; |
||||||
import { createSignalObjectForShape } from "../js-land/connector/createSignalObjectForShape"; |
import { createSignalObjectForShape } from "../js-land/connector/createSignalObjectForShape"; |
||||||
|
|
||||||
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); |
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); |
||||||
|
|
||||||
// TODO: Redo
|
describe("Signal modification and propagation to backend with or without signal pooling", () => { |
||||||
test("shape object notification comes back to others", async () => { |
for (const withPooling of [true, false]) { |
||||||
const object1 = createSignalObjectForShape("Shape1"); |
test(`shape object notification comes back to others ${ |
||||||
const object2 = createSignalObjectForShape("Shape1"); |
withPooling ? "with" : "without" |
||||||
|
} signal pooling`, async () => {
|
||||||
const object3 = createSignalObjectForShape("Shape2"); |
const object1 = createSignalObjectForShape( |
||||||
const object4 = createSignalObjectForShape("Shape2"); |
"TestShape", |
||||||
|
undefined, |
||||||
wait(50); |
withPooling |
||||||
|
); |
||||||
// Update object 1 and expect object 2 to update as well.
|
const object2 = createSignalObjectForShape( |
||||||
object1()!.name = "Updated name from object1"; |
"TestShape", |
||||||
|
undefined, |
||||||
wait(30); |
withPooling |
||||||
expect(object2()!.name).toBe("Updated name from object1"); |
); |
||||||
|
|
||||||
// Expect object of different shape not to have changed.
|
const object3 = createSignalObjectForShape( |
||||||
expect(object3().name).toBe("Niko's cat"); |
"Shape2", |
||||||
|
undefined, |
||||||
// Update object 4 and expect object 3 with same shape to have updated.
|
withPooling |
||||||
object4()!.name = "Updated name from object4"; |
); |
||||||
|
const object4 = createSignalObjectForShape( |
||||||
wait(30); |
"Shape2", |
||||||
expect(object3()!.name).toBe("Updated name from object4"); |
undefined, |
||||||
|
withPooling |
||||||
|
); |
||||||
|
|
||||||
|
await wait(10); |
||||||
|
|
||||||
|
// Update object 1 and expect object 2 to update as well.
|
||||||
|
// @ts-expect-error
|
||||||
|
object1.name = "Updated name from object1"; |
||||||
|
|
||||||
|
await wait(10); |
||||||
|
// @ts-expect-error
|
||||||
|
expect(object2.name).toBe("Updated name from object1"); |
||||||
|
|
||||||
|
// Expect object of different shape not to have changed.
|
||||||
|
// @ts-expect-error
|
||||||
|
expect(object3.name).toBe("Niko's cat"); |
||||||
|
|
||||||
|
// Update object 4 and expect object 3 with same shape to have updated.
|
||||||
|
// @ts-expect-error
|
||||||
|
object4.name = "Updated name from object4"; |
||||||
|
|
||||||
|
await wait(10); |
||||||
|
// @ts-expect-error
|
||||||
|
expect(object3!.name).toBe("Updated name from object4"); |
||||||
|
}); |
||||||
|
} |
||||||
}); |
}); |
||||||
|
Loading…
Reference in new issue