File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ import React from 'react';
44class Button extends React . PureComponent {
55 static propTypes = {
66 children : PropTypes . node . isRequired ,
7- title : PropTypes . string . isRequired ,
7+ title : PropTypes . string ,
8+ } ;
9+
10+ static defaultProps = {
11+ title : null ,
812 } ;
913
1014 render ( ) {
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { shallow } from 'enzyme' ;
3+ import { assert } from 'chai' ;
4+
5+ import Button from '../src/js/Button' ;
6+
7+ describe ( '<Button />' , ( ) => {
8+ describe ( 'title' , ( ) => {
9+ it ( 'should copy `title` to `aria-label`' , ( ) => {
10+ const wrapper = shallow ( (
11+ < Button title = "Collapse" >
12+ Collapse
13+ </ Button >
14+ ) ) ;
15+
16+ assert . equal ( 'Collapse' , wrapper . find ( 'button' ) . prop ( 'aria-label' ) ) ;
17+ } ) ;
18+
19+ it ( 'should set `type` to `button`' , ( ) => {
20+ const wrapper = shallow ( (
21+ < Button >
22+ Basic Button
23+ </ Button >
24+ ) ) ;
25+
26+ assert . equal ( 'button' , wrapper . find ( 'button' ) . prop ( 'type' ) ) ;
27+ } ) ;
28+
29+ it ( 'should pass extra properties to the base button' , ( ) => {
30+ const wrapper = shallow ( (
31+ < Button className = "btn" >
32+ Basic Button
33+ </ Button >
34+ ) ) ;
35+
36+ assert . equal ( 'btn' , wrapper . find ( 'button' ) . prop ( 'className' ) ) ;
37+ } ) ;
38+ } ) ;
39+ } ) ;
You can’t perform that action at this time.
0 commit comments