Skip to content

Commit

Permalink
fix(jest): update tests
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Oct 31, 2024
1 parent 4af6dfc commit 566cf69
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/stores/__tests__/settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ describe('settingsStore', () => {
settingsStore.getShowMediaSettings('token-2')]

// Assert
expect(results).toEqual([true, false])
// It's always called at least once : BrowserStorage.getItem('cachedConversations')
// +1
expect(BrowserStorage.getItem).toHaveBeenCalledTimes(1)
// Whenever capabilitiesManager.ts is imported
// +2
expect(BrowserStorage.getItem).toHaveBeenCalledTimes(2)
})

it('shows correct values received from BrowserStorage', () => {
Expand All @@ -89,11 +89,11 @@ describe('settingsStore', () => {

// Assert
expect(results).toEqual([true, true, false])
// It's always called at least once : BrowserStorage.getItem('cachedConversations')
expect(BrowserStorage.getItem).toHaveBeenCalledTimes(4) // 1 + 3
expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(2, 'showMediaSettings_token-1')
expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(3, 'showMediaSettings_token-2')
expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(4, 'showMediaSettings_token-3')
// It's always called at least once : BrowserStorage.getItem('cachedConversations') (+2)
expect(BrowserStorage.getItem).toHaveBeenCalledTimes(5) // 2 + 3
expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(3, 'showMediaSettings_token-1')
expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(4, 'showMediaSettings_token-2')
expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(5, 'showMediaSettings_token-3')
})

it('updates values correctly', async () => {
Expand All @@ -109,8 +109,8 @@ describe('settingsStore', () => {

// Assert
expect(results).toEqual([false, true])
// It's always called at least once : BrowserStorage.getItem('cachedConversations')
expect(BrowserStorage.getItem).toHaveBeenCalledTimes(1)
// It's always called at least once : BrowserStorage.getItem('cachedConversations') (+2)
expect(BrowserStorage.getItem).toHaveBeenCalledTimes(2)
expect(BrowserStorage.setItem).toHaveBeenCalledTimes(2)
expect(BrowserStorage.setItem).toHaveBeenNthCalledWith(1, 'showMediaSettings_token-1', 'false')
expect(BrowserStorage.setItem).toHaveBeenNthCalledWith(2, 'showMediaSettings_token-2', 'true')
Expand Down

0 comments on commit 566cf69

Please sign in to comment.