|
1 | 1 | import { registerPushToken } from '../registerPushToken'; |
2 | 2 | import { createLogger } from '../../common/logger'; |
3 | | -import { |
4 | | - ExpoSecureStore, |
5 | | - ExpoApplication, |
6 | | -} from '../../common/optionalDependencies'; |
| 3 | +import { ExpoApplication } from '../../common/optionalDependencies'; |
7 | 4 |
|
8 | 5 | jest.mock('../../common/optionalDependencies', () => ({ |
9 | | - ExpoSecureStore: { |
10 | | - getItemAsync: jest.fn().mockResolvedValue(null), |
11 | | - setItemAsync: jest.fn().mockResolvedValue(undefined), |
12 | | - }, |
13 | 6 | ExpoApplication: { |
14 | 7 | getIosIdForVendorAsync: jest.fn().mockResolvedValue('mock-ios-vendor-id'), |
15 | 8 | getAndroidId: jest.fn().mockReturnValue('mock-android-id'), |
@@ -49,16 +42,6 @@ describe('registerPushToken', () => { |
49 | 42 | Platform.OS = 'ios'; |
50 | 43 | }); |
51 | 44 |
|
52 | | - it('skips registration if token is already registered', async () => { |
53 | | - (ExpoSecureStore!.getItemAsync as jest.Mock).mockResolvedValueOnce( |
54 | | - 'ExponentPushToken[abc123]' |
55 | | - ); |
56 | | - |
57 | | - await registerPushToken(baseParams); |
58 | | - |
59 | | - expect(mockFetch).not.toHaveBeenCalled(); |
60 | | - }); |
61 | | - |
62 | 45 | it('sends request to the correct URL', async () => { |
63 | 46 | await registerPushToken(baseParams); |
64 | 47 |
|
@@ -135,30 +118,11 @@ describe('registerPushToken', () => { |
135 | 118 | ); |
136 | 119 | }); |
137 | 120 |
|
138 | | - it('persists token after successful registration', async () => { |
| 121 | + it('registers token on every call', async () => { |
| 122 | + await registerPushToken(baseParams); |
139 | 123 | await registerPushToken(baseParams); |
140 | 124 |
|
141 | | - expect(ExpoSecureStore!.setItemAsync).toHaveBeenCalledWith( |
142 | | - 'sqlite_sync_push_token_registered', |
143 | | - 'ExponentPushToken[abc123]' |
144 | | - ); |
145 | | - }); |
146 | | - |
147 | | - it('handles SecureStore read errors gracefully', async () => { |
148 | | - (ExpoSecureStore!.getItemAsync as jest.Mock).mockRejectedValueOnce( |
149 | | - new Error('SecureStore read failed') |
150 | | - ); |
151 | | - |
152 | | - await expect(registerPushToken(baseParams)).resolves.toBeUndefined(); |
153 | | - expect(mockFetch).toHaveBeenCalled(); |
154 | | - }); |
155 | | - |
156 | | - it('handles SecureStore write errors gracefully', async () => { |
157 | | - (ExpoSecureStore!.setItemAsync as jest.Mock).mockRejectedValueOnce( |
158 | | - new Error('SecureStore write failed') |
159 | | - ); |
160 | | - |
161 | | - await expect(registerPushToken(baseParams)).resolves.toBeUndefined(); |
| 125 | + expect(mockFetch).toHaveBeenCalledTimes(2); |
162 | 126 | }); |
163 | 127 |
|
164 | 128 | it('throws when ExpoApplication is null', async () => { |
|
0 commit comments