@@ -509,6 +509,61 @@ describe('Messages', () => {
509509 expect ( capturedRequest . method ) . toEqual ( 'POST' ) ;
510510 expect ( capturedRequest . path ) . toEqual ( '/v3/grants/id123/messages/send' ) ;
511511 } ) ;
512+
513+ it ( 'should include isPlaintext in JSON body when provided' , async ( ) => {
514+ const jsonBody = {
515+ to : [ { name : 'Test' , email : 'test@example.com' } ] ,
516+ subject : 'Plain text email' ,
517+ body : 'Hello world' ,
518+ isPlaintext : true ,
519+ } ;
520+
521+ await messages . send ( {
522+ identifier : 'id123' ,
523+ requestBody : jsonBody ,
524+ } ) ;
525+
526+ const capturedRequest = apiClient . request . mock . calls [ 0 ] [ 0 ] ;
527+ expect ( capturedRequest . method ) . toEqual ( 'POST' ) ;
528+ expect ( capturedRequest . path ) . toEqual ( '/v3/grants/id123/messages/send' ) ;
529+ expect ( capturedRequest . body ) . toEqual ( jsonBody ) ;
530+ } ) ;
531+
532+ it ( 'should include isPlaintext in multipart form message when provided' , async ( ) => {
533+ const messageJson = {
534+ to : [ { name : 'Test' , email : 'test@example.com' } ] ,
535+ subject : 'Plain text email' ,
536+ body : 'Hello world' ,
537+ isPlaintext : true ,
538+ } ;
539+ const fileStream = createReadableStream ( 'This is the text from file 1' ) ;
540+ const file1 : CreateAttachmentRequest = {
541+ filename : 'file1.txt' ,
542+ contentType : 'text/plain' ,
543+ content : fileStream ,
544+ size : 3 * 1024 * 1024 ,
545+ } ;
546+
547+ await messages . send ( {
548+ identifier : 'id123' ,
549+ requestBody : {
550+ ...messageJson ,
551+ attachments : [ file1 ] ,
552+ } ,
553+ } ) ;
554+
555+ const capturedRequest = apiClient . request . mock . calls [ 0 ] [ 0 ] ;
556+ const formData = (
557+ capturedRequest . form as any as MockedFormData
558+ ) . _getAppendedData ( ) ;
559+ const parsed = JSON . parse ( formData . message ) ;
560+ expect ( parsed . to ) . toEqual ( messageJson . to ) ;
561+ expect ( parsed . subject ) . toEqual ( messageJson . subject ) ;
562+ expect ( parsed . body ) . toEqual ( messageJson . body ) ;
563+ expect ( parsed . is_plaintext ) . toBe ( true ) ;
564+ expect ( capturedRequest . method ) . toEqual ( 'POST' ) ;
565+ expect ( capturedRequest . path ) . toEqual ( '/v3/grants/id123/messages/send' ) ;
566+ } ) ;
512567 } ) ;
513568
514569 describe ( 'scheduledMessages' , ( ) => {
0 commit comments