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 } from "@effect/vitest"; |
| 2 | |
| 3 | import { |
| 4 | EMPTY_INCOMING_SHARE_PRESENTATION_STATE, |
| 5 | transitionIncomingSharePresentation, |
| 6 | } from "./incoming-share-presentation"; |
| 7 | |
| 8 | describe("incoming share presentation", () => { |
| 9 | it("does not reopen a dismissed share when refresh returns a new object for the same id", () => { |
| 10 | const presented = transitionIncomingSharePresentation(EMPTY_INCOMING_SHARE_PRESENTATION_STATE, { |
| 11 | isShareSheetPresented: false, |
| 12 | pendingShareId: "share-1", |
| 13 | }); |
| 14 | expect(presented.shareIdToPresent).toBe("share-1"); |
| 15 | |
| 16 | const whilePresented = transitionIncomingSharePresentation(presented.state, { |
| 17 | isShareSheetPresented: true, |
| 18 | pendingShareId: "share-1", |
| 19 | }); |
| 20 | expect(whilePresented).toEqual({ state: presented.state, shareIdToPresent: null }); |
| 21 | |
| 22 | const dismissed = transitionIncomingSharePresentation(whilePresented.state, { |
| 23 | isShareSheetPresented: false, |
| 24 | pendingShareId: "share-1", |
| 25 | }); |
| 26 | expect(dismissed.state.dismissedShareId).toBe("share-1"); |
| 27 | |
| 28 | expect( |
| 29 | transitionIncomingSharePresentation(dismissed.state, { |
| 30 | isShareSheetPresented: false, |
| 31 | pendingShareId: "share-1", |
| 32 | }), |
| 33 | ).toEqual({ state: dismissed.state, shareIdToPresent: null }); |
| 34 | }); |
| 35 | |
| 36 | it("forgets dismissal after consumption so a later handoff may reuse the id", () => { |
| 37 | const dismissed = { |
| 38 | presentedShareId: null, |
| 39 | dismissedShareId: "share-1", |
| 40 | }; |
| 41 | const consumed = transitionIncomingSharePresentation(dismissed, { |
| 42 | isShareSheetPresented: false, |
| 43 | pendingShareId: null, |
| 44 | }); |
| 45 | expect(consumed.state).toEqual(EMPTY_INCOMING_SHARE_PRESENTATION_STATE); |
| 46 | |
| 47 | expect( |
| 48 | transitionIncomingSharePresentation(consumed.state, { |
| 49 | isShareSheetPresented: false, |
| 50 | pendingShareId: "share-1", |
| 51 | }).shareIdToPresent, |
| 52 | ).toBe("share-1"); |
| 53 | }); |
| 54 | }); |