Skip to content

Commit

Permalink
SWED-2379 update Jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goldenraphti committed Feb 12, 2024
1 parent 225ba51 commit 3cf8957
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ exports[`Component: InputGroup - renders a form-group with a prefix icon if prop
<i
aria-hidden="true"
className="home"
className="at-home"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/App/components/InputGroup/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe("Component: InputGroup -", () => {
expect(icon).toHaveTextContent("");

const componentForSnap = renderer.create(
<InputGroup type="typetest" addOnType="icon" prefixValue="home" />,
<InputGroup type="typetest" addOnType="icon" prefixValue="at-home" />,
);

expect(componentForSnap.toJSON()).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ exports[`Component: MediaObject - renders a muted MediaObject 1`] = `
<i
aria-hidden="true"
className="home text-muted"
className="at-home text-muted"
/>
Expand Down Expand Up @@ -148,7 +148,7 @@ exports[`Component: MediaObject - renders an icon 1`] = `
<i
aria-hidden="true"
className="home "
className="at-home "
/>
Expand Down
32 changes: 16 additions & 16 deletions src/App/components/MediaObject/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ describe("Component: MediaObject -", () => {
render(<MediaObject heading="render-test" />);

const componentForSnap = renderer.create(
<MediaObject heading="render-test" />
<MediaObject heading="render-test" />,
);

expect(componentForSnap.toJSON()).toMatchSnapshot();
});

it("renders an icon", () => {
const { container } = render(
<MediaObject heading="render-test" icon="home" />
<MediaObject heading="render-test" icon="at-home" />,
);

expect(container.querySelectorAll("i")).toHaveLength(1);

const componentForSnap = renderer.create(
<MediaObject heading="render-test" icon="home" />
<MediaObject heading="render-test" icon="at-home" />,
);

expect(componentForSnap.toJSON()).toMatchSnapshot();
Expand All @@ -49,7 +49,7 @@ describe("Component: MediaObject -", () => {
<MediaObject
heading="render-test"
imgUrl="https://via.placeholder.com/48x48"
/>
/>,
);

expect(screen.getByRole("img")).toBeInTheDocument();
Expand All @@ -58,7 +58,7 @@ describe("Component: MediaObject -", () => {
<MediaObject
heading="render-test"
imgUrl="https://via.placeholder.com/48x48"
/>
/>,
);

expect(componentForSnap.toJSON()).toMatchSnapshot();
Expand All @@ -70,42 +70,42 @@ describe("Component: MediaObject -", () => {
heading="render-test"
imgUrl="https://via.placeholder.com/48x48"
mediaRight
/>
/>,
);

expect(screen.getByRole("img").parentElement.parentElement).toHaveClass(
"media-right"
"media-right",
);

const componentForSnap = renderer.create(
<MediaObject
heading="render-test"
imgUrl="https://via.placeholder.com/48x48"
mediaRight
/>
/>,
);

expect(componentForSnap.toJSON()).toMatchSnapshot();
});

it("renders a <small> text", () => {
const { container } = render(
<MediaObject heading="render-test" textSmall text="small text" />
<MediaObject heading="render-test" textSmall text="small text" />,
);

expect(container.querySelectorAll("small")).toHaveLength(1);
expect(container.querySelector("small")).toHaveTextContent("small text");

const componentForSnap = renderer.create(
<MediaObject heading="render-test" textSmall text="small text" />
<MediaObject heading="render-test" textSmall text="small text" />,
);

expect(componentForSnap.toJSON()).toMatchSnapshot();
});

it("renders a muted MediaObject", () => {
const { container } = render(
<MediaObject heading="render-test" icon="home" muted />
<MediaObject heading="render-test" icon="at-home" muted />,
);

const mediaHeader = screen.getByRole("heading");
Expand All @@ -115,37 +115,37 @@ describe("Component: MediaObject -", () => {
expect(container.querySelector("i")).toHaveClass("text-muted");

const componentForSnap = renderer.create(
<MediaObject heading="render-test" icon="home" muted />
<MediaObject heading="render-test" icon="at-home" muted />,
);

expect(componentForSnap.toJSON()).toMatchSnapshot();
});

it("renders MediaObject with class media-sm", () => {
const { container } = render(
<MediaObject heading="render-test" size="sm" />
<MediaObject heading="render-test" size="sm" />,
);

expect(screen.getByRole("heading").tagName).toBe("H4");
expect(container.querySelector("div")).toHaveClass("media-sm");

const componentForSnap = renderer.create(
<MediaObject heading="render-test" size="sm" />
<MediaObject heading="render-test" size="sm" />,
);

expect(componentForSnap.toJSON()).toMatchSnapshot();
});

it("renders MediaObject with class media-lg", () => {
const { container } = render(
<MediaObject heading="render-test" size="lg" />
<MediaObject heading="render-test" size="lg" />,
);

expect(screen.getByRole("heading").tagName).toBe("H2");
expect(container.querySelector("div")).toHaveClass("media-lg");

const componentForSnap = renderer.create(
<MediaObject heading="render-test" size="lg" />
<MediaObject heading="render-test" size="lg" />,
);

expect(componentForSnap.toJSON()).toMatchSnapshot();
Expand Down
Loading

0 comments on commit 3cf8957

Please sign in to comment.