File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import GeneralAPI from "../../lib/api/General";
11
11
import TestingAPI from "../../lib/api/Testing" ;
12
12
import ContactLists from "../../lib/api/ContactLists" ;
13
13
import Contacts from "../../lib/api/Contacts" ;
14
+ import TemplatesBaseAPI from "../../lib/api/Templates" ;
14
15
15
16
const { ERRORS , CLIENT_SETTINGS } = CONFIG ;
16
17
const { TESTING_ENDPOINT , BULK_ENDPOINT , SENDING_ENDPOINT } = CLIENT_SETTINGS ;
@@ -782,5 +783,31 @@ describe("lib/mailtrap-client: ", () => {
782
783
expect ( contactListsClient ) . toBeInstanceOf ( ContactLists ) ;
783
784
} ) ;
784
785
} ) ;
786
+
787
+ describe ( "get templates(): " , ( ) => {
788
+ it ( "rejects with Mailtrap error, when `accountId` is missing." , ( ) => {
789
+ const client = new MailtrapClient ( {
790
+ token : "MY_API_TOKEN" ,
791
+ } ) ;
792
+ expect . assertions ( 1 ) ;
793
+
794
+ try {
795
+ client . templates ;
796
+ } catch ( error ) {
797
+ expect ( error ) . toEqual ( new MailtrapError ( ACCOUNT_ID_MISSING ) ) ;
798
+ }
799
+ } ) ;
800
+
801
+ it ( "returns templates API object when accountId is provided." , ( ) => {
802
+ const client = new MailtrapClient ( {
803
+ token : "MY_API_TOKEN" ,
804
+ accountId : 10 ,
805
+ } ) ;
806
+ expect . assertions ( 1 ) ;
807
+
808
+ const templatesClient = client . templates ;
809
+ expect ( templatesClient ) . toBeInstanceOf ( TemplatesBaseAPI ) ;
810
+ } ) ;
811
+ } ) ;
785
812
} ) ;
786
813
} ) ;
You can’t perform that action at this time.
0 commit comments