UNPKG

salat

Version:

Daily Moroccan prayers time, right in your console, at the tip of your fingers

36 lines (35 loc) 1.52 kB
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { render } from "ink-testing-library"; import { describe, expect, it, vi } from "vitest"; import TimesCommandWrapper from "./TimesCommandWrapper.js"; // Mock dependencies vi.mock("#components/CitySelect", async () => { const { Text } = await import("ink"); return { default: ({ onSelect }) => { // Trigger onSelect immediately? No, we need to test rendering. return _jsx(Text, { children: "CitySelect Mock" }); }, }; }); vi.mock("#components/TimesApp", async () => { const { Text } = await import("ink"); return { default: ({ cityNameArg }) => (_jsxs(Text, { children: ["TimesApp Mock: ", cityNameArg] })), }; }); vi.mock("#components/QueryProvider", () => ({ QueryProvider: ({ children }) => (_jsx(_Fragment, { children: children })), })); describe("TimesCommandWrapper", () => { it("should render TimesApp if initialCity is provided", () => { const { lastFrame } = render(_jsx(TimesCommandWrapper, { initialCity: "Casablanca" })); expect(lastFrame()).toContain("TimesApp Mock: Casablanca"); expect(lastFrame()).not.toContain("CitySelect Mock"); }); it("should render CitySelect if no initialCity provided", () => { const { lastFrame } = render(_jsx(TimesCommandWrapper, {})); expect(lastFrame()).toContain("CitySelect Mock"); expect(lastFrame()).not.toContain("TimesApp Mock"); }); });