Skip to content

Commit 62825bb

Browse files
PR Batch Testershivamhwp
authored andcommitted
test(mobile): scope simulator viewer cleanup to each case
1 parent 9ce96c3 commit 62825bb

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

‎apps/mobile/src/features/devices/device-stream.browser.test.ts‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
1+
import { describe, expect, it, vi } from "vite-plus/test";
22

33
import { start, stop } from "./device-stream.browser";
44

@@ -82,27 +82,27 @@ function viewerFixture(supported: boolean) {
8282
}
8383

8484
describe("native iOS simulator viewer", () => {
85-
afterEach(() => {
86-
stop();
87-
vi.useRealTimers();
88-
vi.unstubAllGlobals();
89-
});
90-
9185
it.each([
9286
{ supported: true, image: "" },
9387
{ supported: false, image: "/api/device-hub/vendor/serve-sim/helper/sim/stream.mjpeg" },
9488
])(
9589
"streams H.264 when WebCodecs decodes it, else MJPEG (supported: $supported)",
9690
async ({ supported, image }) => {
97-
const { configured, requested, videoBodies } = viewerFixture(supported);
98-
await vi.advanceTimersByTimeAsync(0);
99-
expect(requested).toContain("/api/device-hub/vendor/serve-sim/helper/sim/stream.avcc");
100-
videoBodies[0]!.enqueue(new Uint8Array(envelope(1, [1, 0x64, 0x00, 0x33])));
101-
await vi.advanceTimersByTimeAsync(0);
102-
expect(configured).toEqual(supported ? ["avc1.640033"] : []);
103-
const img = document.querySelector("img")!;
104-
expect(img.src && new URL(img.src).pathname).toBe(image);
105-
expect(img.style.display).toBe(supported ? "none" : "block");
91+
try {
92+
const { configured, requested, videoBodies } = viewerFixture(supported);
93+
await vi.advanceTimersByTimeAsync(0);
94+
expect(requested).toContain("/api/device-hub/vendor/serve-sim/helper/sim/stream.avcc");
95+
videoBodies[0]!.enqueue(new Uint8Array(envelope(1, [1, 0x64, 0x00, 0x33])));
96+
await vi.advanceTimersByTimeAsync(0);
97+
expect(configured).toEqual(supported ? ["avc1.640033"] : []);
98+
const img = document.querySelector("img")!;
99+
expect(img.src && new URL(img.src).pathname).toBe(image);
100+
expect(img.style.display).toBe(supported ? "none" : "block");
101+
} finally {
102+
stop();
103+
vi.useRealTimers();
104+
vi.unstubAllGlobals();
105+
}
106106
},
107107
);
108108
});

0 commit comments

Comments
 (0)