Skip to content

Commit df59ba7

Browse files
committed
RI-6336 - removed poluted object for testing
1 parent 01e8c40 commit df59ba7

File tree

1 file changed

+61
-40
lines changed

1 file changed

+61
-40
lines changed

redisinsight/ui/src/slices/tests/browser/hash.spec.ts

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ describe('hash slice', () => {
9393
const nextState = reducer(initialState, loadHashFields(['*', undefined]))
9494

9595
// Assert
96-
const rootState = Object.assign(initialStateDefault, {
96+
const rootState = {
97+
...initialStateDefault,
9798
browser: { hash: nextState },
98-
})
99+
}
99100
expect(hashSelector(rootState)).toEqual(state)
100101
})
101102
})
@@ -126,9 +127,10 @@ describe('hash slice', () => {
126127
const nextState = reducer(initialState, loadHashFieldsSuccess(data))
127128

128129
// Assert
129-
const rootState = Object.assign(initialStateDefault, {
130+
const rootState = {
131+
...initialStateDefault,
130132
browser: { hash: nextState },
131-
})
133+
}
132134
expect(hashSelector(rootState)).toEqual(state)
133135
})
134136

@@ -156,9 +158,10 @@ describe('hash slice', () => {
156158
const nextState = reducer(initialState, loadHashFieldsSuccess(data))
157159

158160
// Assert
159-
const rootState = Object.assign(initialStateDefault, {
161+
const rootState = {
162+
...initialStateDefault,
160163
browser: { hash: nextState },
161-
})
164+
}
162165
expect(hashSelector(rootState)).toEqual(state)
163166
})
164167
})
@@ -177,9 +180,10 @@ describe('hash slice', () => {
177180
const nextState = reducer(initialState, loadHashFieldsFailure(data))
178181

179182
// Assert
180-
const rootState = Object.assign(initialStateDefault, {
183+
const rootState = {
184+
...initialStateDefault,
181185
browser: { hash: nextState },
182-
})
186+
}
183187
expect(hashSelector(rootState)).toEqual(state)
184188
})
185189
})
@@ -197,9 +201,10 @@ describe('hash slice', () => {
197201
const nextState = reducer(initialState, loadMoreHashFields())
198202

199203
// Assert
200-
const rootState = Object.assign(initialStateDefault, {
204+
const rootState = {
205+
...initialStateDefault,
201206
browser: { hash: nextState },
202-
})
207+
}
203208
expect(hashSelector(rootState)).toEqual(state)
204209
})
205210
})
@@ -228,9 +233,10 @@ describe('hash slice', () => {
228233
const nextState = reducer(initialState, loadMoreHashFieldsSuccess(data))
229234

230235
// Assert
231-
const rootState = Object.assign(initialStateDefault, {
236+
const rootState = {
237+
...initialStateDefault,
232238
browser: { hash: nextState },
233-
})
239+
}
234240
expect(hashSelector(rootState)).toEqual(state)
235241
})
236242

