UNPKG

one

Version:

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

32 lines (31 loc) 1.09 kB
import { afterEach, describe, expect, it, vi } from "vitest"; import { getDevServer } from "./getDevServer.native.js"; import { getURL } from "./getURL.native.native.js"; vi.mock("./getDevServer", function () { return { getDevServer: vi.fn(function () { return { url: "http://metro.local:8081/", bundleLoadedFromServer: true }; }) }; }); var originalServerUrl = process.env.ONE_SERVER_URL; afterEach(function () { process.env.ONE_SERVER_URL = originalServerUrl; vi.clearAllMocks(); }); describe("getURL native", function () { it("prefers explicit ONE_SERVER_URL in dev", function () { process.env.ONE_SERVER_URL = "https://app.example.com/"; expect(getURL()).toBe("https://app.example.com"); expect(getDevServer).not.toHaveBeenCalled(); }); it("falls back to the dev server when ONE_SERVER_URL is unset", function () { delete process.env.ONE_SERVER_URL; expect(getURL()).toBe("http://metro.local:8081"); expect(getDevServer).toHaveBeenCalledTimes(1); }); }); //# sourceMappingURL=getURL.native.test.native.js.map