-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35676 from kubabutkiewicz/ts-migration/react-nati…
…ve-airship [No QA][TS migration] Migrate 'react-native-airship.js' mock to TypeScript
- Loading branch information
Showing
3 changed files
with
56 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type {AirshipContact, AirshipPush, AirshipPushAndroid, AirshipPushIOS, AirshipRoot} from '@ua/react-native-airship'; | ||
import {EventType as AirshipEventType, iOS as AirshipIOS} from '@ua/react-native-airship'; | ||
|
||
const EventType: Partial<typeof AirshipEventType> = { | ||
NotificationResponse: AirshipEventType.NotificationResponse, | ||
PushReceived: AirshipEventType.PushReceived, | ||
}; | ||
|
||
const iOS: Partial<typeof AirshipIOS> = { | ||
ForegroundPresentationOption: { | ||
Sound: AirshipIOS.ForegroundPresentationOption.Sound, | ||
Badge: AirshipIOS.ForegroundPresentationOption.Badge, | ||
Banner: AirshipIOS.ForegroundPresentationOption.Banner, | ||
List: AirshipIOS.ForegroundPresentationOption.List, | ||
}, | ||
}; | ||
|
||
const pushIOS: AirshipPushIOS = jest.fn().mockImplementation(() => ({ | ||
setBadgeNumber: jest.fn(), | ||
setForegroundPresentationOptions: jest.fn(), | ||
setForegroundPresentationOptionsCallback: jest.fn(), | ||
}))(); | ||
|
||
const pushAndroid: AirshipPushAndroid = jest.fn().mockImplementation(() => ({ | ||
setForegroundDisplayPredicate: jest.fn(), | ||
}))(); | ||
|
||
const push: AirshipPush = jest.fn().mockImplementation(() => ({ | ||
iOS: pushIOS, | ||
android: pushAndroid, | ||
enableUserNotifications: () => Promise.resolve(false), | ||
clearNotifications: jest.fn(), | ||
getNotificationStatus: () => Promise.resolve({airshipOptIn: false, systemEnabled: false, airshipEnabled: false}), | ||
getActiveNotifications: () => Promise.resolve([]), | ||
}))(); | ||
|
||
const contact: AirshipContact = jest.fn().mockImplementation(() => ({ | ||
identify: jest.fn(), | ||
getNamedUserId: () => Promise.resolve(undefined), | ||
reset: jest.fn(), | ||
module: jest.fn(), | ||
}))(); | ||
|
||
const Airship: Partial<AirshipRoot> = { | ||
addListener: jest.fn(), | ||
removeAllListeners: jest.fn(), | ||
push, | ||
contact, | ||
}; | ||
|
||
export default Airship; | ||
|
||
export {EventType, iOS}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters