Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Fix CartRow tests #749

Merged
merged 2 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Add Cypress tags to all of the buttons (also speed up tests) - #718 by @krzysztofwolski
- Automatically choose variant attributes from url in ProductVariantPicker - #708 by @AlicjaSzu
- Use sdk as a standalone package - #724 by @dominik-zeglen
- Fix CartRow tests - #749 by @dominik-zeglen

## 2.10.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,23 +374,33 @@ exports[`Storyshots @components/organisms/CartRow default 1`] = `
<div
className="c2"
>
<img
alt="product image"
data-cy="cartPageItemundefinedImage"
onError={[Function]}
src="test-file-stub"
srcSet="test-file-stub 1x"
/>
<a
href="/product/the-great-square-table/3/"
onClick={[Function]}
>
<img
alt="product image"
data-cy="cartPageItemundefinedImage"
onError={[Function]}
src="test-file-stub"
srcSet="test-file-stub 1x"
/>
</a>
</div>
<div
className="c3"
>
<p
className="c4"
data-cy="cartPageItemundefinedName"
<a
href="/product/the-great-square-table/3/"
onClick={[Function]}
>
The Great Square Table
</p>
<p
className="c4"
data-cy="cartPageItemundefinedName"
>
The Great Square Table
</p>
</a>
<p
className="c5"
>
Expand Down
2 changes: 1 addition & 1 deletion src/@next/components/organisms/CartRow/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const DEFAULT_PROPS = {
],
},
],
id: "2",
id: "UHJvZHVjdDoz",
maxQuantity: 5,
name: "The Great Square Table",
quantity: 3,
Expand Down
7 changes: 6 additions & 1 deletion src/@next/components/organisms/CartRow/stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { action } from "@storybook/addon-actions";
import { storiesOf } from "@storybook/react";
import React from "react";
import { MemoryRouter } from "react-router";

import { CartRow } from ".";
import { DEFAULT_PROPS } from "./fixtures";
Expand All @@ -13,4 +14,8 @@ const STORY_PROPS = {

storiesOf("@components/organisms/CartRow", module)
.addParameters({ component: CartRow })
.add("default", () => <CartRow {...STORY_PROPS} />);
.add("default", () => (
<MemoryRouter>
<CartRow {...STORY_PROPS} />
</MemoryRouter>
));
41 changes: 24 additions & 17 deletions src/@next/components/organisms/CartRow/test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mount, shallow } from "enzyme";
import "jest-styled-components";
import React from "react";
import { MemoryRouter } from "react-router";

import { Icon, IconButton } from "@components/atoms";

Expand Down Expand Up @@ -45,11 +46,13 @@ describe("<CartRow />", () => {
const onRemoveMock = jest.fn();
const onQuantityChangeMock = jest.fn();
const wrapper = mount(
<CartRow
{...DEFAULT_PROPS}
onRemove={onRemoveMock}
onQuantityChange={onQuantityChangeMock}
/>
<MemoryRouter>
<CartRow
{...DEFAULT_PROPS}
onRemove={onRemoveMock}
onQuantityChange={onQuantityChangeMock}
/>
</MemoryRouter>
);

wrapper
Expand All @@ -66,11 +69,13 @@ describe("<CartRow />", () => {
const onRemoveMock = jest.fn();
const onQuantityChangeMock = jest.fn();
const wrapper = mount(
<CartRow
{...DEFAULT_PROPS}
onRemove={onRemoveMock}
onQuantityChange={onQuantityChangeMock}
/>
<MemoryRouter>
<CartRow
{...DEFAULT_PROPS}
onRemove={onRemoveMock}
onQuantityChange={onQuantityChangeMock}
/>
</MemoryRouter>
);

wrapper
Expand All @@ -87,13 +92,15 @@ describe("<CartRow />", () => {
const onRemoveMock = jest.fn();
const onQuantityChangeMock = jest.fn();
const wrapper = mount(
<CartRow
{...DEFAULT_PROPS}
maxQuantity={3}
quantity={3}
onRemove={onRemoveMock}
onQuantityChange={onQuantityChangeMock}
/>
<MemoryRouter>
<CartRow
{...DEFAULT_PROPS}
maxQuantity={3}
quantity={3}
onRemove={onRemoveMock}
onQuantityChange={onQuantityChangeMock}
/>
</MemoryRouter>
);

wrapper
Expand Down