Skip to content

Commit 53b5e14

Browse files
authored
Merge pull request #452 from Iterable/evan/MOB-5314-linting-changes-to-test-files-and-config-files
[MOB-5314] linting changes to test files and config files
2 parents 6cdba94 + 3e5cd86 commit 53b5e14

File tree

9 files changed

+231
-227
lines changed

9 files changed

+231
-227
lines changed

babel.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
3-
};
2+
presets: ['module:metro-react-native-babel-preset']
3+
}

jest.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
preset: 'react-native',
3-
setupFiles: ["<rootDir>/ts/__mocks__/jest.setup.ts"],
3+
setupFiles: ['<rootDir>/ts/__mocks__/jest.setup.ts'],
44
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
5-
testMatch: ["<rootDir>/ts/__tests__/**/*.(test|spec).[jt]s?(x)"]
6-
};
5+
testMatch: ['<rootDir>/ts/__tests__/**/*.(test|spec).[jt]s?(x)']
6+
}

ts/__mocks__/MockLinking.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
12
export class MockLinking {
23
static canOpenURL = jest.fn()
34
static openURL = jest.fn()
45

56
static addEventListener = jest.fn()
67
static removeEventListener = jest.fn()
78
}
8-

ts/__mocks__/MockRNIterableAPI.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IterableAttributionInfo } from '../Iterable'
22
import IterableInAppMessage from '../IterableInAppMessage'
33

4+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
45
export 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
}

ts/__mocks__/jest.setup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { MockRNIterableAPI } from './MockRNIterableAPI'
22
import { MockLinking } from './MockLinking'
3-
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter.js')
43

54
import * as ReactNative from 'react-native'
5+
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter.js')
66

77
jest.doMock('react-native', () => {
88
// Extend ReactNative
@@ -11,10 +11,10 @@ jest.doMock('react-native', () => {
1111
// Mock RNIterableAPI
1212
NativeModules: {
1313
...ReactNative.NativeModules,
14-
RNIterableAPI: MockRNIterableAPI,
14+
RNIterableAPI: MockRNIterableAPI
1515
},
16-
Linking: MockLinking,
16+
Linking: MockLinking
1717
},
18-
ReactNative,
18+
ReactNative
1919
)
2020
})

0 commit comments

Comments
 (0)