Refactor water volume integration test to use waitFor instead of fake timers
This commit is contained in:
@@ -84,12 +84,10 @@ vi.mock("../../src/assets/project-asset-storage", () => ({
|
|||||||
describe("water volume integration", () => {
|
describe("water volume integration", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
viewportHostInstances.length = 0;
|
viewportHostInstances.length = 0;
|
||||||
vi.useFakeTimers();
|
|
||||||
vi.spyOn(HTMLCanvasElement.prototype, "getContext").mockImplementation(() => ({}) as never);
|
vi.spyOn(HTMLCanvasElement.prototype, "getContext").mockImplementation(() => ({}) as never);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.useRealTimers();
|
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -138,18 +136,17 @@ describe("water volume integration", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await act(async () => {
|
await waitFor(() => {
|
||||||
await vi.runAllTimersAsync();
|
expect(store.getState().document.brushes[brush.id]?.volume).toEqual({
|
||||||
|
mode: "water",
|
||||||
|
water: {
|
||||||
|
colorHex: "#12a4ff",
|
||||||
|
surfaceOpacity: 0.55,
|
||||||
|
waveStrength: 0.35
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(input.value).toBe("#12a4ff");
|
expect(input.value).toBe("#12a4ff");
|
||||||
expect(store.getState().document.brushes[brush.id]?.volume).toEqual({
|
|
||||||
mode: "water",
|
|
||||||
water: {
|
|
||||||
colorHex: "#12a4ff",
|
|
||||||
surfaceOpacity: 0.55,
|
|
||||||
waveStrength: 0.35
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user