@@ -55,6 +55,14 @@ describe('sdk v4', () => {
5555 ) . toThrow ( 'The service ID is required' ) ;
5656 } ) ;
5757
58+ it ( 'should call the send method and fail on the template ID' , ( ) => {
59+ expect ( ( ) =>
60+ send ( 'default_service' , '' , undefined , {
61+ publicKey : 'C2JWGTestKeySomething' ,
62+ } ) ,
63+ ) . toThrow ( 'The template ID is required' ) ;
64+ } ) ;
65+
5866 it ( 'should call the send method and fail on headless' , async ( ) => {
5967 try {
6068 const result = await send (
@@ -76,7 +84,7 @@ describe('sdk v4', () => {
7684 } ) ;
7785
7886 it ( 'should call the send method and fail on headless as promise' , ( ) => {
79- return send ( '' , 'my_test_template' , undefined , {
87+ return send ( 'default_service ' , 'my_test_template' , undefined , {
8088 publicKey : 'C2JWGTestKeySomething' ,
8189 blockHeadless : true ,
8290 } ) . then (
@@ -92,12 +100,56 @@ describe('sdk v4', () => {
92100 ) ;
93101 } ) ;
94102
95- it ( 'should call the send method and fail on the template ID' , ( ) => {
96- expect ( ( ) =>
97- send ( 'default_service' , '' , undefined , {
103+ it ( 'should call the send method and fail on blocklist' , async ( ) => {
104+ try {
105+ const result = await send (
106+ 'default_service' ,
107+ 'my_test_template' ,
108+ {
109+ email : 'bar@emailjs.com' ,
110+ } ,
111+ {
112+ publicKey : 'C2JWGTestKeySomething' ,
113+ blockList : {
114+ list : [ 'foo@emailjs.com' , 'bar@emailjs.com' ] ,
115+ watchVariable : 'email' ,
116+ } ,
117+ } ,
118+ ) ;
119+ expect ( result ) . toBeUndefined ( ) ;
120+ } catch ( error ) {
121+ expect ( error ) . toEqual ( {
122+ status : 403 ,
123+ text : 'Forbidden' ,
124+ } ) ;
125+ }
126+ } ) ;
127+
128+ it ( 'should call the send method and fail on blocklist as promise' , ( ) => {
129+ return send (
130+ 'default_service' ,
131+ 'my_test_template' ,
132+ {
133+ email : 'bar@emailjs.com' ,
134+ } ,
135+ {
98136 publicKey : 'C2JWGTestKeySomething' ,
99- } ) ,
100- ) . toThrow ( 'The template ID is required' ) ;
137+ blockList : {
138+ list : [ 'foo@emailjs.com' , 'bar@emailjs.com' ] ,
139+ watchVariable : 'email' ,
140+ } ,
141+ } ,
142+ ) . then (
143+ ( result ) => {
144+ expect ( result ) . toBeUndefined ( ) ;
145+ } ,
146+ ( error ) => {
147+ expect ( error ) . toEqual ( {
148+ status : 403 ,
149+ text : 'Forbidden' ,
150+ } ) ;
151+ } ,
152+ ) ;
101153 } ) ;
102154
103155 it ( 'should call the send method successfully with 4 params' , async ( ) => {
0 commit comments