UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

36 lines (35 loc) 1.29 kB
import { describe, expect, it } from "vitest"; describe("mobile polyfills", () => { it("installs working web streams globals when the runtime has none", async () => { const originals = ["ReadableStream", "WritableStream", "TransformStream"].map(name => [name, Object.getOwnPropertyDescriptor(globalThis, name)]); for (const [name] of originals) { Reflect.deleteProperty(globalThis, name); } try { await import("../polyfills-mobile.mjs"); const stream = new globalThis.ReadableStream({ start(controller) { controller.enqueue(new TextEncoder().encode("hello")); controller.close(); } }); const reader = stream.getReader(); const { value, done } = await reader.read(); expect(done).toBe(false); expect(new TextDecoder().decode(value)).toBe("hello"); expect(typeof globalThis.WritableStream).toBe("function"); expect(typeof globalThis.TransformStream).toBe("function"); } finally { for (const [name, descriptor] of originals) { Reflect.deleteProperty(globalThis, name); if (descriptor) { Object.defineProperty(globalThis, name, descriptor); } } } }); }); //# sourceMappingURL=polyfills-mobile.test.mjs.map