-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: only request new notification signatures (#2575)
- Loading branch information
Showing
2 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
...onents/settings/PushNotifications/PushNotificationsBanner/PushNotificationsBanner.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,84 @@ | ||
import { _getSafesToRegister } from '.' | ||
import type { AddedSafesState } from '@/store/addedSafesSlice' | ||
import type { PushNotificationPreferences } from '@/services/push-notifications/preferences' | ||
|
||
describe('PushNotificationsBanner', () => { | ||
describe('getSafesToRegister', () => { | ||
it('should return all added safes if no preferences exist', () => { | ||
const addedSafes = { | ||
'1': { | ||
'0x123': {}, | ||
'0x456': {}, | ||
}, | ||
'4': { | ||
'0x789': {}, | ||
}, | ||
} as unknown as AddedSafesState | ||
const allPreferences = undefined | ||
|
||
const result = _getSafesToRegister(addedSafes, allPreferences) | ||
|
||
expect(result).toEqual({ | ||
'1': ['0x123', '0x456'], | ||
'4': ['0x789'], | ||
}) | ||
}) | ||
|
||
it('should return only newly added safes if preferences exist', () => { | ||
const addedSafes = { | ||
'1': { | ||
'0x123': {}, | ||
'0x456': {}, | ||
}, | ||
'4': { | ||
'0x789': {}, | ||
}, | ||
} as unknown as AddedSafesState | ||
const allPreferences = { | ||
'1:0x123': { | ||
safeAddress: '0x123', | ||
chainId: '1', | ||
}, | ||
'4:0x789': { | ||
safeAddress: '0x789', | ||
chainId: '4', | ||
}, | ||
} as unknown as PushNotificationPreferences | ||
|
||
const result = _getSafesToRegister(addedSafes, allPreferences) | ||
|
||
expect(result).toEqual({ | ||
'1': ['0x456'], | ||
}) | ||
}) | ||
|
||
it('should return all added safes if no preferences match', () => { | ||
const addedSafes = { | ||
'1': { | ||
'0x123': {}, | ||
'0x456': {}, | ||
}, | ||
'4': { | ||
'0x789': {}, | ||
}, | ||
} as unknown as AddedSafesState | ||
const allPreferences = { | ||
'1:0x111': { | ||
safeAddress: '0x111', | ||
chainId: '1', | ||
}, | ||
'4:0x222': { | ||
safeAddress: '0x222', | ||
chainId: '4', | ||
}, | ||
} as unknown as PushNotificationPreferences | ||
|
||
const result = _getSafesToRegister(addedSafes, allPreferences) | ||
|
||
expect(result).toEqual({ | ||
'1': ['0x123', '0x456'], | ||
'4': ['0x789'], | ||
}) | ||
}) | ||
}) | ||
}) |
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