-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #415 from Automattic/forno-1690/add/toggle-group
FORNO-1690: Add toggle-group component
- Loading branch information
Showing
4 changed files
with
199 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { render, screen } from '@testing-library/react'; | ||
import { axe } from 'jest-axe'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { RadioBoxGroup } from './RadioBoxGroup'; | ||
|
||
const defaultProps = { | ||
options: [ | ||
{ | ||
label: 'One', | ||
value: 'one', | ||
description: 'This is desc 1', | ||
}, | ||
{ | ||
label: 'Two', | ||
value: 'two', | ||
description: 'This is desc 2', | ||
}, | ||
{ | ||
label: 'Three', | ||
value: 'three', | ||
description: 'This is desc 3', | ||
}, | ||
], | ||
onChange: jest.fn(), | ||
}; | ||
|
||
describe( '<RadioBoxGroup />', () => { | ||
it.each( [ 'primary', 'chip' ] )( 'renders the default variant', async variant => { | ||
const { container } = render( <RadioBoxGroup { ...defaultProps } variant={ variant } /> ); | ||
|
||
const dom = await screen.findAllByRole( 'radio' ); | ||
|
||
expect( dom ).toHaveLength( 3 ); | ||
expect( dom[ 0 ] ).toHaveAttribute( 'value', 'one' ); | ||
expect( dom[ 1 ] ).toHaveAttribute( 'value', 'two' ); | ||
expect( dom[ 2 ] ).toHaveAttribute( 'value', 'three' ); | ||
|
||
// Check for accessibility issues | ||
expect( await axe( container ) ).toHaveNoViolations(); | ||
} ); | ||
} ); |
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