@@ -21,6 +21,25 @@ describe('ReactDOMInput', function() {
2121 var ReactLink ;
2222 var ReactTestUtils ;
2323
24+ var onClick = mocks . getMockFunction ( ) ;
25+
26+ function expectClickThru ( input ) {
27+ onClick . mockClear ( ) ;
28+ ReactTestUtils . Simulate . click ( input . getDOMNode ( ) ) ;
29+ expect ( onClick . mock . calls . length ) . toBe ( 1 ) ;
30+ }
31+
32+ function expectNoClickThru ( input ) {
33+ onClick . mockClear ( ) ;
34+ ReactTestUtils . Simulate . click ( input . getDOMNode ( ) ) ;
35+ expect ( onClick . mock . calls . length ) . toBe ( 0 ) ;
36+ }
37+
38+ function mounted ( input ) {
39+ input = ReactTestUtils . renderIntoDocument ( input ) ;
40+ return input ;
41+ }
42+
2443 beforeEach ( function ( ) {
2544 require ( 'mock-modules' ) . dumpCache ( ) ;
2645 React = require ( 'React' ) ;
@@ -29,6 +48,28 @@ describe('ReactDOMInput', function() {
2948 spyOn ( console , 'warn' ) ;
3049 } ) ;
3150
51+ it ( 'should forward clicks when it starts out not disabled' , function ( ) {
52+ expectClickThru ( mounted ( < input onClick = { onClick } /> ) ) ;
53+ } ) ;
54+
55+ it ( 'should not forward clicks when it starts out disabled' , function ( ) {
56+ expectNoClickThru (
57+ mounted ( < input disabled = { true } onClick = { onClick } /> )
58+ ) ;
59+ } ) ;
60+
61+ it ( 'should forward clicks when it becomes not disabled' , function ( ) {
62+ var input = mounted ( < input disabled = { true } onClick = { onClick } /> ) ;
63+ input . setProps ( { disabled : false } ) ;
64+ expectClickThru ( input ) ;
65+ } ) ;
66+
67+ it ( 'should not forward clicks when it becomes disabled' , function ( ) {
68+ var input = mounted ( < input onClick = { onClick } /> ) ;
69+ input . setProps ( { disabled : true } ) ;
70+ expectNoClickThru ( input ) ;
71+ } ) ;
72+
3273 it ( 'should display `defaultValue` of number 0' , function ( ) {
3374 var stub = < input type = "text" defaultValue = { 0 } /> ;
3475 stub = ReactTestUtils . renderIntoDocument ( stub ) ;
0 commit comments