1
1
import { IterableAttributionInfo } from '../Iterable'
2
2
import IterableInAppMessage from '../IterableInAppMessage'
3
3
4
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class
4
5
export class MockRNIterableAPI {
5
6
static email ?: string
6
7
static userId ?: string
@@ -10,24 +11,24 @@ export class MockRNIterableAPI {
10
11
static messages ?: IterableInAppMessage [ ]
11
12
static clickedUrl ?: string
12
13
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 ) => {
15
16
resolve ( MockRNIterableAPI . email )
16
17
} )
17
18
}
18
19
19
- static setEmail ( email : string , authToken ?: string | undefined ) {
20
+ static setEmail ( email : string , authToken ?: string | undefined ) : void {
20
21
MockRNIterableAPI . email = email
21
22
MockRNIterableAPI . token = authToken
22
23
}
23
24
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 ) => {
26
27
resolve ( MockRNIterableAPI . userId )
27
28
} )
28
29
}
29
30
30
- static setUserId ( userId : string , authToken ?: string | undefined ) {
31
+ static setUserId ( userId : string , authToken ?: string | undefined ) : void {
31
32
MockRNIterableAPI . userId = userId
32
33
MockRNIterableAPI . token = authToken
33
34
}
@@ -48,36 +49,36 @@ export class MockRNIterableAPI {
48
49
49
50
static trackEvent = jest . fn ( )
50
51
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 ) => {
53
54
resolve ( MockRNIterableAPI . lastPushPayload )
54
55
} )
55
56
}
56
57
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 ) => {
59
60
resolve ( MockRNIterableAPI . attributionInfo )
60
61
} )
61
62
}
62
63
63
- static setAttributionInfo ( attributionInfo ?: IterableAttributionInfo ) {
64
+ static setAttributionInfo ( attributionInfo ?: IterableAttributionInfo ) : void {
64
65
MockRNIterableAPI . attributionInfo = attributionInfo
65
66
}
66
67
67
68
static initializeWithApiKey = jest . fn ( )
68
69
69
70
static setInAppShowResponse = jest . fn ( )
70
71
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 ) => {
73
74
resolve ( MockRNIterableAPI . messages )
74
75
} )
75
76
}
76
77
77
78
static setAutoDisplayPaused = jest . fn ( )
78
79
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 ) => {
81
82
resolve ( MockRNIterableAPI . clickedUrl )
82
83
} )
83
84
}
@@ -98,13 +99,13 @@ export class MockRNIterableAPI {
98
99
99
100
// set messages function is to set the messages static property
100
101
// this is for testing purposes only
101
- static setMessages ( messages : IterableInAppMessage [ ] ) {
102
+ static setMessages ( messages : IterableInAppMessage [ ] ) : void {
102
103
MockRNIterableAPI . messages = messages
103
104
}
104
-
105
+
105
106
// setClickedUrl function is to set the messages static property
106
107
// this is for testing purposes only
107
- static setClickedUrl ( clickedUrl : string ) {
108
+ static setClickedUrl ( clickedUrl : string ) : void {
108
109
MockRNIterableAPI . clickedUrl = clickedUrl
109
110
}
110
111
}
0 commit comments