Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
feat(switch): removes name from props
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmeyer committed Oct 13, 2019
1 parent 5636c0b commit b4bc81c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
3 changes: 0 additions & 3 deletions src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ interface Props {
id: string
/** The label to render next to the switch */
label: string
/**Gives the switch a name */
name?: string
/** Determines if the switch should be disabled or not. By default false */
disabled?: boolean
/** The onChange listener */
Expand All @@ -23,7 +21,6 @@ class Switch extends Component<Props, {}> {
<div>
<FormCheck
type="switch"
name={this.props.name}
id={this.props.id}
label={this.props.label}
disabled={this.props.disabled}
Expand Down
9 changes: 1 addition & 8 deletions test/switch.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { mount, shallow } from 'enzyme'
import { mount } from 'enzyme'
import FormCheck from 'react-bootstrap/FormCheck'
import * as sinon from 'sinon'
import { Switch } from '../src'
Expand All @@ -9,17 +9,10 @@ describe('Switch', () => {
const switchWrapper = mount(<Switch id="id" label="Switch" />)
expect(switchWrapper.text()).toEqual('Switch')
expect(switchWrapper.props().disabled).toBeFalsy()
expect(switchWrapper.props().name).toBeUndefined()
expect(switchWrapper.props().onChange).toBeUndefined()
expect(switchWrapper.find(FormCheck)).toHaveLength(1)
})

it('Switch should allow for the use of a name', () => {
const switchWrapper = shallow(<Switch id="switch" label="Switch" name="test" />)
const bootstrapSwitch = switchWrapper.find(FormCheck)
expect(bootstrapSwitch.props().name).toEqual('test')
})

it('Switch should render be rendered disabled when disabled prop is used', () => {
const wrapper = mount(<Switch id="switch" label="Switch" disabled />)
const input = wrapper.find(HTMLInputElement)
Expand Down

0 comments on commit b4bc81c

Please sign in to comment.