The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { describe, expect, it, vi } from "vite-plus/test"; |
| 2 | |
| 3 | import { |
| 4 | recordHomeTransitionEnd, |
| 5 | recordHomeTransitionStart, |
| 6 | runWhenHomeCovered, |
| 7 | } from "./home-route-visibility"; |
| 8 | |
| 9 | vi.mock("@react-navigation/native", () => ({ useNavigation: vi.fn() })); |
| 10 | |
| 11 | describe("runWhenHomeCovered", () => { |
| 12 | it("waits for the page opening over Home to finish covering it, then runs once", () => { |
| 13 | const clearSearch = vi.fn(); |
| 14 | runWhenHomeCovered(clearSearch); |
| 15 | recordHomeTransitionStart(true); |
| 16 | expect(clearSearch).not.toHaveBeenCalled(); |
| 17 | recordHomeTransitionEnd(true, true); |
| 18 | expect(clearSearch).not.toHaveBeenCalled(); |
| 19 | recordHomeTransitionEnd(true, false); |
| 20 | expect(clearSearch).toHaveBeenCalledTimes(1); |
| 21 | recordHomeTransitionStart(false); |
| 22 | recordHomeTransitionEnd(true, false); |
| 23 | expect(clearSearch).toHaveBeenCalledTimes(1); |
| 24 | }); |
| 25 | |
| 26 | it("drops the action when Home reappears before it is covered", () => { |
| 27 | const clearSearch = vi.fn(); |
| 28 | runWhenHomeCovered(clearSearch); |
| 29 | recordHomeTransitionStart(true); |
| 30 | recordHomeTransitionStart(false); |
| 31 | recordHomeTransitionEnd(false, false); |
| 32 | recordHomeTransitionEnd(true, false); |
| 33 | expect(clearSearch).not.toHaveBeenCalled(); |
| 34 | }); |
| 35 | }); |