11import { IterableAttributionInfo } from '../Iterable'
22import IterableInAppMessage from '../IterableInAppMessage'
33
4+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class
45export class MockRNIterableAPI {
56 static email ?: string
67 static userId ?: string
@@ -10,24 +11,24 @@ export class MockRNIterableAPI {
1011 static messages ?: IterableInAppMessage [ ]
1112 static clickedUrl ?: string
1213
13- static getEmail ( ) : Promise < string | undefined > {
14- return new Promise ( ( resolve , _ ) => {
14+ static async getEmail ( ) : Promise < string | undefined > {
15+ return await new Promise ( ( resolve , reject ) => {
1516 resolve ( MockRNIterableAPI . email )
1617 } )
1718 }
1819
19- static setEmail ( email : string , authToken ?: string | undefined ) {
20+ static setEmail ( email : string , authToken ?: string | undefined ) : void {
2021 MockRNIterableAPI . email = email
2122 MockRNIterableAPI . token = authToken
2223 }
2324
24- static getUserId ( ) : Promise < string | undefined > {
25- return new Promise ( ( resolve , _ ) => {
25+ static async getUserId ( ) : Promise < string | undefined > {
26+ return await new Promise ( ( resolve , reject ) => {
2627 resolve ( MockRNIterableAPI . userId )
2728 } )
2829 }
2930
30- static setUserId ( userId : string , authToken ?: string | undefined ) {
31+ static setUserId ( userId : string , authToken ?: string | undefined ) : void {
3132 MockRNIterableAPI . userId = userId
3233 MockRNIterableAPI . token = authToken
3334 }
@@ -48,36 +49,36 @@ export class MockRNIterableAPI {
4849
4950 static trackEvent = jest . fn ( )
5051
51- static getLastPushPayload ( ) : Promise < any | undefined > {
52- return new Promise ( ( resolve , _ ) => {
52+ static async getLastPushPayload ( ) : Promise < any | undefined > {
53+ return await new Promise ( ( resolve , reject ) => {
5354 resolve ( MockRNIterableAPI . lastPushPayload )
5455 } )
5556 }
5657
57- static getAttributionInfo ( ) : Promise < IterableAttributionInfo | undefined > {
58- return new Promise ( ( resolve , _ ) => {
58+ static async getAttributionInfo ( ) : Promise < IterableAttributionInfo | undefined > {
59+ return await new Promise ( ( resolve , reject ) => {
5960 resolve ( MockRNIterableAPI . attributionInfo )
6061 } )
6162 }
6263
63- static setAttributionInfo ( attributionInfo ?: IterableAttributionInfo ) {
64+ static setAttributionInfo ( attributionInfo ?: IterableAttributionInfo ) : void {
6465 MockRNIterableAPI . attributionInfo = attributionInfo
6566 }
6667
6768 static initializeWithApiKey = jest . fn ( )
6869
6970 static setInAppShowResponse = jest . fn ( )
7071
71- static getInAppMessages ( ) : Promise < IterableInAppMessage [ ] | undefined > {
72- return new Promise ( ( resolve , _ ) => {
72+ static async getInAppMessages ( ) : Promise < IterableInAppMessage [ ] | undefined > {
73+ return await new Promise ( ( resolve , reject ) => {
7374 resolve ( MockRNIterableAPI . messages )
7475 } )
7576 }
7677
7778 static setAutoDisplayPaused = jest . fn ( )
7879
79- static showMessage ( message : IterableInAppMessage , consume : boolean ) : Promise < string | undefined > {
80- return new Promise ( ( resolve , _ ) => {
80+ static async showMessage ( message : IterableInAppMessage , consume : boolean ) : Promise < string | undefined > {
81+ return await new Promise ( ( resolve , reject ) => {
8182 resolve ( MockRNIterableAPI . clickedUrl )
8283 } )
8384 }
@@ -98,13 +99,13 @@ export class MockRNIterableAPI {
9899
99100 // set messages function is to set the messages static property
100101 // this is for testing purposes only
101- static setMessages ( messages : IterableInAppMessage [ ] ) {
102+ static setMessages ( messages : IterableInAppMessage [ ] ) : void {
102103 MockRNIterableAPI . messages = messages
103104 }
104-
105+
105106 // setClickedUrl function is to set the messages static property
106107 // this is for testing purposes only
107- static setClickedUrl ( clickedUrl : string ) {
108+ static setClickedUrl ( clickedUrl : string ) : void {
108109 MockRNIterableAPI . clickedUrl = clickedUrl
109110 }
110111}
0 commit comments