@@ -193,7 +193,52 @@ test('generates plain text and html mixed message with an attachment', () => {
193193 )
194194} )
195195
196- test ( 'sending only an attachment, without content isn not allowed' , async ( ) => {
196+ test ( 'generates plain text and html related message with an inline attachment' , ( ) => {
197+ const msg = new MIMEMessage ( envctx )
198+ msg . boundaries = { related : 'abcdef' , alt : 'qwerty' }
199+ msg . setHeader ( 'Date' , 'Wed, 22 Mar 2023 23:36:33 +0000' )
200+ msg . setHeader ( 'Message-ID' , '<oliusb0xvxc@mail.com>' )
201+ msg . setSender ( 'test@mail.com' )
202+ msg . setSubject ( 'Lorem Ipsum' )
203+ msg . addMessage ( { contentType : 'text/plain' , data : 'hello there' } )
204+ msg . addMessage ( { contentType : 'text/html' , data : 'hello there <b>Murat</b>' } )
205+ msg . addAttachment ( {
206+ inline : true ,
207+ contentType : 'image/jpg' ,
208+ filename : 'sample.jpg' ,
209+ data : sampleImageBase64
210+ } )
211+
212+ expect ( msg . hasInlineAttachments ( ) ) . toBe ( true ) ;
213+ expect ( msg . getMessageByType ( "text/plain" ) ?. data ) . toBe ( "hello there" )
214+
215+ expect ( msg . asRaw ( ) ) . toBe ( 'Date: Wed, 22 Mar 2023 23:36:33 +0000' + envctx . eol +
216+ 'From: <test@mail.com>' + envctx . eol +
217+ 'Message-ID: <oliusb0xvxc@mail.com>' + envctx . eol +
218+ 'Subject: =?utf-8?B?TG9yZW0gSXBzdW0=?=' + envctx . eol +
219+ 'MIME-Version: 1.0' + envctx . eol +
220+ 'Content-Type: multipart/related; boundary=abcdef' + envctx . eol + envctx . eol +
221+ '--abcdef' + envctx . eol +
222+ 'Content-Type: multipart/alternative; boundary=qwerty' + envctx . eol + envctx . eol +
223+ '--qwerty' + envctx . eol +
224+ 'Content-Type: text/plain; charset=UTF-8' + envctx . eol +
225+ 'Content-Transfer-Encoding: 7bit' + envctx . eol + envctx . eol +
226+ 'hello there' + envctx . eol + envctx . eol +
227+ '--qwerty' + envctx . eol +
228+ 'Content-Type: text/html; charset=UTF-8' + envctx . eol +
229+ 'Content-Transfer-Encoding: 7bit' + envctx . eol + envctx . eol +
230+ 'hello there <b>Murat</b>' + envctx . eol + envctx . eol +
231+ '--qwerty--' + envctx . eol + envctx . eol +
232+ '--abcdef' + envctx . eol +
233+ 'Content-Type: image/jpg; name="sample.jpg"' + envctx . eol +
234+ 'Content-Transfer-Encoding: base64' + envctx . eol +
235+ 'Content-Disposition: inline; filename="sample.jpg"' + envctx . eol + envctx . eol +
236+ sampleImageBase64 + envctx . eol +
237+ '--abcdef--'
238+ )
239+ } )
240+
241+ test ( 'sending only an attachment, without content is not allowed' , async ( ) => {
197242 const msg = new MIMEMessage ( envctx )
198243 msg . setHeader ( 'Date' , 'Wed, 22 Mar 2023 23:36:33 +0000' )
199244 msg . setHeader ( 'Message-ID' , '<oliusb0xvxc@mail.com>' )
0 commit comments