File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,11 +8,16 @@ var Badge = React.createClass({
88 pullRight : React . PropTypes . bool
99 } ,
1010
11+ hasContent : function ( ) {
12+ return ValidComponentChildren . hasValidComponent ( this . props . children ) ||
13+ ( typeof this . props . children === 'string' ) ||
14+ ( typeof this . props . children === 'number' )
15+ } ,
16+
1117 render : function ( ) {
1218 var classes = {
1319 'pull-right' : this . props . pullRight ,
14- 'badge' : ( ValidComponentChildren . hasValidComponent ( this . props . children )
15- || ( typeof this . props . children === 'string' ) )
20+ 'badge' : this . hasContent ( )
1621 } ;
1722 return (
1823 < span
Original file line number Diff line number Diff line change @@ -23,6 +23,16 @@ describe('Badge', function () {
2323 assert . ok ( instance . getDOMNode ( ) . className . match ( / \b b a d g e \b / ) ) ;
2424 } ) ;
2525
26+ it ( 'Should have a badge using a number' , function ( ) {
27+ var count = 42 ;
28+ var instance = ReactTestUtils . renderIntoDocument (
29+ < Badge >
30+ { count }
31+ </ Badge >
32+ ) ;
33+ assert . ok ( instance . getDOMNode ( ) . className . match ( / \b b a d g e \b / ) ) ;
34+ } ) ;
35+
2636 it ( 'Should have a badge class pulled right' , function ( ) {
2737 var instance = ReactTestUtils . renderIntoDocument (
2838 < Badge pullRight >
You can’t perform that action at this time.
0 commit comments