Skip to content

Commit e747751

Browse files
committed
Clean up store before every test case
Signed-off-by: Gnanesh <[email protected]>
1 parent 0be9759 commit e747751

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

redisinsight/ui/src/slices/tests/instances/clientCerts.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AxiosError } from 'axios'
22
import { cloneDeep } from 'lodash'
33
import { apiService } from 'uiSrc/services'
44
import { addErrorNotification } from 'uiSrc/slices/app/notifications'
5-
import { initialStateDefault, mockedStore } from 'uiSrc/utils/test-utils'
5+
import { cleanup, initialStateDefault, mockedStore } from 'uiSrc/utils/test-utils'
66
import reducer, {
77
initialState,
88
loadClientCerts,
@@ -20,6 +20,13 @@ jest.mock('uiSrc/services', () => ({
2020
...jest.requireActual('uiSrc/services'),
2121
}))
2222

23+
let store: typeof mockedStore
24+
beforeEach(() => {
25+
cleanup()
26+
store = cloneDeep(mockedStore)
27+
store.clearActions()
28+
})
29+
2330
describe('clientCerts slice', () => {
2431
describe('reducer, actions and selectors', () => {
2532
it('should return the initial state on first run', () => {
@@ -201,7 +208,6 @@ describe('clientCerts slice', () => {
201208
const responsePayload = { data, status: 200 }
202209

203210
apiService.get = jest.fn().mockResolvedValue(responsePayload)
204-
const store = cloneDeep(mockedStore)
205211

206212
// Act
207213
await store.dispatch<any>(fetchClientCerts())
@@ -231,8 +237,6 @@ describe('clientCerts slice', () => {
231237

232238
const id = '70b95d32-c19d-4311-bb24-e684af12cf15'
233239

234-
const store = cloneDeep(mockedStore)
235-
236240
// Act
237241
await store.dispatch<any>(deleteClientCertAction(id, onSuccessAction))
238242

@@ -259,8 +263,6 @@ describe('clientCerts slice', () => {
259263
const onSuccessAction = jest.fn()
260264
const id = '70b95d32-c19d-4311-bb24-e684af12cf15'
261265

262-
const store = cloneDeep(mockedStore)
263-
264266
// Act
265267
await store.dispatch<any>(deleteClientCertAction(id, onSuccessAction))
266268

0 commit comments

Comments
 (0)