From a0d76665cc25315477e8fb8b38a40fb8a4e481a1 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Thu, 31 Oct 2024 21:04:33 +0100 Subject: [PATCH] fix(jest): update tests Signed-off-by: DorraJaouad --- src/stores/__tests__/settings.spec.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/stores/__tests__/settings.spec.js b/src/stores/__tests__/settings.spec.js index baa9cbb8ba2..b36a55cd187 100644 --- a/src/stores/__tests__/settings.spec.js +++ b/src/stores/__tests__/settings.spec.js @@ -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', () => { @@ -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 () => { @@ -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')