-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Menu] Use strict mode compatible testing API #16582
Conversation
e8d753c
to
7a796f7
Compare
No bundle size changes comparing b3218e7...aa2ac87 |
}); | ||
|
||
// no case for variant=menu | ||
it('[variant=selectedMenu] nothing selected, first index invalid', () => { |
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 test has the same outcome as [variant=selectedMenu] nothing selected
. Should [variant=selectedMenu] nothing selected
focus the first item and this test shouldn't?
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 test has the same outcome as [variant=selectedMenu] nothing selected
The content anchor is different for this test.
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.
Could you explain what you mean by different? I can't spot a difference visually between menu
and selectedMenu
for pre-selected items, no selected items or null
-items:
https://github.com/mui-org/material-ui/blob/275a966d6ed7a479904e5c544978220e3e8d9711/test/regressions/tests/Menu/MenuContentAnchors.js
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.
selectedMenu
is the default, so to see the variant-specific differences, you need to specify variant="menu"
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.
7a796f7
to
f6d0ab9
Compare
Updated descriptions to describe the test case not repeat what is tested. If you write Applied the following diff: - it [variant=menu] nothing selected
+ specify [variant=menu] will focus the menu if nothing is selected
- it [variant=selectedMenu] nothing selected
+ specify [variant=selectedMenu] will focus the menu if nothing is selected
- it [variant=menu] nothing selected, autoFocus on third
+ specify [variant=menu] ignores `autoFocus` on `MenuItem`
- it [variant=menu] second item selected
+ specify [variant=menu] ignores `selected` on `MenuItem`
- it [variant=selectedMenu] second item selected
+ specify [variant=selectedMenu] focuses the `selected` `MenuItem`
- it [variant=selectedMenu] second item selected, explicit tabIndex
+ specify [variant=selectedMenu] allows overriding `tabIndex` on `MenuItem`
- it [variant=selectedMenu] second item selected and disabled
+ specify [variant=selectedMenu] focuses the menu if the selected menuitem is disabled
- it [variant=selectedMenu] second item selected, no autoFocus
+ specify [variant=selectedMenu] focuses no part of the menu when `autoFocus={false}` @ryancogswell I'm still missing some context about Do we even need this variant switch? Currently we allow The vertical alignment should probably be a single prop? I'd even consider removing that behavior completely in v5. |
756eb86
to
d067f2f
Compare
Yes, sorry about this bad description. Initially I had three values for variant, because I thought I needed slightly different behavior for
Its value is pretty minimal and based on use cases invented in my head rather than asked for by users. I was also planning to eventually add more values for the My intent with the |
@testing-library/react
makes these test so much more readable. Got rid of the focus trackers. IMO this is more of a bug that should be fixed but it's probably best the wait for Flare instead of implementing this ourselves.Moved the fixture into the test. This was likely a remnant of the "one component per file" paradigm. But we want to see what we're testing so let's move them into the test.
Reduces as much indirection in tests as possible (isolate each case, prefer wet tests).
Reordered tests so that tests that only differ in variant are next to each other.
/cc @ryancogswell