@@ -251,6 +251,26 @@ describe('ApiMailAdapter', () => {
251251 expect ( _sendMail . calls . all ( ) [ 0 ] . args [ 0 ] ) . toEqual ( expectedArguments ) ;
252252 } ) ;
253253
254+ it ( 'allows sendMail() without using a template' , async ( ) => {
255+ const adapter = new ApiMailAdapter ( config ) ;
256+ const apiCallbackSpy = spyOn ( adapter , 'apiCallback' ) . and . callFake ( apiResponseSuccess ) ;
257+ const options = {
258+ sender : config . sender ,
259+ 260+ subject : 'ExampleSubject' ,
261+ text : 'ExampleText' ,
262+ html : 'ExampleHtml' ,
263+ } ;
264+
265+ await expectAsync ( adapter . sendMail ( options ) ) . toBeResolved ( ) ;
266+ const apiPayload = apiCallbackSpy . calls . all ( ) [ 0 ] . args [ 0 ] . payload ;
267+ expect ( apiPayload . from ) . toEqual ( options . sender ) ;
268+ expect ( apiPayload . to ) . toEqual ( options . recipient ) ;
269+ expect ( apiPayload . subject ) . toEqual ( options . subject ) ;
270+ expect ( apiPayload . text ) . toEqual ( options . text ) ;
271+ expect ( apiPayload . html ) . toEqual ( options . html ) ;
272+ } ) ;
273+
254274 it ( 'passes user to callback when user is passed to sendMail()' , async ( ) => {
255275 const adapter = new ApiMailAdapter ( config ) ;
256276 const localeCallbackSpy = spyOn ( config . templates . customEmailWithLocaleCallback , 'localeCallback' ) . and . callThrough ( ) ;
@@ -385,7 +405,6 @@ describe('ApiMailAdapter', () => {
385405 const adapter = new ApiMailAdapter ( config ) ;
386406 const configs = [
387407 { templateName : 'invalid' } ,
388- { templateName : 'invalid' , direct : true }
389408 ] ;
390409 for ( const config of configs ) {
391410 await expectAsync ( adapter . _sendMail ( config ) ) . toBeRejectedWith ( Errors . Error . noTemplateWithName ( 'invalid' ) ) ;
0 commit comments