fix unit test

main
Laurin Weger 2 weeks ago
parent ed6765fbf6
commit cda988217d
No known key found for this signature in database
GPG Key ID: 9B372BB0B792770F
  1. 0
      src/ng-mock/tests/subscriptionToStore.test.ts
  2. 62
      src/ng-mock/tests/updatesWithWasm.test.ts

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

Loading…
Cancel
Save