-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(infoBox): add separator toggle and tests (#844)
* feat(infoBox): add separator toggle and tests Co-authored-by: Eli Flores <eli.flores@digitalservice.bund.de> * feat(infoBox): let zod set default value Co-authored-by: Eli Flores <eli.flores@digitalservice.bund.de> * feat(infoBox): use screen instead of querySelector Co-authored-by: Eli Flores <eli.flores@digitalservice.bund.de> --------- Co-authored-by: Eli Flores <eli.flores@digitalservice.bund.de>
- Loading branch information
1 parent
39f642e
commit c9d4ed3
Showing
6 changed files
with
79 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import InfoBox, { InfoBoxPropsSchema } from "~/components/InfoBox"; | ||
|
||
const mockInfoBoxItems = [ | ||
{ | ||
label: undefined, | ||
headline: undefined, | ||
image: undefined, | ||
content: "Lorem1", | ||
buttons: [], | ||
}, | ||
{ | ||
label: undefined, | ||
headline: undefined, | ||
image: undefined, | ||
content: "Lorem2", | ||
buttons: [], | ||
}, | ||
]; | ||
|
||
describe("InfoBox", () => { | ||
it("has expected padding when the separator is enabled", () => { | ||
render(<InfoBox separator={true} items={mockInfoBoxItems} />); | ||
expect(screen.getByRole("list")).toHaveClass("ds-stack-32"); | ||
}); | ||
it("has expected padding when the separator is disabled", () => { | ||
render(<InfoBox separator={false} items={mockInfoBoxItems} />); | ||
expect(screen.getByRole("list")).toHaveClass("ds-stack-48"); | ||
}); | ||
it("has expected padding when the separator is unset", () => { | ||
const infoBoxProps = InfoBoxPropsSchema.parse({ | ||
items: mockInfoBoxItems, | ||
}); | ||
|
||
render(<InfoBox {...infoBoxProps} />); | ||
expect(screen.getByRole("list")).toHaveClass("ds-stack-32"); | ||
}); | ||
}); |
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,18 @@ | ||
import { render } from "@testing-library/react"; | ||
import InfoBoxItem from "~/components/InfoBoxItem"; | ||
|
||
const separatorStyleClass = | ||
".pt-32.border-0.border-solid.border-0.border-t-2.border-gray-400.first\\:border-none"; | ||
|
||
describe("InfoBoxItem", () => { | ||
it("has expected class properties when the separator is enabled", () => { | ||
const { container } = render(<InfoBoxItem separator={true} />); | ||
expect(container.querySelector(separatorStyleClass)).toBeInTheDocument(); | ||
}); | ||
it("has expected class properties when the separator is disabled", () => { | ||
const { container } = render(<InfoBoxItem separator={false} />); | ||
expect( | ||
container.querySelector(separatorStyleClass), | ||
).not.toBeInTheDocument(); | ||
}); | ||
}); |
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