-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6979 from Sage/FE-6804-detail-rtl
refactor(detail): convert enzyme tests to RTL
- Loading branch information
Showing
10 changed files
with
68 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { elementsTagTest, rootTagTest } from "./tags-specs"; | ||
export { default } from "./tags-specs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from "react"; | ||
import { render, screen, within } from "@testing-library/react"; | ||
import Detail from "."; | ||
import { testStyledSystemMargin } from "../../__spec_helper__/__internal__/test-utils"; | ||
|
||
test("renders children", () => { | ||
render(<Detail>foo</Detail>); | ||
|
||
expect(screen.getByText("foo")).toBeVisible(); | ||
}); | ||
|
||
test("renders with provided `footnote`", () => { | ||
render(<Detail footnote="extra info">foo</Detail>); | ||
|
||
const footnoteText = within(screen.getByTestId("footnote")).getByText( | ||
"extra info" | ||
); | ||
|
||
expect(footnoteText).toBeVisible(); | ||
}); | ||
|
||
test("renders with provided `icon`", () => { | ||
render(<Detail icon="bin">foo</Detail>); | ||
|
||
const icon = screen.getByTestId("icon"); | ||
|
||
expect(icon).toBeVisible(); | ||
expect(icon).toHaveAttribute("type", "bin"); | ||
}); | ||
|
||
test("renders with provided data- tags", () => { | ||
render( | ||
<Detail data-element="bar" data-role="baz"> | ||
foo | ||
</Detail> | ||
); | ||
|
||
expect(screen.getByTestId("baz")).toHaveAttribute("data-element", "bar"); | ||
}); | ||
|
||
// coverage | ||
test("renders with expected styles when `icon` and `footnote` are passed", () => { | ||
render( | ||
<Detail icon="bin" footnote="extra info"> | ||
foo | ||
</Detail> | ||
); | ||
|
||
const footnote = screen.getByTestId("footnote"); | ||
|
||
expect(footnote).toHaveStyle("margin-left: 26px"); | ||
}); | ||
|
||
testStyledSystemMargin((props) => <Detail {...props}>foo</Detail>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters