-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: FeedbackPhaseBanner component functionality and accessibility #2815
Conversation
Removed vultr server and associated DNS entries |
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.
One small change required!
@@ -0,0 +1,67 @@ | |||
import "@testing-library/jest-dom/extend-expect"; | |||
|
|||
import { fireEvent } from "@testing-library/react"; |
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.
This isn't something we're currently enforcing (maybe we should?) but fireEvent
is rarely needed and we can rely on user
for an experience which is closer to the real DOM.
Instead of importing this we can can use the user
returned from setup()
like so -
test("clicking on feedback link calls handleFeedbackClick", async () => {
const { getByText, user } = setup(
<FeedbackPhaseBanner
handleFeedbackClick={handleFeedbackClick}
handleReportAnIssueClick={handleReportAnIssueClick}
/>,
);
await user.click(getByText("feedback"));
expect(handleFeedbackClick).toHaveBeenCalledTimes(1);
});
The notable change here is that this is now an async
function - I think the test will just fail without the await
before user.click()
.
Docs: https://testing-library.com/docs/dom-testing-library/api-events/
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.
Fixed here: 2035632
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.
Thanks for the quick fixes here! ✅
What
Why