-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(radio): discovery-153 pf4 radio (#153)
* addSourceWizardStepOne, radio update * radio, pf4 radio wrapper * styling, temporary adjustment
- Loading branch information
Showing
7 changed files
with
388 additions
and
70 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
113 changes: 113 additions & 0 deletions
113
src/components/form/__tests__/__snapshots__/radio.test.js.snap
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,113 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Radio Component should handle children as a label: children label radio 1`] = ` | ||
<div | ||
class="pf-c-radio quipucords-form__radio " | ||
> | ||
<input | ||
aria-invalid="false" | ||
class="pf-c-radio__input" | ||
data-ouia-component-id="OUIA-Generated-Radio-5" | ||
data-ouia-component-type="PF4/Radio" | ||
data-ouia-safe="true" | ||
id="generatedid-" | ||
name="generatedid-" | ||
type="radio" | ||
value="" | ||
/> | ||
<label | ||
class="pf-c-radio__label" | ||
for="generatedid-" | ||
> | ||
lorem ipsum | ||
</label> | ||
</div> | ||
`; | ||
|
||
exports[`Radio Component should handle disabled, checked: active 1`] = ` | ||
<div | ||
class="pf-c-radio pf-m-standalone quipucords-form__radio " | ||
> | ||
<input | ||
aria-invalid="false" | ||
aria-label="radio input" | ||
class="pf-c-radio__input" | ||
data-ouia-component-id="OUIA-Generated-Radio-3" | ||
data-ouia-component-type="PF4/Radio" | ||
data-ouia-safe="true" | ||
id="generatedid-" | ||
name="generatedid-" | ||
type="radio" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Radio Component should handle disabled, checked: checked 1`] = ` | ||
<div | ||
class="pf-c-radio pf-m-standalone quipucords-form__radio " | ||
> | ||
<input | ||
aria-invalid="false" | ||
aria-label="radio input" | ||
checked="" | ||
class="pf-c-radio__input" | ||
data-ouia-component-id="OUIA-Generated-Radio-4" | ||
data-ouia-component-type="PF4/Radio" | ||
data-ouia-safe="true" | ||
id="generatedid-" | ||
name="generatedid-" | ||
type="radio" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Radio Component should handle disabled, checked: disabled 1`] = ` | ||
<div | ||
class="pf-c-radio pf-m-standalone quipucords-form__radio " | ||
> | ||
<input | ||
aria-invalid="false" | ||
aria-label="radio input" | ||
class="pf-c-radio__input" | ||
data-ouia-component-id="OUIA-Generated-Radio-2" | ||
data-ouia-component-type="PF4/Radio" | ||
data-ouia-safe="true" | ||
disabled="" | ||
id="generatedid-" | ||
name="generatedid-" | ||
type="radio" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Radio Component should render a basic component: basic component 1`] = ` | ||
<div | ||
class="pf-c-radio pf-m-standalone quipucords-form__radio " | ||
> | ||
<input | ||
aria-invalid="false" | ||
aria-label="radio input" | ||
class="pf-c-radio__input" | ||
data-ouia-component-id="OUIA-Generated-Radio-1" | ||
data-ouia-component-type="PF4/Radio" | ||
data-ouia-safe="true" | ||
id="generatedid-" | ||
name="generatedid-" | ||
type="radio" | ||
value="" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Radio Component should return an emulated onChange event: emulated event 1`] = ` | ||
Object { | ||
"checked": true, | ||
"currentTarget": Object {}, | ||
"id": "generatedid-", | ||
"keyCode": undefined, | ||
"name": "generatedid-", | ||
"persist": [Function], | ||
"target": Object {}, | ||
"value": undefined, | ||
} | ||
`; |
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,54 @@ | ||
import React from 'react'; | ||
import { mount, shallow } from 'enzyme'; | ||
import { Radio as PfRadio } from '@patternfly/react-core/dist/js/components/Radio'; | ||
import { Radio } from '../radio'; | ||
import { helpers } from '../../../common'; | ||
|
||
describe('Radio Component', () => { | ||
it('should render a basic component', () => { | ||
const props = {}; | ||
|
||
const component = mount(<Radio {...props} />); | ||
expect(component.render()).toMatchSnapshot('basic component'); | ||
}); | ||
|
||
it('should handle disabled, checked', () => { | ||
const props = { | ||
isDisabled: true | ||
}; | ||
|
||
const component = shallow(<Radio {...props} />); | ||
expect(component.render()).toMatchSnapshot('disabled'); | ||
|
||
component.setProps({ | ||
isDisabled: false | ||
}); | ||
expect(component.render()).toMatchSnapshot('active'); | ||
|
||
component.setProps({ | ||
isDisabled: false, | ||
isChecked: true | ||
}); | ||
|
||
expect(component.render()).toMatchSnapshot('checked'); | ||
}); | ||
|
||
it('should handle children as a label', () => { | ||
const props = {}; | ||
const component = mount(<Radio {...props}>lorem ipsum</Radio>); | ||
expect(component.render()).toMatchSnapshot('children label radio'); | ||
}); | ||
|
||
it('should return an emulated onChange event', done => { | ||
const props = {}; | ||
|
||
props.onChange = event => { | ||
expect(event).toMatchSnapshot('emulated event'); | ||
done(); | ||
}; | ||
|
||
const component = shallow(<Radio {...props}>lorem ipsum</Radio>); | ||
const mockEvent = { currentTarget: {}, target: {}, persist: helpers.noop }; | ||
component.find(PfRadio).simulate('change', true, mockEvent); | ||
}); | ||
}); |
Oops, something went wrong.