-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#24 added tests for select and radio components
- Loading branch information
Showing
7 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/components/ui-elements/radio/__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,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Radio component testing renders without error 1`] = `"<div class=\\"form-check form-check-radio\\"><label class=\\"form-check-label text-dark\\"><input type=\\"radio\\" value=\\"the-radio\\" id=\\"the-radio\\" class=\\"form-check-input\\"/>the radio<span class=\\"circle\\"><span class=\\"check\\"></span></span></label></div>"`; | ||
exports[`RadioGroup component testing renders without error 1`] = `"<div class=\\"form-group\\"><div class=\\"form-check form-check-radio\\" input=\\"[object Object]\\"><label class=\\"form-check-label text-dark\\"><input type=\\"radio\\" value=\\"the-radio\\" id=\\"the-radio\\" class=\\"form-check-input\\"/>the radio<span class=\\"circle\\"><span class=\\"check\\"></span></span></label></div><div class=\\"form-check form-check-radio\\" input=\\"[object Object]\\"><label class=\\"form-check-label text-dark\\"><input type=\\"radio\\" value=\\"the-radio\\" id=\\"the-radio\\" class=\\"form-check-input\\"/>the radio<span class=\\"circle\\"><span class=\\"check\\"></span></span></label></div></div>"`; |
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,36 @@ | ||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
|
||
import Radio from './radio' | ||
import RadioGroup from './radio-group' | ||
|
||
const defaultRadioProps = { input: { value: '', onChange: () => { } }, label: 'the radio', value: 'the-radio' } | ||
const childElements = [ | ||
shallow(<Radio {...defaultRadioProps} />), | ||
shallow(<Radio {...defaultRadioProps} />) | ||
] | ||
const defaultGroupProps = { input: {}, children: childElements } | ||
|
||
describe('Radio component testing', () => { | ||
test('renders without error', () => { | ||
const wrapper = shallow(<Radio {...defaultRadioProps} />) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('RadioGroup component testing', () => { | ||
let wrapper | ||
|
||
beforeEach(() => { | ||
wrapper = shallow(<RadioGroup {...defaultGroupProps} />) | ||
}) | ||
|
||
test('renders without error', () => { | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
|
||
test('renders all children elements', () => { | ||
const childrenNumber = wrapper.find('input[type="radio"]') | ||
expect(childrenNumber.length).toBe(childElements.length) | ||
}) | ||
}) |
3 changes: 3 additions & 0 deletions
3
src/components/ui-elements/select/__snapshots__/select.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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`rendering testing renders without error 1`] = `"<div class=\\"form-group bmd-form-group\\"><label class=\\"control-label bmd-label-static\\" for=\\"the-select\\">the select</label><select name=\\"the-select\\" id=\\"the-select\\" class=\\"form-control\\"><option data-test=\\"option\\"></option><option data-test=\\"option\\">first-option</option><option data-test=\\"option\\">second-option</option><option data-test=\\"option\\">third-option</option></select></div>"`; |
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,22 @@ | ||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
|
||
import Select from './select' | ||
|
||
const defaultProps = { input: { name: 'the-select' }, label: 'the select', options: ['first-option', 'second-option', 'third-option'] } | ||
|
||
describe('rendering testing', () => { | ||
let wrapper | ||
|
||
beforeEach(() => { | ||
wrapper = shallow(<Select {...defaultProps} />) | ||
}) | ||
test('renders without error', () => { | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
|
||
test('renders correct number of options (including empty one)', () => { | ||
const optionNodes = wrapper.find('[data-test="option"]') | ||
expect(optionNodes.length).toBe(defaultProps.options.length + 1) | ||
}) | ||
}) |