Skip to content

Commit b4d5126

Browse files
committed
update CommandsHistoryIndexedDB.spec.ts and CommandsHistorySQLite.spec.ts to use current version of msw handler
1 parent ee0dbb7 commit b4d5126

File tree

2 files changed

+68
-77
lines changed

2 files changed

+68
-77
lines changed

redisinsight/ui/src/services/commands-history/database/CommandsHistoryIndexedDB.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { rest } from 'msw'
1+
import { http, HttpResponse } from 'msw'
22
import { faker } from '@faker-js/faker'
33
import {
4-
CommandExecution,
54
CommandExecutionType,
65
CommandExecutionUI,
76
ResultsMode,
@@ -251,12 +250,11 @@ describe('CommandsHistoryIndexedDB', () => {
251250

252251
// Override the MSW handler to return our mock commands
253252
mswServer.use(
254-
rest.post<CommandExecution[]>(
253+
http.post(
255254
getMswURL(
256255
getUrl(mockInstanceId, ApiEndpoints.WORKBENCH_COMMAND_EXECUTIONS),
257256
),
258-
async (_req, res, ctx) =>
259-
res(ctx.status(200), ctx.json(mockCommandExecutions)),
257+
async () => HttpResponse.json(mockCommandExecutions, { status: 200 }),
260258
),
261259
)
262260

@@ -284,11 +282,11 @@ describe('CommandsHistoryIndexedDB', () => {
284282

285283
// Override the MSW handler to return an error status
286284
mswServer.use(
287-
rest.post<CommandExecution[]>(
285+
http.post(
288286
getMswURL(
289287
getUrl(mockInstanceId, ApiEndpoints.WORKBENCH_COMMAND_EXECUTIONS),
290288
),
291-
async (_req, res, ctx) => res(ctx.status(statusCode)),
289+
async () => HttpResponse.text('', { status: statusCode }),
292290
),
293291
)
294292

@@ -318,11 +316,11 @@ describe('CommandsHistoryIndexedDB', () => {
318316

319317
// Override the MSW handler to simulate a network error
320318
mswServer.use(
321-
rest.post<CommandExecution[]>(
319+
http.post(
322320
getMswURL(
323321
getUrl(mockInstanceId, ApiEndpoints.WORKBENCH_COMMAND_EXECUTIONS),
324322
),
325-
async (_req, res) => res.networkError(mockError),
323+
async () => HttpResponse.error(),
326324
),
327325
)
328326

0 commit comments

Comments
 (0)