@@ -264,61 +264,6 @@ describe('Templates', () => {
264264        'Failed to render React component. Make sure to install `@react-email/render`' , 
265265      ) ; 
266266    } ) ; 
267- 
268-     it ( 'creates a template with object and list variable types' ,  async  ( )  =>  { 
269-       const  payload : CreateTemplateOptions  =  { 
270-         name : 'Complex Variables Template' , 
271-         html : '<h1>Welcome {{{userProfile.name}}}!</h1><p>Your tags: {{{tags}}}</p>' , 
272-         variables : [ 
273-           { 
274-             key : 'userProfile' , 
275-             type : 'object' , 
276-             fallbackValue : {  name : 'John' ,  age : 30  } , 
277-           } , 
278-           { 
279-             key : 'tags' , 
280-             type : 'list' , 
281-             fallbackValue : [ 'premium' ,  'vip' ] , 
282-           } , 
283-           { 
284-             key : 'scores' , 
285-             type : 'list' , 
286-             fallbackValue : [ 95 ,  87 ,  92 ] , 
287-           } , 
288-           { 
289-             key : 'flags' , 
290-             type : 'list' , 
291-             fallbackValue : [ true ,  false ,  true ] , 
292-           } , 
293-           { 
294-             key : 'items' , 
295-             type : 'list' , 
296-             fallbackValue : [ {  id : 1  } ,  {  id : 2  } ] , 
297-           } , 
298-         ] , 
299-       } ; 
300-       const  response : CreateTemplateResponseSuccess  =  { 
301-         object : 'template' , 
302-         id : 'fd61172c-cafc-40f5-b049-b45947779a29' , 
303-       } ; 
304- 
305-       mockSuccessResponse ( response ,  { 
306-         headers : {  Authorization : `Bearer ${ TEST_API_KEY }   } , 
307-       } ) ; 
308- 
309-       const  resend  =  new  Resend ( TEST_API_KEY ) ; 
310-       await  expect ( 
311-         resend . templates . create ( payload ) , 
312-       ) . resolves . toMatchInlineSnapshot ( ` 
313-         { 
314-           "data": { 
315-             "id": "fd61172c-cafc-40f5-b049-b45947779a29", 
316-             "object": "template", 
317-           }, 
318-           "error": null, 
319-         } 
320-       ` ) ; 
321-     } ) ; 
322267  } ) ; 
323268
324269  describe ( 'remove' ,  ( )  =>  { 
@@ -541,65 +486,6 @@ describe('Templates', () => {
541486        } 
542487      ` ) ; 
543488    } ) ; 
544- 
545-     it ( 'updates a template with object and list variable types' ,  async  ( )  =>  { 
546-       const  id  =  'fd61172c-cafc-40f5-b049-b45947779a29' ; 
547-       const  payload : UpdateTemplateOptions  =  { 
548-         name : 'Updated Complex Variables Template' , 
549-         html : '<h1>Updated Welcome {{{config.theme}}}!</h1><p>Permissions: {{{permissions}}}</p>' , 
550-         variables : [ 
551-           { 
552-             key : 'config' , 
553-             type : 'object' , 
554-             fallbackValue : {  theme : 'dark' ,  lang : 'en'  } , 
555-           } , 
556-           { 
557-             key : 'permissions' , 
558-             type : 'list' , 
559-             fallbackValue : [ 'read' ,  'write' ] , 
560-           } , 
561-           { 
562-             key : 'counts' , 
563-             type : 'list' , 
564-             fallbackValue : [ 10 ,  20 ,  30 ] , 
565-           } , 
566-           { 
567-             key : 'enabled' , 
568-             type : 'list' , 
569-             fallbackValue : [ true ,  false ] , 
570-           } , 
571-           { 
572-             key : 'metadata' , 
573-             type : 'list' , 
574-             fallbackValue : [ {  key : 'a'  } ,  {  key : 'b'  } ] , 
575-           } , 
576-         ] , 
577-       } ; 
578-       const  response  =  { 
579-         object : 'template' , 
580-         id, 
581-       } ; 
582- 
583-       mockSuccessResponse ( response ,  { 
584-         headers : { 
585-           Authorization : 'Bearer re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop' , 
586-         } , 
587-       } ) ; 
588- 
589-       const  resend  =  new  Resend ( 're_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop' ) ; 
590- 
591-       await  expect ( 
592-         resend . templates . update ( id ,  payload ) , 
593-       ) . resolves . toMatchInlineSnapshot ( ` 
594-         { 
595-           "data": { 
596-             "id": "fd61172c-cafc-40f5-b049-b45947779a29", 
597-             "object": "template", 
598-           }, 
599-           "error": null, 
600-         } 
601-       ` ) ; 
602-     } ) ; 
603489  } ) ; 
604490
605491  describe ( 'get' ,  ( )  =>  { 
@@ -1015,20 +901,33 @@ describe('Templates', () => {
1015901
1016902      const  resend  =  new  Resend ( TEST_API_KEY ) ; 
1017903
904+       // Test before and limit together 
1018905      await  resend . templates . list ( { 
1019906        before : 'cursor1' , 
907+         limit : 25 , 
908+       } ) ; 
909+ 
910+       // Verify before and limit pagination parameters are included 
911+       const  [ firstUrl ]  =  fetchMock . mock . calls [ 0 ] ; 
912+       const  firstParsedUrl  =  new  URL ( firstUrl  as  string ) ; 
913+ 
914+       expect ( firstParsedUrl . pathname ) . toBe ( '/templates' ) ; 
915+       expect ( firstParsedUrl . searchParams . get ( 'before' ) ) . toBe ( 'cursor1' ) ; 
916+       expect ( firstParsedUrl . searchParams . get ( 'limit' ) ) . toBe ( '25' ) ; 
917+ 
918+       // Test after and limit together 
919+       await  resend . templates . list ( { 
1020920        after : 'cursor2' , 
1021921        limit : 25 , 
1022922      } ) ; 
1023923
1024-       // Verify all  pagination parameters are included 
1025-       const  [ url ]  =  fetchMock . mock . calls [ 0 ] ; 
1026-       const  parsedUrl  =  new  URL ( url  as  string ) ; 
924+       // Verify after and limit  pagination parameters are included 
925+       const  [ secondUrl ]  =  fetchMock . mock . calls [ 1 ] ; 
926+       const  secondParsedUrl  =  new  URL ( secondUrl  as  string ) ; 
1027927
1028-       expect ( parsedUrl . pathname ) . toBe ( '/templates' ) ; 
1029-       expect ( parsedUrl . searchParams . get ( 'before' ) ) . toBe ( 'cursor1' ) ; 
1030-       expect ( parsedUrl . searchParams . get ( 'after' ) ) . toBe ( 'cursor2' ) ; 
1031-       expect ( parsedUrl . searchParams . get ( 'limit' ) ) . toBe ( '25' ) ; 
928+       expect ( secondParsedUrl . pathname ) . toBe ( '/templates' ) ; 
929+       expect ( secondParsedUrl . searchParams . get ( 'after' ) ) . toBe ( 'cursor2' ) ; 
930+       expect ( secondParsedUrl . searchParams . get ( 'limit' ) ) . toBe ( '25' ) ; 
1032931    } ) ; 
1033932  } ) ; 
1034933} ) ; 
0 commit comments