-
Notifications
You must be signed in to change notification settings - Fork 27
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 #101 from appsmithorg/release
feat: Button component
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@appsmithorg/design-system": patch | ||
--- | ||
|
||
feat: Added button test |
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,46 @@ | ||
import React from "react"; | ||
import "@testing-library/jest-dom"; | ||
import { render, screen } from "@testing-library/react"; | ||
import Button, { Size } from "./index"; | ||
import { create } from "react-test-renderer"; | ||
|
||
describe("<Button /> component - render", () => { | ||
it("renders the button component with text passed as input", () => { | ||
render(<Button size={Size.medium} tag="button" text="Run" />); | ||
expect(screen.getByRole("button")).toHaveTextContent("Run"); | ||
}); | ||
}); | ||
|
||
describe("<Button /> component - loading behaviour", () => { | ||
it("calls the onclick handler when not in loading state", () => { | ||
const fn = jest.fn(); | ||
const tree = create( | ||
<Button | ||
isLoading={false} | ||
onClick={fn} | ||
size={Size.medium} | ||
tag="button" | ||
text="Run" | ||
/>, | ||
); | ||
const button = tree.root.findByType("button"); | ||
button.props.onClick(); | ||
expect(fn.mock.calls.length).toBe(1); | ||
}); | ||
|
||
it("does not call the onclick handler when in loading state", () => { | ||
const fn = jest.fn(); | ||
const tree = create( | ||
<Button | ||
isLoading | ||
onClick={fn} | ||
size={Size.medium} | ||
tag="button" | ||
text="Run" | ||
/>, | ||
); | ||
const button = tree.root.findByType("button"); | ||
button.props.onClick(); | ||
expect(fn.mock.calls.length).toBe(0); | ||
}); | ||
}); |
96ee6b2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
design-system – ./
design-system-olive.vercel.app
design-system-git-main-get-appsmith.vercel.app
design-system-get-appsmith.vercel.app