-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework remote promo sheet logic / designs (#6085)
* immediately set isShown when we're going to show a sheet * improvements to remote promo sheets * partialize persistence and fix some light mode / dark mode oddities * add targeted version check * rename func * fix type * fix exported function name * fix promo sheet check to handle all multiple addresses * improve checks * re-memo sync * cleanup * undo address specific store change --------- Co-authored-by: Ibrahim Taveras <[email protected]>
- Loading branch information
1 parent
2aa7bae
commit a0d629f
Showing
13 changed files
with
268 additions
and
178 deletions.
There are no files selected for viewing
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
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
54 changes: 54 additions & 0 deletions
54
src/components/remote-promo-sheet/check-fns/__tests__/isTargetedVersionOrNewer.test.ts
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,54 @@ | ||
import { isTargetedVersionOrNewer } from '../isTargetedVersionOrNewer'; | ||
import * as DeviceInfo from 'react-native-device-info'; | ||
|
||
jest.mock('react-native-device-info', () => ({ | ||
getVersion: jest.fn(), | ||
})); | ||
|
||
describe('isTargetedVersionOrNewer', () => { | ||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
it('should return true when current app version is newer than version to check', async () => { | ||
(DeviceInfo.getVersion as jest.Mock).mockReturnValue('2.0.0'); | ||
const result = await isTargetedVersionOrNewer('1.9.0'); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should return false when current app version is older than version to check', async () => { | ||
(DeviceInfo.getVersion as jest.Mock).mockReturnValue('1.8.0'); | ||
const result = await isTargetedVersionOrNewer('1.9.0'); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
it('should return true when versions are equal', async () => { | ||
(DeviceInfo.getVersion as jest.Mock).mockReturnValue('1.9.0'); | ||
const result = await isTargetedVersionOrNewer('1.9.0'); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should handle patch versions correctly', async () => { | ||
(DeviceInfo.getVersion as jest.Mock).mockReturnValue('1.9.1'); | ||
const result = await isTargetedVersionOrNewer('1.9.0'); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should handle versions with different number of parts', async () => { | ||
(DeviceInfo.getVersion as jest.Mock).mockReturnValue('2.0'); | ||
const result = await isTargetedVersionOrNewer('1.9.9'); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should return true when versions are equal but have different number of parts', async () => { | ||
(DeviceInfo.getVersion as jest.Mock).mockReturnValue('2.0.0'); | ||
const result = await isTargetedVersionOrNewer('2.0'); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should return false when current app version is older with different number of parts', async () => { | ||
(DeviceInfo.getVersion as jest.Mock).mockReturnValue('1.9'); | ||
const result = await isTargetedVersionOrNewer('2.0.0'); | ||
expect(result).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.