@@ -79,7 +79,107 @@ test.after(async (t) => {
79
79
server . close ( t . pass ) ;
80
80
} ) ;
81
81
82
- test ( 'simple text message' , async ( t ) => {
82
+ test . serial ( 'message validation fails without `from` header' , async ( t ) => {
83
+ const msg = new Message ( { } ) ;
84
+ const { isValid, validationError } = msg . checkValidity ( ) ;
85
+ t . false ( isValid ) ;
86
+ t . is ( validationError , 'Message must have a `from` header' ) ;
87
+ } ) ;
88
+
89
+ test . serial (
90
+ 'message validation fails without `to`, `cc`, or `bcc` header' ,
91
+ async ( t ) => {
92
+ const { isValid, validationError } = new Message ( {
93
+
94
+ } ) . checkValidity ( ) ;
95
+
96
+ t . false ( isValid ) ;
97
+ t . is (
98
+ validationError ,
99
+ 'Message must have at least one `to`, `cc`, or `bcc` header'
100
+ ) ;
101
+ }
102
+ ) ;
103
+
104
+ test . serial (
105
+ 'message validation succeeds with only `to` recipient header (string)' ,
106
+ async ( t ) => {
107
+ const { isValid, validationError } = new Message ( {
108
+
109
+
110
+ } ) . checkValidity ( ) ;
111
+
112
+ t . true ( isValid ) ;
113
+ t . is ( validationError , undefined ) ;
114
+ }
115
+ ) ;
116
+
117
+ test . serial (
118
+ 'message validation succeeds with only `to` recipient header (array)' ,
119
+ async ( t ) => {
120
+ const { isValid, validationError } = new Message ( {
121
+
122
+
123
+ } ) . checkValidity ( ) ;
124
+
125
+ t . true ( isValid ) ;
126
+ t . is ( validationError , undefined ) ;
127
+ }
128
+ ) ;
129
+
130
+ test . serial (
131
+ 'message validation succeeds with only `cc` recipient header (string)' ,
132
+ async ( t ) => {
133
+ const { isValid, validationError } = new Message ( {
134
+
135
+
136
+ } ) . checkValidity ( ) ;
137
+
138
+ t . true ( isValid ) ;
139
+ t . is ( validationError , undefined ) ;
140
+ }
141
+ ) ;
142
+
143
+ test . serial (
144
+ 'message validation succeeds with only `cc` recipient header (array)' ,
145
+ async ( t ) => {
146
+ const { isValid, validationError } = new Message ( {
147
+
148
+
149
+ } ) . checkValidity ( ) ;
150
+
151
+ t . true ( isValid ) ;
152
+ t . is ( validationError , undefined ) ;
153
+ }
154
+ ) ;
155
+
156
+ test . serial (
157
+ 'message validation succeeds with only `bcc` recipient header (string)' ,
158
+ async ( t ) => {
159
+ const { isValid, validationError } = new Message ( {
160
+
161
+
162
+ } ) . checkValidity ( ) ;
163
+
164
+ t . true ( isValid ) ;
165
+ t . is ( validationError , undefined ) ;
166
+ }
167
+ ) ;
168
+
169
+ test . serial (
170
+ 'message validation succeeds with only `bcc` recipient header (array)' ,
171
+ async ( t ) => {
172
+ const { isValid, validationError } = new Message ( {
173
+
174
+
175
+ } ) . checkValidity ( ) ;
176
+
177
+ t . true ( isValid ) ;
178
+ t . is ( validationError , undefined ) ;
179
+ }
180
+ ) ;
181
+
182
+ test . serial ( 'simple text message' , async ( t ) => {
83
183
const msg = {
84
184
subject : 'this is a test TEXT message from emailjs' ,
85
185
@@ -98,7 +198,7 @@ test('simple text message', async (t) => {
98
198
t . is ( mail . messageId , '<' + msg [ 'message-id' ] + '>' ) ;
99
199
} ) ;
100
200
101
- test ( 'null text message' , async ( t ) => {
201
+ test . serial ( 'null text message' , async ( t ) => {
102
202
const msg = {
103
203
subject : 'this is a test TEXT message from emailjs' ,
104
204
@@ -111,7 +211,7 @@ test('null text message', async (t) => {
111
211
t . is ( mail . text , '\n\n\n' ) ;
112
212
} ) ;
113
213
114
- test ( 'empty text message' , async ( t ) => {
214
+ test . serial ( 'empty text message' , async ( t ) => {
115
215
const msg = {
116
216
subject : 'this is a test TEXT message from emailjs' ,
117
217
@@ -124,7 +224,7 @@ test('empty text message', async (t) => {
124
224
t . is ( mail . text , '\n\n\n' ) ;
125
225
} ) ;
126
226
127
- test ( 'simple unicode text message' , async ( t ) => {
227
+ test . serial ( 'simple unicode text message' , async ( t ) => {
128
228
const msg = {
129
229
subject : 'this ✓ is a test ✓ TEXT message from emailjs' ,
130
230
from :
'zelda✓ <[email protected] >' ,
@@ -139,45 +239,7 @@ test('simple unicode text message', async (t) => {
139
239
t . is ( mail . to ?. text , msg . to ) ;
140
240
} ) ;
141
241
142
- test ( 'very large text message' , async ( t ) => {
143
- // thanks to jart+loberstech for this one!
144
- const msg = {
145
- subject : 'this is a test TEXT message from emailjs' ,
146
-
147
-
148
- text : textFixture ,
149
- } ;
150
-
151
- const mail = await send ( msg ) ;
152
- t . is ( mail . text , msg . text . replace ( / \r / g, '' ) + '\n\n\n' ) ;
153
- t . is ( mail . subject , msg . subject ) ;
154
- t . is ( mail . from ?. text , msg . from ) ;
155
- t . is ( mail . to ?. text , msg . to ) ;
156
- } ) ;
157
-
158
- test ( 'very large text data message' , async ( t ) => {
159
- const text = '<html><body><pre>' + textFixture + '</pre></body></html>' ;
160
-
161
- const msg = {
162
- subject : 'this is a test TEXT+DATA message from emailjs' ,
163
-
164
-
165
- text : 'hello friend if you are seeing this, you can not view html emails. it is attached inline.' ,
166
- attachment : {
167
- data : text ,
168
- alternative : true ,
169
- } ,
170
- } ;
171
-
172
- const mail = await send ( msg ) ;
173
- t . is ( mail . html , text . replace ( / \r / g, '' ) ) ;
174
- t . is ( mail . text , msg . text + '\n' ) ;
175
- t . is ( mail . subject , msg . subject ) ;
176
- t . is ( mail . from ?. text , msg . from ) ;
177
- t . is ( mail . to ?. text , msg . to ) ;
178
- } ) ;
179
-
180
- test ( 'html data message' , async ( t ) => {
242
+ test . serial ( 'html data message' , async ( t ) => {
181
243
const msg = {
182
244
subject : 'this is a test TEXT+HTML+DATA message from emailjs' ,
183
245
@@ -196,7 +258,7 @@ test('html data message', async (t) => {
196
258
t . is ( mail . to ?. text , msg . to ) ;
197
259
} ) ;
198
260
199
- test ( 'html file message' , async ( t ) => {
261
+ test . serial ( 'html file message' , async ( t ) => {
200
262
const msg = {
201
263
subject : 'this is a test TEXT+HTML+FILE message from emailjs' ,
202
264
@@ -215,7 +277,7 @@ test('html file message', async (t) => {
215
277
t . is ( mail . to ?. text , msg . to ) ;
216
278
} ) ;
217
279
218
- test ( 'html with image embed message' , async ( t ) => {
280
+ test . serial ( 'html with image embed message' , async ( t ) => {
219
281
const htmlFixture2Url = new URL ( 'attachments/smtp2.html' , import . meta. url ) ;
220
282
const imageFixtureUrl = new URL ( 'attachments/smtp.gif' , import . meta. url ) ;
221
283
const msg = {
@@ -248,7 +310,7 @@ test('html with image embed message', async (t) => {
248
310
t . is ( mail . to ?. text , msg . to ) ;
249
311
} ) ;
250
312
251
- test ( 'html data and attachment message' , async ( t ) => {
313
+ test . serial ( 'html data and attachment message' , async ( t ) => {
252
314
const msg = {
253
315
subject : 'this is a test TEXT+HTML+FILE message from emailjs' ,
254
316
@@ -270,7 +332,7 @@ test('html data and attachment message', async (t) => {
270
332
t . is ( mail . to ?. text , msg . to ) ;
271
333
} ) ;
272
334
273
- test ( 'attachment message' , async ( t ) => {
335
+ test . serial ( 'attachment message' , async ( t ) => {
274
336
const msg = {
275
337
subject : 'this is a test TEXT+ATTACHMENT message from emailjs' ,
276
338
@@ -291,7 +353,7 @@ test('attachment message', async (t) => {
291
353
t . is ( mail . to ?. text , msg . to ) ;
292
354
} ) ;
293
355
294
- test ( 'attachment sent with unicode filename message' , async ( t ) => {
356
+ test . serial ( 'attachment sent with unicode filename message' , async ( t ) => {
295
357
const msg = {
296
358
subject : 'this is a test TEXT+ATTACHMENT message from emailjs' ,
297
359
@@ -313,7 +375,7 @@ test('attachment sent with unicode filename message', async (t) => {
313
375
t . is ( mail . to ?. text , msg . to ) ;
314
376
} ) ;
315
377
316
- test ( 'attachments message' , async ( t ) => {
378
+ test . serial ( 'attachments message' , async ( t ) => {
317
379
const msg = {
318
380
subject : 'this is a test TEXT+2+ATTACHMENTS message from emailjs' ,
319
381
@@ -342,7 +404,9 @@ test('attachments message', async (t) => {
342
404
t . is ( mail . to ?. text , msg . to ) ;
343
405
} ) ;
344
406
345
- test ( 'streams message' , async ( t ) => {
407
+ test . serial ( 'streams message' , async ( t ) => {
408
+ t . timeout ( 15000 ) ;
409
+
346
410
const msg = {
347
411
subject : 'this is a test TEXT+2+STREAMED+ATTACHMENTS message from emailjs' ,
348
412
@@ -375,81 +439,43 @@ test('streams message', async (t) => {
375
439
t . is ( mail . to ?. text , msg . to ) ;
376
440
} ) ;
377
441
378
- test ( 'message validation fails without `from` header' , async ( t ) => {
379
- const msg = new Message ( { } ) ;
380
- const { isValid, validationError } = msg . checkValidity ( ) ;
381
- t . false ( isValid ) ;
382
- t . is ( validationError , 'Message must have a `from` header' ) ;
383
- } ) ;
384
-
385
- test ( 'message validation fails without `to`, `cc`, or `bcc` header' , async ( t ) => {
386
- const { isValid, validationError } = new Message ( {
387
-
388
- } ) . checkValidity ( ) ;
442
+ // thanks to jart+loberstech for this one!
443
+ test . serial ( 'very large text message' , async ( t ) => {
444
+ t . timeout ( 15000 ) ;
389
445
390
- t . false ( isValid ) ;
391
- t . is (
392
- validationError ,
393
- 'Message must have at least one `to`, `cc`, or `bcc` header'
394
- ) ;
395
- } ) ;
396
-
397
- test ( 'message validation succeeds with only `to` recipient header (string)' , async ( t ) => {
398
- const { isValid, validationError } = new Message ( {
399
-
400
-
401
- } ) . checkValidity ( ) ;
402
-
403
- t . true ( isValid ) ;
404
- t . is ( validationError , undefined ) ;
405
- } ) ;
406
-
407
- test ( 'message validation succeeds with only `to` recipient header (array)' , async ( t ) => {
408
- const { isValid, validationError } = new Message ( {
409
-
410
-
411
- } ) . checkValidity ( ) ;
412
-
413
- t . true ( isValid ) ;
414
- t . is ( validationError , undefined ) ;
415
- } ) ;
416
-
417
- test ( 'message validation succeeds with only `cc` recipient header (string)' , async ( t ) => {
418
- const { isValid, validationError } = new Message ( {
419
-
420
-
421
- } ) . checkValidity ( ) ;
422
-
423
- t . true ( isValid ) ;
424
- t . is ( validationError , undefined ) ;
425
- } ) ;
426
-
427
- test ( 'message validation succeeds with only `cc` recipient header (array)' , async ( t ) => {
428
- const { isValid, validationError } = new Message ( {
429
-
430
-
431
- } ) . checkValidity ( ) ;
446
+ const msg = {
447
+ subject : 'this is a test TEXT message from emailjs' ,
448
+
449
+
450
+ text : textFixture ,
451
+ } ;
432
452
433
- t . true ( isValid ) ;
434
- t . is ( validationError , undefined ) ;
453
+ const mail = await send ( msg ) ;
454
+ t . is ( mail . text , msg . text . replace ( / \r / g, '' ) + '\n\n\n' ) ;
455
+ t . is ( mail . subject , msg . subject ) ;
456
+ t . is ( mail . from ?. text , msg . from ) ;
457
+ t . is ( mail . to ?. text , msg . to ) ;
435
458
} ) ;
436
459
437
- test ( 'message validation succeeds with only `bcc` recipient header (string)' , async ( t ) => {
438
- const { isValid, validationError } = new Message ( {
439
-
440
-
441
- } ) . checkValidity ( ) ;
442
-
443
- t . true ( isValid ) ;
444
- t . is ( validationError , undefined ) ;
445
- } ) ;
460
+ test . serial ( 'very large text data message' , async ( t ) => {
461
+ t . timeout ( 15000 ) ;
446
462
447
- test ( 'message validation succeeds with only `bcc` recipient header (array)' , async ( t ) => {
448
- const { isValid, validationError } = new Message ( {
449
-
450
-
451
- } ) . checkValidity ( ) ;
463
+ const text = '<html><body><pre>' + textFixture + '</pre></body></html>' ;
464
+ const msg = {
465
+ subject : 'this is a test TEXT+DATA message from emailjs' ,
466
+
467
+
468
+ text : 'hello friend if you are seeing this, you can not view html emails. it is attached inline.' ,
469
+ attachment : {
470
+ data : text ,
471
+ alternative : true ,
472
+ } ,
473
+ } ;
452
474
453
- t . true ( isValid ) ;
454
- t . is ( validationError , undefined ) ;
475
+ const mail = await send ( msg ) ;
476
+ t . is ( mail . html , text . replace ( / \r / g, '' ) ) ;
477
+ t . is ( mail . text , msg . text + '\n' ) ;
478
+ t . is ( mail . subject , msg . subject ) ;
479
+ t . is ( mail . from ?. text , msg . from ) ;
480
+ t . is ( mail . to ?. text , msg . to ) ;
455
481
} ) ;
0 commit comments