@@ -15,7 +15,7 @@ import TemplatesBaseAPI from "../../lib/api/Templates";
15
15
16
16
const { ERRORS , CLIENT_SETTINGS } = CONFIG ;
17
17
const { TESTING_ENDPOINT , BULK_ENDPOINT , SENDING_ENDPOINT } = CLIENT_SETTINGS ;
18
- const { TEST_INBOX_ID_MISSING , ACCOUNT_ID_MISSING , BULK_SANDBOX_INCOMPATIBLE } =
18
+ const { ACCOUNT_ID_MISSING , BULK_SANDBOX_INCOMPATIBLE , TEST_INBOX_ID_MISSING } =
19
19
ERRORS ;
20
20
21
21
describe ( "lib/mailtrap-client: " , ( ) => {
@@ -331,6 +331,23 @@ describe("lib/mailtrap-client: ", () => {
331
331
}
332
332
} ) ;
333
333
334
+ it ( "throws MailtrapError(TEST_INBOX_ID_MISSING) when sending in sandbox mode without testInboxId" , async ( ) => {
335
+ const client = new MailtrapClient ( {
336
+ token : "MY_API_TOKEN" ,
337
+ sandbox : true ,
338
+ accountId : 123 ,
339
+ } ) ;
340
+
341
+ await expect (
342
+ client . send ( {
343
+ from :
{ email :
"[email protected] " , name :
"Sender" } ,
344
+ to :
[ { email :
"[email protected] " } ] ,
345
+ subject : "Test" ,
346
+ text : "Body" ,
347
+ } )
348
+ ) . rejects . toEqual ( new MailtrapError ( TEST_INBOX_ID_MISSING ) ) ;
349
+ } ) ;
350
+
334
351
describe ( "batch sending:" , ( ) => {
335
352
it ( "rejects with Mailtrap error when bulk and sandbox modes are used together" , async ( ) => {
336
353
const batchClient = new MailtrapClient ( {
@@ -664,20 +681,6 @@ describe("lib/mailtrap-client: ", () => {
664
681
} ) ;
665
682
666
683
describe ( "get testing(): " , ( ) => {
667
- it ( "rejects with Mailtrap error, when `testInboxId` is missing." , ( ) => {
668
- const client = new MailtrapClient ( {
669
- token : "MY_API_TOKEN" ,
670
- } ) ;
671
-
672
- expect . assertions ( 1 ) ;
673
-
674
- try {
675
- client . testing ;
676
- } catch ( error ) {
677
- expect ( error ) . toEqual ( new MailtrapError ( TEST_INBOX_ID_MISSING ) ) ;
678
- }
679
- } ) ;
680
-
681
684
it ( "rejects with Mailtrap error, when `accountId` is missing." , ( ) => {
682
685
const client = new MailtrapClient ( {
683
686
token : "MY_API_TOKEN" ,
0 commit comments