Skip to content

Commit

Permalink
chore(deps): update dependency msw to v2 (#1600)
Browse files Browse the repository at this point in the history
* Update dependency msw to v2

* fix: Update import statements in opsAPI.test.js and mocks.js to use http instead of rest

* remakes bun lock

* chore(deps): update dependency msw to v2

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: fpigeonjr <[email protected]>
  • Loading branch information
renovate[bot] and fpigeonjr authored Apr 3, 2024
1 parent 657b057 commit c962f78
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Binary file modified frontend/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"history": "5.3.0",
"jose": "5.2.2",
"jsdom": "24.0.0",
"msw": "1.3.2",
"msw": "2.2.13",
"prettier": "3.2.5",
"redux-mock-store": "1.5.4",
"vite": "5.2.7",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/api/opsAPI.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { server } from "../helpers/mocks";
import { rest } from "msw";
import { http } from "msw";
import { waitFor } from "@testing-library/react";
import { useGetAgreementsQuery } from "./opsAPI";
import { renderWithProviders } from "../test-utils";
Expand All @@ -25,7 +25,7 @@ describe("opsApi", () => {
// This will override any API qury performed, for all endpoints,
// and return our mocked response.
server.use(
rest.get(`*`, (req, res, ctx) => {
http.get(`*`, (req, res, ctx) => {
return res(ctx.status(200), ctx.json(mockData));
})
);
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/helpers/mocks.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { rest } from "msw";
import { http } from "msw";
import { setupServer } from "msw/node";

// const BACKEND_DOMAIN = import.meta.env.VITE_BACKEND_DOMAIN;
// Adding optional runtime config.
const BACKEND_DOMAIN = window.__RUNTIME_CONFIG__?.REACT_APP_BACKEND_DOMAIN || import.meta.env.VITE_BACKEND_DOMAIN;

export const handlers = [
rest.get(`${BACKEND_DOMAIN}/api/v1/agreements/`, (req, res, ctx) => {
http.get(`${BACKEND_DOMAIN}/api/v1/agreements/`, (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json([
Expand All @@ -17,13 +17,13 @@ export const handlers = [
);
}),

rest.get(`${BACKEND_DOMAIN}/api/v1/agreements/:id`, (req, res, ctx) => {
http.get(`${BACKEND_DOMAIN}/api/v1/agreements/:id`, (req, res, ctx) => {
const { id } = req.params;

return res(ctx.status(200), ctx.json({ id, name: `Agreement ${id}` }));
}),

rest.get(`${BACKEND_DOMAIN}/api/v1/research-projects/`, (req, res, ctx) => {
http.get(`${BACKEND_DOMAIN}/api/v1/research-projects/`, (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json([
Expand All @@ -34,7 +34,7 @@ export const handlers = [
);
}),

rest.post(`${BACKEND_DOMAIN}/api/v1/research-projects/`, (req, res, ctx) => {
http.post(`${BACKEND_DOMAIN}/api/v1/research-projects/`, (req, res, ctx) => {
const { body } = req;

return res(ctx.status(201), ctx.json({ id: 3, name: body.name }), ctx.delay(150));
Expand Down

0 comments on commit c962f78

Please sign in to comment.