Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

incoming-share-native.test.ts

32 lines1.1 KB

1import { describe, expect, it, vi } from "@effect/vitest";
2import type { SharePayload } from "expo-sharing";
3​
4import { createIncomingSharePayloadReader } from "./incoming-share-native";
5​
6describe("createIncomingSharePayloadReader", () => {
7 it("treats a missing iOS App Group as an unavailable inbox", () => {
8 const readPayloads = vi.fn((): ReadonlyArray<SharePayload> => {
9 throw Object.assign(new Error("Expo-sharing has failed to fetch the app group id"), {
10 code: "ERR_FAILED_TO_RESOLVE_APP_GROUP_ID",
11 });
12 });
13 const read = createIncomingSharePayloadReader({ platform: "ios", readPayloads });
14​
15 expect(read()).toEqual([]);
16 expect(read()).toEqual([]);
17 expect(readPayloads).toHaveBeenCalledTimes(1);
18 });
19​
20 // regression: #4943 stop shared content errors in Personal Team builds
21 it("preserves other native errors", () => {
22 const error = new Error("native failure");
23 const read = createIncomingSharePayloadReader({
24 platform: "ios",
25 readPayloads: () => {
26 throw error;
27 },
28 });
29​
30 expect(read).toThrow(error);
31 });
32});