Skip to content

Commit d85a9d7

Browse files
committed
refactor: refactor handlers
1 parent 8416c70 commit d85a9d7

12 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/features/auth/components/SignInForm.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Meta, StoryObj } from "@storybook/react-vite";
22
import { userEvent, within, screen, expect } from "storybook/test";
33

4-
import { getSignInHandler } from "@/test-lib/handlers/sign-in-handler";
4+
import { postSignInHandler } from "@/test-lib/handlers/post-sign-in-handler";
55
import { sleep } from "@/test-lib/storybook/sleep";
66

77
import { SignInForm } from "./SignInForm";
@@ -12,7 +12,7 @@ const meta = {
1212
parameters: {
1313
layout: "centered",
1414
msw: {
15-
handlers: [getSignInHandler()],
15+
handlers: [postSignInHandler()],
1616
},
1717
},
1818
} satisfies Meta<typeof SignInForm>;

src/features/carts/components/AddToCartButton/AddToCartButton.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "storybook-addon-remix-react-router";
1313

1414
import { generateUuid } from "@/test-lib/generate-uuid";
15-
import { getAddToCartHandler } from "@/test-lib/handlers/get-add-to-cart-handler";
15+
import { putAddToCartHandler } from "@/test-lib/handlers/put-add-to-cart-handler";
1616
import { sleep } from "@/test-lib/storybook/sleep";
1717

1818
import { AddToCartButton } from "./AddToCartButton";
@@ -35,7 +35,7 @@ const meta = {
3535
parameters: {
3636
layout: "centered",
3737
msw: {
38-
handlers: [getAddToCartHandler()],
38+
handlers: [putAddToCartHandler()],
3939
},
4040
reactRouter: reactRouterParameters({
4141
routing: { path: "/products" },

src/features/carts/components/ClearCartButton/ClearCartButton.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react-vite";
22
import { userEvent, within, screen, expect } from "storybook/test";
33

44
import { ClearCartButton } from "@/features/carts/components/ClearCartButton/ClearCartButton";
5-
import { getClearCartHandler } from "@/test-lib/handlers/get-clear-cart-handler";
5+
import { deleteClearCartHandler } from "@/test-lib/handlers/delete-clear-cart-handler";
66
import { sleep } from "@/test-lib/storybook/sleep";
77

88
const meta = {
@@ -11,7 +11,7 @@ const meta = {
1111
parameters: {
1212
layout: "centered",
1313
msw: {
14-
handlers: [getClearCartHandler()],
14+
handlers: [deleteClearCartHandler()],
1515
},
1616
},
1717
} satisfies Meta<typeof ClearCartButton>;

src/features/products/components/ProductCard.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react-vite";
22
import { withRouter } from "storybook-addon-remix-react-router";
33

44
import { ProductFixture } from "@/test-lib/fixtures/product-fixture";
5-
import { getAddToCartHandler } from "@/test-lib/handlers/get-add-to-cart-handler";
5+
import { putAddToCartHandler } from "@/test-lib/handlers/put-add-to-cart-handler";
66

77
import { ProductCard } from "./ProductCard";
88

@@ -13,7 +13,7 @@ const meta = {
1313
parameters: {
1414
layout: "centered",
1515
msw: {
16-
handlers: [getAddToCartHandler()],
16+
handlers: [putAddToCartHandler()],
1717
},
1818
},
1919
} satisfies Meta<typeof ProductCard>;

src/features/products/components/ProductDetails.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { action } from "storybook/actions";
44
import { withRouter } from "storybook-addon-remix-react-router";
55

66
import { ProductFixture } from "@/test-lib/fixtures/product-fixture";
7-
import { getAddToCartHandler } from "@/test-lib/handlers/get-add-to-cart-handler";
7+
import { putAddToCartHandler } from "@/test-lib/handlers/put-add-to-cart-handler";
88

99
import { ProductDetails } from "./ProductDetails";
1010

@@ -15,7 +15,7 @@ const meta = {
1515
parameters: {
1616
layout: "centered",
1717
msw: {
18-
handlers: [getAddToCartHandler()],
18+
handlers: [putAddToCartHandler()],
1919
},
2020
},
2121
} satisfies Meta<typeof ProductDetails>;

src/pages/Cart/Cart.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { withRouter } from "storybook-addon-remix-react-router";
55
import { CartFixture } from "@/test-lib/fixtures/cart-fixture";
66
import { USER_CART_ID } from "@/test-lib/fixtures/user-fixture";
77
import { generateUuid } from "@/test-lib/generate-uuid";
8+
import { deleteClearCartHandler } from "@/test-lib/handlers/delete-clear-cart-handler";
89
import { getCartHandler } from "@/test-lib/handlers/get-cart-handler";
9-
import { getClearCartHandler } from "@/test-lib/handlers/get-clear-cart-handler";
1010
import { getProductHandler } from "@/test-lib/handlers/get-product-handler";
1111

1212
import { cartPageLoader } from "./loader";
@@ -50,7 +50,7 @@ export const Default: Story = {
5050
);
5151
}),
5252
getProductHandler(),
53-
getClearCartHandler(),
53+
deleteClearCartHandler(),
5454
],
5555
},
5656
},

