Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/__tests__/lib/api/resources/inbound/Threads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,42 @@ describe("lib/api/resources/inbound/Threads: ", () => {
status: "delivered",
delivered_at: "2026-05-08T11:40:05.000Z",
bounced_at: null,
rejected_at: null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Could you add a rejected outbound message to the fixture (status: "not_delivered" with rejected_at set), like the other SDKs do? Then the test also shows a real timestamp, not only null.

},
},
{ visibility_status: "placeholder", direction: "inbound" },
{
visibility_status: "available",
direction: "outbound",
id: "2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e",
delivery: {
to: "suppressed@example.com",
status: "not_delivered",
delivered_at: null,
bounced_at: null,
rejected_at: "2026-05-08T11:40:01.000Z",
},
},
],
} as unknown as Thread;

mock.onGet(`${threadsURL}/1700000000000124`).reply(200, thread);

const result = await threadsAPI.get(42, "1700000000000124");
const [received, sent, placeholder] = result.messages;
const [received, sent, placeholder, rejected] = result.messages;

expect(result).toEqual(thread);
expect(received.forwards?.[0].status).toEqual("forwarded");
expect(sent.delivery?.status).toEqual("delivered");
expect(sent.delivery?.bounced_at).toBeNull();
expect(sent.delivery?.rejected_at).toBeNull();
expect(placeholder.forwards).toBeUndefined();
expect(placeholder.delivery).toBeUndefined();
expect(rejected.delivery?.status).toEqual("not_delivered");
expect(rejected.delivery?.bounced_at).toBeNull();
expect(rejected.delivery?.rejected_at).toEqual(
"2026-05-08T11:40:01.000Z"
);
});
});

Expand Down
1 change: 1 addition & 0 deletions src/types/api/inbound/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ThreadMessageDelivery {
status: ThreadMessageDeliveryStatus;
delivered_at: string | null;
bounced_at: string | null;
rejected_at: string | null;
}

export interface ThreadSummary {
Expand Down