-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31fc7ff
commit 5a76c2f
Showing
15 changed files
with
224 additions
and
38 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
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
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
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
25 changes: 25 additions & 0 deletions
25
polaris-react/src/components/Picker/components/Activator/tests/Activator.test.tsx
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,25 @@ | ||
import React from 'react'; | ||
import {mountWithApp} from 'tests/utilities'; | ||
|
||
import {Activator} from '../Activator'; | ||
import {UnstyledButton} from '../../../../UnstyledButton'; | ||
|
||
describe('<Activator />', () => { | ||
it('renders a label', () => { | ||
const activator = mountWithApp(<Activator label="label" />); | ||
|
||
expect(activator).toContainReactText('label'); | ||
}); | ||
|
||
it('renders a placeholder', () => { | ||
const activator = mountWithApp(<Activator placeholder="placeholder" />); | ||
|
||
expect(activator).toContainReactText('placeholder'); | ||
}); | ||
|
||
it('renders a disabled activator', () => { | ||
const activator = mountWithApp(<Activator disabled />); | ||
|
||
expect(activator).toContainReactComponent(UnstyledButton, {disabled: true}); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...components/TextField/TextField.module.css → ...onents/SearchField/SearchField.module.css
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.TextField { | ||
.SearchField { | ||
flex-grow: 1; | ||
padding: var(--p-space-100) 0; | ||
outline: none; | ||
|
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
1 change: 1 addition & 0 deletions
1
polaris-react/src/components/Picker/components/SearchField/index.ts
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 @@ | ||
export {SearchField} from './SearchField'; |
73 changes: 73 additions & 0 deletions
73
polaris-react/src/components/Picker/components/SearchField/tests/SearchField.test.tsx
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,73 @@ | ||
import React from 'react'; | ||
import {mountWithApp} from 'tests/utilities'; | ||
|
||
import {SearchField} from '../SearchField'; | ||
import {Label} from '../../../../Label'; | ||
import type {ComboboxTextFieldType} from '../../../../../utilities/combobox'; | ||
import {ComboboxTextFieldContext} from '../../../../../utilities/combobox'; | ||
import type {TextFieldProps} from '../../../../TextField'; | ||
|
||
function mountWithProvider( | ||
props: { | ||
textFieldProps?: Partial<TextFieldProps>; | ||
textFieldProviderValue?: Partial<ComboboxTextFieldType>; | ||
} = {}, | ||
) { | ||
const textField = mountWithApp( | ||
<ComboboxTextFieldContext.Provider | ||
value={{...props.textFieldProviderValue}} | ||
> | ||
<SearchField | ||
label="label" | ||
onChange={noop} | ||
autoComplete="off" | ||
{...props.textFieldProps} | ||
/> | ||
</ComboboxTextFieldContext.Provider>, | ||
); | ||
|
||
return textField; | ||
} | ||
|
||
describe('<TextField />', () => { | ||
it('renders a label', () => { | ||
const picker = mountWithProvider({ | ||
textFieldProps: { | ||
label: 'Field', | ||
}, | ||
}); | ||
|
||
expect(picker).toContainReactComponent(Label, {children: 'Field'}); | ||
}); | ||
|
||
it('renders a prefix', () => { | ||
const picker = mountWithProvider({ | ||
textFieldProps: { | ||
prefix: <div>Prefix</div>, | ||
}, | ||
}); | ||
|
||
expect(picker).toContainReactComponent('div', {children: 'Prefix'}); | ||
}); | ||
|
||
it('renders accessibility attributes', () => { | ||
const picker = mountWithProvider({ | ||
textFieldProviderValue: { | ||
activeOptionId: 'option1', | ||
listboxId: 'listbox1', | ||
setTextFieldLabelId: () => 'TextFieldLabel', | ||
}, | ||
}); | ||
|
||
expect(picker).toContainReactComponent('input', { | ||
role: 'combobox', | ||
'aria-activedescendant': 'option1', | ||
'aria-haspopup': 'listbox', | ||
'aria-autocomplete': 'list', | ||
'aria-expanded': 'true', | ||
'aria-controls': 'listbox1', | ||
}); | ||
}); | ||
}); | ||
|
||
function noop() {} |
1 change: 0 additions & 1 deletion
1
polaris-react/src/components/Picker/components/TextField/index.ts
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export {TextField} from './TextField'; | ||
export {SearchField} from './SearchField'; | ||
export * from './Activator'; |
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from './Picker'; | ||
export {TextField as PickerTextField} from './components'; |
Oops, something went wrong.