Skip to content

Commit a8c439d

Browse files
committed
RI-6336 - removed poluted object for testing + fixed unit tests
1 parent 1618b04 commit a8c439d

File tree

3 files changed

+62
-40
lines changed

3 files changed

+62
-40
lines changed

redisinsight/ui/src/pages/browser/components/key-list/KeyList.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ describe('KeyList', () => {
165165
await waitFor(async () => {
166166
expect(apiServiceMock.mock.calls[0]).toEqual([
167167
'/databases//keys/get-metadata',
168-
{ keys: ['key1'], shownColumns },
168+
{ keys: ['key1'], getSize: true, getTtl: true },
169169
params,
170170
])
171171

172172
expect(apiServiceMock.mock.calls[1]).toEqual([
173173
'/databases//keys/get-metadata',
174-
{ keys: ['key1', 'key2', 'key3'], shownColumns },
174+
{ keys: ['key1', 'key2', 'key3'], getSize: true, getTtl: true },
175175
params,
176176
])
177177
}, { timeout: 150 })

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,13 +1694,17 @@ describe('keys slice', () => {
16941694
)
16951695
)
16961696

1697+
const expectedData = {
1698+
keys: data.map(({ name }) => ({ name })),
1699+
type: undefined,
1700+
}
1701+
1702+
expectedData.getTtl = shownColumns.includes(BrowserColumns.TTL)
1703+
expectedData.getSize = shownColumns.includes(BrowserColumns.Size)
1704+
16971705
expect(apiServiceMock).toBeCalledWith(
16981706
'/databases//keys/get-metadata',
1699-
{
1700-
keys: data.map(({ name }) => ({ name })),
1701-
type: undefined,
1702-
shownColumns,
1703-
},
1707+
expectedData,
17041708
{ params: { encoding: 'buffer' }, signal: controller.signal },
17051709
)
17061710

@@ -1771,14 +1775,18 @@ describe('keys slice', () => {
17711775
)
17721776
)
17731777

1778+
const expectedData = {
1779+
keys: data.map(({ name }) => (name)),
1780+
type: undefined
1781+
}
1782+
1783+
expectedData.getTtl = shownColumns.includes(BrowserColumns.TTL)
1784+
expectedData.getSize = shownColumns.includes(BrowserColumns.Size)
1785+
17741786
// Assert
17751787
expect(apiServiceMock).toBeCalledWith(
17761788
'/databases//keys/get-metadata',
1777-
{
1778-
keys: data.map(({ name }) => (name)),
1779-
type: undefined,
1780-
shownColumns,
1781-
},
1789+
expectedData,
17821790
{ params: { encoding: 'buffer' }, signal: controller.signal },
17831791
)
17841792

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

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ beforeEach(() => {
5454
type: 'object',
5555
}
5656

57-
const rootStateWithSelectedKey = Object.assign(initialStateDefault, {
57+
const rootStateWithSelectedKey = {
58+
...initialStateDefault,
5859
browser: {
5960
keys: {
6061
selectedKey: {
@@ -64,7 +65,7 @@ beforeEach(() => {
6465
},
6566
},
6667
},
67-
})
68+
}
6869

6970
storeWithSelectedKey = mockStore(rootStateWithSelectedKey)
7071
})
@@ -95,11 +96,12 @@ describe('rejson slice', () => {
9596
const nextState = reducer(initialState, loadRejsonBranch())
9697

9798
// Assert
98-
const rootState = Object.assign(initialStateDefault, {
99+
const rootState = {
100+
...initialStateDefault,
99101
browser: {
100102
rejson: nextState,
101103
},
102-
})
104+
}
103105
expect(rejsonSelector(rootState)).toEqual(state)
104106
})
105107
})
@@ -121,11 +123,12 @@ describe('rejson slice', () => {
121123
)
122124

123125
// Assert
124-
const rootState = Object.assign(initialStateDefault, {
126+
const rootState = {
127+
...initialStateDefault,
125128
browser: {
126129
rejson: nextState,
127130
},
128-
})
131+
}
129132
expect(rejsonSelector(rootState)).toEqual(state)
130133
})
131134

