@@ -5,7 +5,7 @@ import renderer from 'react-test-renderer';
55
66describe ( '<Checkbox />' , ( ) => {
77 const checkbox = (
8- < Checkbox id = 'foo' value = 'Option 1' / >
8+ < Checkbox id = 'foo' value = 'Option 1' > Label </ Checkbox >
99 ) ;
1010
1111 test ( 'create checkbox' , ( ) => {
@@ -17,7 +17,7 @@ describe('<Checkbox />', () => {
1717
1818 describe ( 'Checkbox Tests' , ( ) => {
1919 let setup = ( props ) => {
20- return mount ( < Checkbox value = 'Label 1' { ...props } / >) ;
20+ return mount ( < Checkbox value = 'Label 1' { ...props } > Label </ Checkbox > ) ;
2121 } ;
2222 test ( 'should add checked attribute when checked is passed' , ( ) => {
2323 let element = setup ( {
@@ -83,37 +83,73 @@ describe('<Checkbox />', () => {
8383 } ) ;
8484
8585 test ( 'should allow props to be spread to the Checkbox component' , ( ) => {
86- const element = mount ( < Checkbox data-sample = 'Sample' / >) ;
86+ const element = mount ( < Checkbox data-sample = 'Sample' > Label </ Checkbox > ) ;
8787
8888 expect (
8989 element . find ( '.fd-form-item' ) . getDOMNode ( ) . attributes [ 'data-sample' ] . value
9090 ) . toBe ( 'Sample' ) ;
9191 } ) ;
9292
9393 test ( 'should allow props to be spread to the Checkbox component input' , ( ) => {
94- const element = mount ( < Checkbox inputProps = { { 'data-sample' : 'Sample' } } / >) ;
94+ const element = mount ( < Checkbox inputProps = { { 'data-sample' : 'Sample' } } > Label </ Checkbox > ) ;
9595
9696 expect (
9797 element . find ( '.fd-checkbox' ) . getDOMNode ( ) . attributes [ 'data-sample' ] . value
9898 ) . toBe ( 'Sample' ) ;
9999 } ) ;
100100
101101 test ( 'should allow props to be spread to the Checkbox component label' , ( ) => {
102- const element = mount ( < Checkbox labelProps = { { 'data-sample' : 'Sample' } } / >) ;
102+ const element = mount ( < Checkbox labelProps = { { 'data-sample' : 'Sample' } } > Label </ Checkbox > ) ;
103103
104104 expect (
105105 element . find ( '.fd-form-label' ) . getDOMNode ( ) . attributes [ 'data-sample' ] . value
106106 ) . toBe ( 'Sample' ) ;
107107 } ) ;
108108 } ) ;
109+ describe ( 'Validation states' , ( ) => {
110+ test ( 'should render the correct snapshots' , ( ) => {
111+ const checkboxWarning = (
112+ < Checkbox id = 'foo' state = 'warning' > Label</ Checkbox >
113+ ) ;
114+
115+ let component = renderer . create ( checkboxWarning ) ;
116+ let tree = component . toJSON ( ) ;
117+ expect ( tree ) . toMatchSnapshot ( ) ;
118+
119+ const checkboxError = (
120+ < Checkbox id = 'foo' state = 'error' > Label</ Checkbox >
121+ ) ;
122+
123+ component = renderer . create ( checkboxError ) ;
124+ tree = component . toJSON ( ) ;
125+ expect ( tree ) . toMatchSnapshot ( ) ;
126+
127+ const checkboxSuccess = (
128+ < Checkbox id = 'foo' state = 'success' > Label</ Checkbox >
129+ ) ;
130+
131+ component = renderer . create ( checkboxSuccess ) ;
132+ tree = component . toJSON ( ) ;
133+ expect ( tree ) . toMatchSnapshot ( ) ;
134+
135+ const checkboxInformation = (
136+ < Checkbox id = 'foo' state = 'information' > Label</ Checkbox >
137+ ) ;
138+
139+ component = renderer . create ( checkboxInformation ) ;
140+ tree = component . toJSON ( ) ;
141+ expect ( tree ) . toMatchSnapshot ( ) ;
142+ } ) ;
143+ } ) ;
144+
109145 test ( 'forwards the ref' , ( ) => {
110146 let ref ;
111147 class Test extends React . Component {
112148 constructor ( props ) {
113149 super ( props ) ;
114150 ref = React . createRef ( ) ;
115151 }
116- render = ( ) => < Checkbox ref = { ref } / >;
152+ render = ( ) => < Checkbox ref = { ref } > Label </ Checkbox > ;
117153 }
118154 mount ( < Test /> ) ;
119155
0 commit comments