✨(react) add icon to Button
The DS does not offer an icons set yet but it seems important to already provide a support for external icons in Button.
This commit is contained in:
@@ -12,6 +12,24 @@ describe("<Button/>", () => {
|
||||
expect(button.classList.contains("c__button")).toBe(true);
|
||||
});
|
||||
|
||||
it("renders with custom class when using left icon", () => {
|
||||
render(<Button icon={<div>Icon</div>}>Test button</Button>);
|
||||
const button = screen.getByText("Test button");
|
||||
expect(button.classList.contains("c__button")).toBe(true);
|
||||
expect(button.classList.contains("c__button--with-icon--left")).toBe(true);
|
||||
});
|
||||
|
||||
it("renders with custom class when using right icon", () => {
|
||||
render(
|
||||
<Button icon={<div>Icon</div>} iconPosition="right">
|
||||
Test button
|
||||
</Button>
|
||||
);
|
||||
const button = screen.getByText("Test button");
|
||||
expect(button.classList.contains("c__button")).toBe(true);
|
||||
expect(button.classList.contains("c__button--with-icon--right")).toBe(true);
|
||||
});
|
||||
|
||||
it("call onClick when click occurs", async () => {
|
||||
const user = userEvent.setup();
|
||||
const handleClick = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user