-
Notifications
You must be signed in to change notification settings - Fork 379
Expand file tree
/
Copy pathreact-native.ts
More file actions
118 lines (108 loc) · 2.96 KB
/
react-native.ts
File metadata and controls
118 lines (108 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { vi } from 'vitest';
export const createEmitterSubscriptionMock = (
eventName: string,
callback: (payload: unknown) => void,
) => ({
remove: vi.fn(),
emitter: {
addListener: vi.fn(),
removeAllListeners: vi.fn(),
listenerCount: vi.fn(() => 1),
emit: vi.fn(),
},
listener: () => callback,
context: undefined,
eventType: eventName,
key: 0,
subscriber: {
addSubscription: vi.fn(),
removeSubscription: vi.fn(),
removeAllSubscriptions: vi.fn(),
getSubscriptionsForType: vi.fn(),
},
});
const mockRNOneSignal = {
initialize: vi.fn(),
login: vi.fn(),
logout: vi.fn(),
setPrivacyConsentRequired: vi.fn(),
setPrivacyConsentGiven: vi.fn(),
setLogLevel: vi.fn(),
setAlertLevel: vi.fn(),
enterLiveActivity: vi.fn(),
exitLiveActivity: vi.fn(),
setPushToStartToken: vi.fn(),
removePushToStartToken: vi.fn(),
setupDefaultLiveActivity: vi.fn(),
startDefaultLiveActivity: vi.fn(),
addPushSubscriptionObserver: vi.fn(),
getPushSubscriptionId: vi.fn(),
getPushSubscriptionToken: vi.fn(),
getOptedIn: vi.fn(),
optOut: vi.fn(),
optIn: vi.fn(),
addUserStateObserver: vi.fn(),
getOnesignalId: vi.fn(),
getExternalId: vi.fn(),
setLanguage: vi.fn(),
addAlias: vi.fn(),
addAliases: vi.fn(),
removeAlias: vi.fn(),
removeAliases: vi.fn(),
addEmail: vi.fn(),
removeEmail: vi.fn(),
addSms: vi.fn(),
removeSms: vi.fn(),
addTag: vi.fn(),
addTags: vi.fn(),
removeTags: vi.fn(),
getTags: vi.fn(),
hasNotificationPermission: vi.fn(),
requestNotificationPermission: vi.fn(),
canRequestNotificationPermission: vi.fn(),
registerForProvisionalAuthorization: vi.fn(),
permissionNative: vi.fn(),
addNotificationClickListener: vi.fn(),
addNotificationForegroundLifecycleListener: vi.fn(),
addPermissionObserver: vi.fn(),
clearAllNotifications: vi.fn(),
removeNotification: vi.fn(),
removeGroupedNotifications: vi.fn(),
addInAppMessageClickListener: vi.fn(),
addInAppMessagesLifecycleListener: vi.fn(),
addTriggers: vi.fn(),
removeTrigger: vi.fn(),
removeTriggers: vi.fn(),
clearTriggers: vi.fn(),
paused: vi.fn(),
getPaused: vi.fn(),
requestLocationPermission: vi.fn(),
setLocationShared: vi.fn(),
isLocationShared: vi.fn(),
addOutcome: vi.fn(),
addUniqueOutcome: vi.fn(),
addOutcomeWithValue: vi.fn(),
displayNotification: vi.fn(),
preventDefault: vi.fn(),
trackEvent: vi.fn(),
};
const mockPlatform = {
OS: 'ios',
};
export const NativeModules = {
OneSignal: mockRNOneSignal,
};
export const Platform = mockPlatform;
export { mockPlatform, mockRNOneSignal };
export class NativeEventEmitter {
constructor(_nativeModule: typeof mockRNOneSignal) {}
addListener(eventName: string, callback: (payload: unknown) => void) {
return createEmitterSubscriptionMock(eventName, callback);
}
removeListener(_eventName: string, _callback: (payload: unknown) => void) {
// Mock implementation
}
removeAllListeners(_eventName: string) {
// Mock implementation
}
}