@@ -143,11 +146,12 @@ describe('rejson slice', () => {
143146
const nextState = reducer(initialState, loadRejsonBranchSuccess(data))
144147

145148
// Assert
146-
const rootState = Object.assign(initialStateDefault, {
149+
const rootState = {
150+
...initialStateDefault,
147151
browser: {
148152
rejson: nextState,
149153
},
150-
})
154+
}
151155
expect(rejsonSelector(rootState)).toEqual(state)
152156
})
153157
})
@@ -166,11 +170,12 @@ describe('rejson slice', () => {
166170
const nextState = reducer(initialState, loadRejsonBranchFailure(data))
167171

168172
// Assert
169-
const rootState = Object.assign(initialStateDefault, {
173+
const rootState = {
174+
...initialStateDefault,
170175
browser: {
171176
rejson: nextState,
172177
},
173-
})
178+
}
174179
expect(rejsonSelector(rootState)).toEqual(state)
175180
})
176181
})
@@ -187,11 +192,12 @@ describe('rejson slice', () => {
187192
const nextState = reducer(initialState, appendReJSONArrayItem())
188193

189194
// Assert
190-
const rootState = Object.assign(initialStateDefault, {
195+
const rootState = {
196+
...initialStateDefault,
191197
browser: {
192198
rejson: nextState,
193199
},
194-
})
200+
}
195201
expect(rejsonSelector(rootState)).toEqual(state)
196202
})
197203
})
@@ -207,11 +213,12 @@ describe('rejson slice', () => {
207213
const nextState = reducer(initialState, appendReJSONArrayItemSuccess())
208214

209215
// Assert
210-
const rootState = Object.assign(initialStateDefault, {
216+
const rootState = {
217+
...initialStateDefault,
211218
browser: {
212219
rejson: nextState,
213220
},
214-
})
221+
}
215222
expect(rejsonSelector(rootState)).toEqual(state)
216223
})
217224
})
@@ -230,11 +237,12 @@ describe('rejson slice', () => {
230237
const nextState = reducer(initialState, appendReJSONArrayItemFailure(data))
231238

232239
// Assert
233-
const rootState = Object.assign(initialStateDefault, {
240+
const rootState = {
241+
...initialStateDefault,
234242
browser: {
235243
rejson: nextState,
236244
},
237-
})
245+
}
238246
expect(rejsonSelector(rootState)).toEqual(state)
239247
})
240248
})
@@ -251,11 +259,12 @@ describe('rejson slice', () => {
251259
const nextState = reducer(initialState, setReJSONData())
252260

253261
// Assert
254-
const rootState = Object.assign(initialStateDefault, {
262+
const rootState = {
263+
...initialStateDefault,
255264
browser: {
256265
rejson: nextState,
257266
},
258-
})
267+
}
259268
expect(rejsonSelector(rootState)).toEqual(state)
260269
})
261270
})
@@ -271,11 +280,12 @@ describe('rejson slice', () => {
271280
const nextState = reducer(initialState, setReJSONDataSuccess())
272281

273282
// Assert
274-
const rootState = Object.assign(initialStateDefault, {
283+
const rootState = {
284+
...initialStateDefault,
275285
browser: {
276286
rejson: nextState,
277287
},
278-
})
288+
}
279289
expect(rejsonSelector(rootState)).toEqual(state)
280290
})
281291
})
@@ -294,11 +304,12 @@ describe('rejson slice', () => {
294304
const nextState = reducer(initialState, setReJSONDataFailure(data))
295305

296306
// Assert
297-
const rootState = Object.assign(initialStateDefault, {
307+
const rootState = {
308+
...initialStateDefault,
298309
browser: {
299310
rejson: nextState,
300311
},
301-
})
312+
}
302313
expect(rejsonSelector(rootState)).toEqual(state)
303314
})
304315
})
@@ -315,11 +326,12 @@ describe('rejson slice', () => {
315326
const nextState = reducer(initialState, removeRejsonKey())
316327

317328
// Assert
318-
const rootState = Object.assign(initialStateDefault, {
329+
const rootState = {
330+
...initialStateDefault,
319331
browser: {
320332
rejson: nextState,
321333
},
322-
})
334+
}
323335
expect(rejsonSelector(rootState)).toEqual(state)
324336
})
325337
})
@@ -335,11 +347,12 @@ describe('rejson slice', () => {
335347
const nextState = reducer(initialState, removeRejsonKeySuccess())
336348

337349
// Assert
338-
const rootState = Object.assign(initialStateDefault, {
350+
const rootState = {
351+
...initialStateDefault,
339352
browser: {
340353
rejson: nextState,
341354
},
342-
})
355+
}
343356
expect(rejsonSelector(rootState)).toEqual(state)
344357
})
345358
})
@@ -358,11 +371,12 @@ describe('rejson slice', () => {
358371
const nextState = reducer(initialState, removeRejsonKeyFailure(data))
359372

360373
// Assert
361-
const rootState = Object.assign(initialStateDefault, {
374+
const rootState = {
375+
...initialStateDefault,
362376
browser: {
363377
rejson: nextState,
364378
},
365-
})
379+
}
366380
expect(rejsonSelector(rootState)).toEqual(state)
367381
})
368382
})

0 commit comments

Comments
 (0)