|
1 | | -import { afterEach, describe, expect, it, vi } from "vite-plus/test"; |
| 1 | +import { describe, expect, it, vi } from "vite-plus/test"; |
2 | 2 |
|
3 | 3 | import { start, stop } from "./device-stream.browser"; |
4 | 4 |
|
@@ -82,27 +82,27 @@ function viewerFixture(supported: boolean) { |
82 | 82 | } |
83 | 83 |
|
84 | 84 | describe("native iOS simulator viewer", () => { |
85 | | - afterEach(() => { |
86 | | - stop(); |
87 | | - vi.useRealTimers(); |
88 | | - vi.unstubAllGlobals(); |
89 | | - }); |
90 | | - |
91 | 85 | it.each([ |
92 | 86 | { supported: true, image: "" }, |
93 | 87 | { supported: false, image: "/api/device-hub/vendor/serve-sim/helper/sim/stream.mjpeg" }, |
94 | 88 | ])( |
95 | 89 | "streams H.264 when WebCodecs decodes it, else MJPEG (supported: $supported)", |
96 | 90 | 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 | + } |
106 | 106 | }, |
107 | 107 | ); |
108 | 108 | }); |
0 commit comments