src/pages/Product/Product.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Meta, StoryObj } from "@storybook/react-vite";
22
import { withRouter } from "storybook-addon-remix-react-router";
33

4-
import { getAddToCartHandler } from "@/test-lib/handlers/get-add-to-cart-handler";
54
import { getProductHandler } from "@/test-lib/handlers/get-product-handler";
5+
import { putAddToCartHandler } from "@/test-lib/handlers/put-add-to-cart-handler";
66

77
import { productPageLoader } from "./loader";
88

@@ -22,7 +22,7 @@ const meta = {
2222
loader: productPageLoader,
2323
},
2424
msw: {
25-
handlers: [getAddToCartHandler(), getProductHandler()],
25+
handlers: [putAddToCartHandler(), getProductHandler()],
2626
},
2727
},
2828
decorators: [withRouter],

src/pages/Products/Products.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { Meta, StoryObj } from "@storybook/react-vite";
22
import { HttpResponse } from "msw";
33
import { withRouter } from "storybook-addon-remix-react-router";
44

5-
import { getAddToCartHandler } from "@/test-lib/handlers/get-add-to-cart-handler";
65
import { getProductsHandler } from "@/test-lib/handlers/get-products-handler";
6+
import { putAddToCartHandler } from "@/test-lib/handlers/put-add-to-cart-handler";
77

88
import { productsPageLoader } from "./loader";
99

@@ -27,7 +27,7 @@ type Story = StoryObj<typeof meta>;
2727
export const Default: Story = {
2828
parameters: {
2929
msw: {
30-
handlers: [getProductsHandler(), getAddToCartHandler()],
30+
handlers: [getProductsHandler(), putAddToCartHandler()],
3131
},
3232
},
3333
};

src/pages/SignIn/SignIn.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Meta, StoryObj } from "@storybook/react-vite";
22
import { withRouter } from "storybook-addon-remix-react-router";
33

4-
import { getSignInHandler } from "@/test-lib/handlers/sign-in-handler";
4+
import { postSignInHandler } from "@/test-lib/handlers/post-sign-in-handler";
55

66
import { SignInPage as Component } from "./index";
77

@@ -11,7 +11,7 @@ const meta = {
1111
parameters: {
1212
layout: "centered",
1313
msw: {
14-
handlers: [getSignInHandler()],
14+
handlers: [postSignInHandler()],
1515
},
1616
},
1717
decorators: [withRouter],

src/test-lib/handlers/get-clear-cart-handler.ts renamed to src/test-lib/handlers/delete-clear-cart-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { host } from "@/lib/http";
44

55
import type { DeleteResolver } from "./resolvers";
66

7-
export const getClearCartHandler = (resolver?: DeleteResolver) =>
7+
export const deleteClearCartHandler = (resolver?: DeleteResolver) =>
88
http.delete(`${host}/carts/:cartId`, (req) => {
99
if (resolver) return resolver(req);
1010

0 commit comments

Comments
 (0)