-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(radio-group): react radio-group accepts classname, id, and style…
… props [#87784030]
- Loading branch information
Caroline Taymor, Kenny Wang and Matt Royal
authored and
pivotal ui
committed
Jul 15, 2015
1 parent
b570e21
commit 4d781f5
Showing
2 changed files
with
56 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,65 @@ | ||
require('../spec_helper'); | ||
var RadioGroup = require('../../../src/pivotal-ui-react/radio-group/radio-group').RadioGroup; | ||
var Radio = require('../../../src/pivotal-ui-react/radio/radio').Radio; | ||
|
||
describe('RadioGroup', function() { | ||
var changeSpy; | ||
beforeEach(function() { | ||
var RadioGroup = require('../../../src/pivotal-ui-react/radio-group/radio-group').RadioGroup; | ||
var Radio = require('../../../src/pivotal-ui-react/radio/radio').Radio; | ||
|
||
changeSpy = jasmine.createSpy('change'); | ||
React.render( | ||
<RadioGroup name="bananas" onChange={changeSpy} id="clear-channel"> | ||
<Radio value="1">One!!!</Radio> | ||
<Radio value="2">The two value</Radio> | ||
<Radio value="3">Three</Radio> | ||
</RadioGroup>, | ||
root | ||
); | ||
}); | ||
describe('basic RadioGroup', function() { | ||
var changeSpy; | ||
beforeEach(function() { | ||
|
||
afterEach(function() { | ||
React.unmountComponentAtNode(root); | ||
}); | ||
changeSpy = jasmine.createSpy('change'); | ||
React.render( | ||
<RadioGroup name="bananas" onChange={changeSpy}> | ||
<Radio value="1">One!!!</Radio> | ||
<Radio value="2">The two value</Radio> | ||
<Radio value="3">Three</Radio> | ||
</RadioGroup>, | ||
root | ||
); | ||
}); | ||
|
||
it('renders the radio group', function() { | ||
expect('.radio-group#clear-channel').toExist(); | ||
}); | ||
afterEach(function() { | ||
React.unmountComponentAtNode(root); | ||
}); | ||
|
||
it('renders 3 radiobuttons', function() { | ||
expect('.radio-group .radio label :radio[name=bananas]').toHaveLength(3); | ||
expect('.radio-group .radio label :radio[name=bananas]:eq(0)').toHaveValue('1'); | ||
expect('.radio-group .radio label :radio[name=bananas]:eq(1)').toHaveValue('2'); | ||
expect('.radio-group .radio label :radio[name=bananas]:eq(2)').toHaveValue('3'); | ||
it('renders the radio group', function() { | ||
expect('.radio-group').toExist(); | ||
}); | ||
|
||
it('renders 3 radiobuttons', function() { | ||
expect('.radio-group .radio label :radio[name=bananas]').toHaveLength(3); | ||
expect('.radio-group .radio label :radio[name=bananas]:eq(0)').toHaveValue('1'); | ||
expect('.radio-group .radio label :radio[name=bananas]:eq(1)').toHaveValue('2'); | ||
expect('.radio-group .radio label :radio[name=bananas]:eq(2)').toHaveValue('3'); | ||
}); | ||
|
||
describe('when the radio button is changed', function() { | ||
beforeEach(function() { | ||
$('.radio-group :radio').simulate('change').simulate('click'); | ||
}); | ||
|
||
it('calls the change callback', function() { | ||
expect(changeSpy).toHaveBeenCalledWith('1'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when the radio button is changed', function() { | ||
describe('RadioGroup with custom attributes', function() { | ||
beforeEach(function() { | ||
$('.radio-group :radio').simulate('change').simulate('click'); | ||
React.render( | ||
<RadioGroup name="bananas" id="clear-channel" style={{color: 'red'}} className='1234'> | ||
<Radio value="1">One!!!</Radio> | ||
<Radio value="2">The two value</Radio> | ||
<Radio value="3">Three</Radio> | ||
</RadioGroup>, | ||
root | ||
); | ||
}); | ||
|
||
it('calls the change callback', function() { | ||
expect(changeSpy).toHaveBeenCalledWith('1'); | ||
it('renders the radio group with the overrides', function() { | ||
expect('.radio-group').toHaveAttr('id', 'clear-channel'); | ||
expect('.radio-group').toHaveClass('1234'); | ||
expect('.radio-group').toHaveCss({color: 'rgb(255, 0, 0)'}); | ||
}); | ||
}); | ||
}); |
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