@@ -256,9 +262,10 @@ describe('hash slice', () => {
256262
const nextState = reducer(initialState, loadMoreHashFieldsSuccess(data))
257263

258264
// Assert
259-
const rootState = Object.assign(initialStateDefault, {
265+
const rootState = {
266+
...initialStateDefault,
260267
browser: { hash: nextState },
261-
})
268+
}
262269
expect(hashSelector(rootState)).toEqual(state)
263270
})
264271
})
@@ -277,9 +284,10 @@ describe('hash slice', () => {
277284
const nextState = reducer(initialState, loadMoreHashFieldsFailure(data))
278285

279286
// Assert
280-
const rootState = Object.assign(initialStateDefault, {
287+
const rootState = {
288+
...initialStateDefault,
281289
browser: { hash: nextState },
282-
})
290+
}
283291
expect(hashSelector(rootState)).toEqual(state)
284292
})
285293
})
@@ -296,9 +304,10 @@ describe('hash slice', () => {
296304
const nextState = reducer(initialState, removeHashFields())
297305

298306
// Assert
299-
const rootState = Object.assign(initialStateDefault, {
307+
const rootState = {
308+
...initialStateDefault,
300309
browser: { hash: nextState },
301-
})
310+
}
302311
expect(hashSelector(rootState)).toEqual(state)
303312
})
304313
})
@@ -319,9 +328,10 @@ describe('hash slice', () => {
319328
const nextState = reducer(initailStateRemove, removeHashFieldsSuccess())
320329

321330
// Assert
322-
const rootState = Object.assign(initialStateDefault, {
331+
const rootState = {
332+
...initialStateDefault,
323333
browser: { hash: nextState },
324-
})
334+
}
325335
expect(hashSelector(rootState)).toEqual(initailStateRemove)
326336
})
327337
})
@@ -340,9 +350,10 @@ describe('hash slice', () => {
340350
const nextState = reducer(initialState, removeHashFieldsFailure(data))
341351

342352
// Assert
343-
const rootState = Object.assign(initialStateDefault, {
353+
const rootState = {
354+
...initialStateDefault,
344355
browser: { hash: nextState },
345-
})
356+
}
346357
expect(hashSelector(rootState)).toEqual(state)
347358
})
348359
})
@@ -377,9 +388,10 @@ describe('hash slice', () => {
377388
const nextState = reducer(initialStateRemove, removeFieldsFromList(data))
378389

379390
// Assert
380-
const rootState = Object.assign(initialStateDefault, {
391+
const rootState = {
392+
...initialStateDefault,
381393
browser: { hash: nextState },
382-
})
394+
}
383395
expect(hashSelector(rootState)).toEqual(state)
384396
})
385397
})
@@ -400,9 +412,10 @@ describe('hash slice', () => {
400412
const nextState = reducer(initialState, updateValue())
401413

402414
// Assert
403-
const rootState = Object.assign(initialStateDefault, {
415+
const rootState = {
416+
...initialStateDefault,
404417
browser: { hash: nextState },
405-
})
418+
}
406419
expect(hashSelector(rootState)).toEqual(state)
407420
})
408421
})
@@ -423,9 +436,10 @@ describe('hash slice', () => {
423436
const nextState = reducer(initialState, updateValueSuccess())
424437

425438
// Assert
426-
const rootState = Object.assign(initialStateDefault, {
439+
const rootState = {
440+
...initialStateDefault,
427441
browser: { hash: nextState },
428-
})
442+
}
429443
expect(hashSelector(rootState)).toEqual(state)
430444
})
431445
})
@@ -447,9 +461,10 @@ describe('hash slice', () => {
447461
const nextState = reducer(initialState, updateValueFailure(data))
448462

449463
// Assert
450-
const rootState = Object.assign(initialStateDefault, {
464+
const rootState = {
465+
...initialStateDefault,
451466
browser: { hash: nextState },
452-
})
467+
}
453468
expect(hashSelector(rootState)).toEqual(state)
454469
})
455470
})
@@ -470,9 +485,10 @@ describe('hash slice', () => {
470485
const nextState = reducer(initialState, resetUpdateValue())
471486

472487
// Assert
473-
const rootState = Object.assign(initialStateDefault, {
488+
const rootState = {
489+
...initialStateDefault,
474490
browser: { hash: nextState },
475-
})
491+
}
476492
expect(hashSelector(rootState)).toEqual(state)
477493
})
478494
})
@@ -508,7 +524,7 @@ describe('hash slice', () => {
508524
describe('fetchMoreHashFields', () => {
509525
it(
510526
'call fetchMoreHashFields, loadMoreHashFieldsSuccess,'
511-
+ ' when fetch is successed',
527+
+ ' when fetch is successed',
512528
async () => {
513529
// Arrange
514530
const data = {
@@ -566,15 +582,19 @@ describe('hash slice', () => {
566582
describe('deleteHashFields', () => {
567583
it(
568584
'call removeHashFields, removeHashFieldsSuccess,'
569-
+ ' and removeFieldsFromList when fetch is successed',
585+
+ ' and removeFieldsFromList when fetch is successed',
570586
async () => {
571587
// Arrange
572588

573589
const key = stringToBuffer('key')
574590
const fields = ['hash field', 'hash field 2'].map((field) => stringToBuffer(field))
575591
const responsePayload = { status: 200, data: { affected: 2 } }
576-
const nextState = Object.assign(initialStateDefault, {
592+
const nextState = {
593+
...initialStateDefault,
577594
browser: {
595+
keys: {
596+
...initialStateDefault.browser.keys,
597+
},
578598
hash: {
579599
...initialState,
580600
data: {
@@ -583,7 +603,7 @@ describe('hash slice', () => {
583603
}
584604
}
585605
},
586-
})
606+
}
587607

588608
const mockedStore = mockStore(nextState)
589609

@@ -622,7 +642,8 @@ describe('hash slice', () => {
622642
const key = 'key'
623643
const fields = ['hash field', 'hash field 2']
624644
const responsePayload = { status: 200, data: { affected: 2 } }
625-
const nextState = Object.assign(initialStateDefault, {
645+
const nextState = {
646+
...initialStateDefault,
626647
browser: {
627648
hash: {
628649
...initialState,
@@ -632,7 +653,7 @@ describe('hash slice', () => {
632653
}
633654
}
634655
},
635-
})
656+
}
636657

637658
const mockedStore = mockStore(nextState)
638659

@@ -668,7 +689,7 @@ describe('hash slice', () => {
668689
apiService.put = jest.fn().mockResolvedValue(responsePayload)
669690

670691
// Act
671-
await store.dispatch<any>(addHashFieldsAction({ keyName, fields }))
692+
await mockedStore.dispatch<any>(addHashFieldsAction({ keyName, fields }))
672693

673694
// Assert
674695
const expectedActions = [
@@ -744,7 +765,7 @@ describe('hash slice', () => {
744765
apiService.put = jest.fn().mockRejectedValue(responsePayload)
745766

746767
// Act
747-
await store.dispatch<any>(updateHashFieldsAction({ keyName, fields }))
768+
await mockedStore.dispatch<any>(updateHashFieldsAction({ keyName, fields }))
748769

749770
// Assert
750771
const expectedActions = [

0 commit comments

Comments
 (0)