@@ -9,6 +9,8 @@ import MailtrapError from "../../lib/MailtrapError";
9
9
import CONFIG from "../../config" ;
10
10
import GeneralAPI from "../../lib/api/General" ;
11
11
import TestingAPI from "../../lib/api/Testing" ;
12
+ import ContactLists from "../../lib/api/ContactLists" ;
13
+ import Contacts from "../../lib/api/Contacts" ;
12
14
13
15
const { ERRORS , CLIENT_SETTINGS } = CONFIG ;
14
16
const { TESTING_ENDPOINT , BULK_ENDPOINT , SENDING_ENDPOINT } = CLIENT_SETTINGS ;
@@ -728,5 +730,57 @@ describe("lib/mailtrap-client: ", () => {
728
730
expect ( generalClient ) . toBeInstanceOf ( GeneralAPI ) ;
729
731
} ) ;
730
732
} ) ;
733
+
734
+ describe ( "get contacts(): " , ( ) => {
735
+ it ( "rejects with Mailtrap error, when `accountId` is missing." , ( ) => {
736
+ const client = new MailtrapClient ( {
737
+ token : "MY_API_TOKEN" ,
738
+ } ) ;
739
+ expect . assertions ( 1 ) ;
740
+
741
+ try {
742
+ client . contacts ;
743
+ } catch ( error ) {
744
+ expect ( error ) . toEqual ( new MailtrapError ( ACCOUNT_ID_MISSING ) ) ;
745
+ }
746
+ } ) ;
747
+
748
+ it ( "returns contacts API object when accountId is provided." , ( ) => {
749
+ const client = new MailtrapClient ( {
750
+ token : "MY_API_TOKEN" ,
751
+ accountId : 10 ,
752
+ } ) ;
753
+ expect . assertions ( 1 ) ;
754
+
755
+ const contactsClient = client . contacts ;
756
+ expect ( contactsClient ) . toBeInstanceOf ( Contacts ) ;
757
+ } ) ;
758
+ } ) ;
759
+
760
+ describe ( "get contactLists(): " , ( ) => {
761
+ it ( "rejects with Mailtrap error, when `accountId` is missing." , ( ) => {
762
+ const client = new MailtrapClient ( {
763
+ token : "MY_API_TOKEN" ,
764
+ } ) ;
765
+ expect . assertions ( 1 ) ;
766
+
767
+ try {
768
+ client . contactLists ;
769
+ } catch ( error ) {
770
+ expect ( error ) . toEqual ( new MailtrapError ( ACCOUNT_ID_MISSING ) ) ;
771
+ }
772
+ } ) ;
773
+
774
+ it ( "returns contact lists API object when accountId is provided." , ( ) => {
775
+ const client = new MailtrapClient ( {
776
+ token : "MY_API_TOKEN" ,
777
+ accountId : 10 ,
778
+ } ) ;
779
+ expect . assertions ( 1 ) ;
780
+
781
+ const contactListsClient = client . contactLists ;
782
+ expect ( contactListsClient ) . toBeInstanceOf ( ContactLists ) ;
783
+ } ) ;
784
+ } ) ;
731
785
} ) ;
732
786
} ) ;
0 commit comments