-
Notifications
You must be signed in to change notification settings - Fork 647
chore: add className testing util #7231
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
base: main
Are you sure you want to change the base?
Changes from all commits
269434b
7972d0e
4034aca
cae2022
a61c41c
62aae49
69f163c
bc6b386
82c72dd
bfe79ca
ac283d1
b7b7b79
64e7843
782ea21
9fa44a1
42223c3
67216ae
ce10e92
1ef18dc
3b197b5
115e1d5
598e866
456b839
afaf244
ea20e33
a04d375
f8b8fe6
7f1dc19
fed64bd
d86cc26
1a1e752
86cdc16
cd19193
e328fb9
6bde988
c890576
b71e08a
6538b81
7e84707
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ import type {AutocompleteInputProps} from '../Autocomplete' | |
| import Autocomplete from '../Autocomplete' | ||
| import type {AutocompleteMenuInternalProps, AutocompleteMenuItem} from '../Autocomplete/AutocompleteMenu' | ||
| import BaseStyles from '../BaseStyles' | ||
| import {implementsClassName} from '../utils/testing' | ||
| import classes from './AutocompleteOverlay.module.css' | ||
|
|
||
| const mockItems = [ | ||
| {text: 'zero', id: '0'}, | ||
|
|
@@ -47,6 +49,11 @@ const LabelledAutocomplete = <T extends AutocompleteMenuItem>({ | |
|
|
||
| describe('Autocomplete', () => { | ||
| describe('Autocomplete.Input', () => { | ||
| implementsClassName(props => ( | ||
| <Autocomplete> | ||
| <Autocomplete.Input {...props} /> | ||
| </Autocomplete> | ||
| )) | ||
| it('calls onChange', async () => { | ||
| const user = userEvent.setup() | ||
| const onChangeMock = vi.fn() | ||
|
|
@@ -214,15 +221,6 @@ describe('Autocomplete', () => { | |
|
|
||
| expect(getByDisplayValue('0')).toBeDefined() | ||
| }) | ||
|
|
||
| it('should support `className` on the outermost element', () => { | ||
| const Element = () => ( | ||
| <Autocomplete> | ||
| <Autocomplete.Input className={'test-class-name'} /> | ||
| </Autocomplete> | ||
| ) | ||
| expect(render(<Element />).container.firstChild).toHaveClass('test-class-name') | ||
| }) | ||
| }) | ||
|
|
||
| describe('Autocomplete.Menu', () => { | ||
|
|
@@ -444,23 +442,19 @@ describe('Autocomplete', () => { | |
| }) | ||
| }) | ||
|
|
||
| describe('Autocomplete.Overlay', () => { | ||
| it('should support `className` on the outermost element', async () => { | ||
| const Element = ({className}: {className: string}) => ( | ||
| // TODO: Enable once className override bug is fixed in Autocomplete.Overlay, also remember to remove from ignore list on script/check-classname-tests.mjs | ||
| describe.skip('Autocomplete.Overlay', () => { | ||
|
Comment on lines
+445
to
+446
|
||
| implementsClassName( | ||
| props => ( | ||
| <Autocomplete id="autocompleteId"> | ||
| <Autocomplete.Input /> | ||
| <Autocomplete.Overlay className={className} visibility="visible"> | ||
| <Autocomplete.Overlay {...props} visibility="visible"> | ||
| hi | ||
| </Autocomplete.Overlay> | ||
| </Autocomplete> | ||
| ) | ||
| const {container: elementContainer, getByRole} = render(<Element className="test-class-name" />) | ||
| const inputNode = getByRole('combobox') | ||
| await userEvent.click(inputNode) | ||
| await userEvent.keyboard('{ArrowDown}') | ||
| // overlay is a sibling of elementContainer | ||
| expect(elementContainer.parentElement?.querySelectorAll('.test-class-name')).toHaveLength(1) | ||
| }) | ||
| ), | ||
| classes.Overlay, | ||
| ) | ||
| }) | ||
|
|
||
| describe('null context', () => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.