1- import type { ErrorResponse } from '../interfaces' ;
2- import { Resend } from '../resend' ;
1+ import type { ErrorResponse } from '../../ interfaces' ;
2+ import { Resend } from '../../ resend' ;
33
44const resend = new Resend ( 're_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop' ) ;
55
6- describe ( 'Attachments ' , ( ) => {
6+ describe ( 'Receiving ' , ( ) => {
77 afterEach ( ( ) => fetchMock . resetMocks ( ) ) ;
88
99 describe ( 'get' , ( ) => {
@@ -22,8 +22,8 @@ describe('Attachments', () => {
2222 } ,
2323 } ) ;
2424
25- const result = await resend . attachments . get ( {
26- inboundId : '61cda979-919d-4b9d-9638-c148b93ff410' ,
25+ const result = await resend . attachments . receiving . get ( {
26+ emailId : '61cda979-919d-4b9d-9638-c148b93ff410' ,
2727 id : 'att_123' ,
2828 } ) ;
2929
@@ -61,8 +61,8 @@ describe('Attachments', () => {
6161 } ,
6262 } ) ;
6363
64- const result = await resend . attachments . get ( {
65- inboundId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
64+ const result = await resend . attachments . receiving . get ( {
65+ emailId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
6666 id : 'att_123' ,
6767 } ) ;
6868
@@ -71,9 +71,9 @@ describe('Attachments', () => {
7171 "data": {
7272 "data": {
7373 "content": "base64encodedcontent==",
74- "contentDisposition ": "attachment",
75- "contentId ": "cid_123",
76- "contentType ": "application/pdf",
74+ "content_disposition ": "attachment",
75+ "content_id ": "cid_123",
76+ "content_type ": "application/pdf",
7777 "filename": "document.pdf",
7878 "id": "att_123",
7979 },
@@ -106,8 +106,8 @@ describe('Attachments', () => {
106106 } ,
107107 } ) ;
108108
109- const result = await resend . attachments . get ( {
110- inboundId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
109+ const result = await resend . attachments . receiving . get ( {
110+ emailId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
111111 id : 'att_456' ,
112112 } ) ;
113113
@@ -116,9 +116,9 @@ describe('Attachments', () => {
116116 "data": {
117117 "data": {
118118 "content": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
119- "contentDisposition ": "inline",
120- "contentId ": "cid_456",
121- "contentType ": "image/png",
119+ "content_disposition ": "inline",
120+ "content_id ": "cid_456",
121+ "content_type ": "image/png",
122122 "filename": "image.png",
123123 "id": "att_456",
124124 },
@@ -150,8 +150,8 @@ describe('Attachments', () => {
150150 } ,
151151 } ) ;
152152
153- const result = await resend . attachments . get ( {
154- inboundId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
153+ const result = await resend . attachments . receiving . get ( {
154+ emailId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
155155 id : 'att_789' ,
156156 } ) ;
157157
@@ -160,10 +160,8 @@ describe('Attachments', () => {
160160 "data": {
161161 "data": {
162162 "content": "base64content",
163- "contentDisposition": "attachment",
164- "contentId": undefined,
165- "contentType": "text/plain",
166- "filename": undefined,
163+ "content_disposition": "attachment",
164+ "content_type": "text/plain",
167165 "id": "att_789",
168166 },
169167 "object": "attachment",
@@ -180,7 +178,7 @@ describe('Attachments', () => {
180178 it ( 'returns error' , async ( ) => {
181179 const response : ErrorResponse = {
182180 name : 'not_found' ,
183- message : 'Inbound email not found' ,
181+ message : 'Email not found' ,
184182 } ;
185183
186184 fetchMock . mockOnce ( JSON . stringify ( response ) , {
@@ -191,24 +189,16 @@ describe('Attachments', () => {
191189 } ,
192190 } ) ;
193191
194- const result = await resend . attachments . list ( {
195- inboundId : '61cda979-919d-4b9d-9638-c148b93ff410' ,
192+ const result = await resend . attachments . receiving . list ( {
193+ emailId : '61cda979-919d-4b9d-9638-c148b93ff410' ,
196194 } ) ;
197195
198- expect ( result ) . toMatchInlineSnapshot ( `
199- {
200- "data": null,
201- "error": {
202- "message": "Inbound email not found",
203- "name": "not_found",
204- },
205- }
206- ` ) ;
196+ expect ( result ) . toEqual ( { data : null , error : response } ) ;
207197 } ) ;
208198 } ) ;
209199
210200 describe ( 'when attachments found' , ( ) => {
211- it ( 'returns multiple attachments with transformed fields ' , async ( ) => {
201+ it ( 'returns multiple attachments' , async ( ) => {
212202 const apiResponse = {
213203 object : 'attachment' as const ,
214204 data : [
@@ -239,33 +229,11 @@ describe('Attachments', () => {
239229 } ,
240230 } ) ;
241231
242- const result = await resend . attachments . list ( {
243- inboundId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
232+ const result = await resend . attachments . receiving . list ( {
233+ emailId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
244234 } ) ;
245235
246- expect ( result ) . toMatchInlineSnapshot ( `
247- {
248- "data": [
249- {
250- "content": "base64encodedcontent==",
251- "contentDisposition": "attachment",
252- "contentId": "cid_123",
253- "contentType": "application/pdf",
254- "filename": "document.pdf",
255- "id": "att_123",
256- },
257- {
258- "content": "imagebase64==",
259- "contentDisposition": "inline",
260- "contentId": "cid_456",
261- "contentType": "image/png",
262- "filename": "image.png",
263- "id": "att_456",
264- },
265- ],
266- "error": null,
267- }
268- ` ) ;
236+ expect ( result ) . toEqual ( { data : apiResponse , error : null } ) ;
269237 } ) ;
270238
271239 it ( 'returns empty array when no attachments' , async ( ) => {
@@ -282,16 +250,11 @@ describe('Attachments', () => {
282250 } ,
283251 } ) ;
284252
285- const result = await resend . attachments . list ( {
286- inboundId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
253+ const result = await resend . attachments . receiving . list ( {
254+ emailId : '67d9bcdb-5a02-42d7-8da9-0d6feea18cff' ,
287255 } ) ;
288256
289- expect ( result ) . toMatchInlineSnapshot ( `
290- {
291- "data": [],
292- "error": null,
293- }
294- ` ) ;
257+ expect ( result ) . toEqual ( { data : apiResponse , error : null } ) ;
295258 } ) ;
296259 } ) ;
297260 } ) ;
0 commit comments