-
Notifications
You must be signed in to change notification settings - Fork 86
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
Option comps rtl #7014
Option comps rtl #7014
Conversation
const mockedGuid = "guid-12345"; | ||
jest.mock("../../../__internal__/utils/helpers/guid"); | ||
(guid as jest.MockedFunction<typeof guid>).mockImplementation(() => mockedGuid); |
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.
question: it doesn't appear we are asserting the id set on an underlying element in any of the tests. Is this mock required for something else?
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 one can be removed, I'm actually going to keep it in the other ones as we should be testing when the user set a custom id or not etc
expect(option).not.toHaveAttribute("aria-disabled"); | ||
}); | ||
|
||
it("should call `onSelect` or `onClick` when the user clicks on the element", async () => { |
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.
suggestion(non-blocking): what do you think of this so it reflects calling both event handlers?
it("should call `onSelect` or `onClick` when the user clicks on the element", async () => { | |
it("should call `onSelect` and `onClick` when the user clicks on the element", async () => { |
592a521
to
ef7e9d2
Compare
fed4db4
to
c5e43d8
Compare
expect(screen.queryByRole("option", { name: "bar" })).not.toBeInTheDocument(); | ||
}); | ||
|
||
test("should set guid as `id` on the elment when none passed", () => { |
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.
typo:
test("should set guid as `id` on the elment when none passed", () => { | |
test("should set guid as `id` on the element when none passed", () => { |
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should call `onSelect` when the user clicks on the element and `onClick` is not set but custom `id` passed", async () => { |
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.
suggestion(non-blocking): what do you think of this wording tweak for clarity?
it("should call `onSelect` when the user clicks on the element and `onClick` is not set but custom `id` passed", async () => { | |
it("calls `onSelect` when clicked and neither `onClick` nor `id` are set", async () => { |
}); | ||
}); | ||
|
||
it("should call `onSelect` when the user clicks on the element and `onClick` is not set but custom `id` is passed", async () => { |
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.
suggestion(non-blocking): similarly, what do you think about this tweak for clarity?:
it("should call `onSelect` when the user clicks on the element and `onClick` is not set but custom `id` is passed", async () => { | |
it("calls `onSelect` when clicked, without `onClick` set, but with `id` provided.", async () => { |
c5e43d8
to
77fcc4e
Compare
🎉 This PR is included in version 143.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Proposed behaviour
Converts Option, OptionGroupHeader and OptionRow unit tests to RTL
Current behaviour
Option, OptionGroupHeader and OptionRow unit tests are enzyme
Checklist
d.ts
file added or updated if requiredQA
Additional context
Testing instructions