Skip to content

Commit 4ffebdd

Browse files
committed
Added ref and key for submit input button fixes react-bootstrap#235
1 parent 386147f commit 4ffebdd

5 files changed

Lines changed: 45 additions & 24 deletions

File tree

karma.ci.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ module.exports = function(config) {
33

44
basePath: '',
55

6-
frameworks: ['mocha', 'chai'],
6+
frameworks: [
7+
'mocha',
8+
'chai',
9+
'sinon'
10+
],
711

812
files: [
913
'test/vendor/es5-shim.js',

karma.dev.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ module.exports = function (config) {
33

44
basePath: '',
55

6-
frameworks: ['mocha', 'chai'],
6+
frameworks: [
7+
'mocha',
8+
'chai',
9+
'sinon'
10+
],
711

812
files: [
913
'test_bundle.js'

package.json

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,35 @@
1717
"react": ">=0.9"
1818
},
1919
"devDependencies": {
20-
"karma-chai": "0.0.2",
21-
"mocha": "~1.16.2",
22-
"karma-script-launcher": "~0.1.0",
23-
"karma-chrome-launcher": "~0.1.2",
24-
"karma-html2js-preprocessor": "~0.1.0",
25-
"karma-firefox-launcher": "~0.1.3",
26-
"karma-jasmine": "~0.1.5",
27-
"karma-coffee-preprocessor": "~0.1.2",
28-
"requirejs": "~2.1.9",
29-
"karma-requirejs": "~0.2.1",
30-
"karma-phantomjs-launcher": "~0.1.1",
31-
"karma": "~0.12.8",
32-
"karma-mocha": "~0.1.1",
33-
"react": "0.10.0",
3420
"envify": "~1.2.1",
3521
"grunt": "~0.4.2",
36-
"grunt-contrib-uglify": "~0.3.2",
37-
"grunt-contrib-clean": "~0.5.0",
38-
"grunt-contrib-watch": "~0.5.3",
22+
"grunt-amd-wrap": "^1.0.1",
3923
"grunt-browserify": "~1.3.0",
4024
"grunt-cli": "~0.1.13",
41-
"grunt-react": "~0.6.0",
25+
"grunt-contrib-clean": "~0.5.0",
26+
"grunt-contrib-copy": "~0.5.0",
4227
"grunt-contrib-requirejs": "~0.4.1",
28+
"grunt-contrib-uglify": "~0.3.2",
29+
"grunt-contrib-watch": "~0.5.3",
30+
"grunt-react": "~0.6.0",
4331
"grunt-shell": "~0.6.4",
44-
"grunt-contrib-copy": "~0.5.0",
32+
"karma": "~0.12.8",
33+
"karma-chai": "0.0.2",
34+
"karma-chrome-launcher": "~0.1.2",
35+
"karma-coffee-preprocessor": "~0.1.2",
36+
"karma-firefox-launcher": "~0.1.3",
37+
"karma-html2js-preprocessor": "~0.1.0",
38+
"karma-jasmine": "~0.1.5",
39+
"karma-mocha": "~0.1.1",
40+
"karma-phantomjs-launcher": "~0.1.1",
41+
"karma-requirejs": "~0.2.1",
42+
"karma-script-launcher": "~0.1.0",
43+
"karma-sinon": "^1.0.3",
44+
"mocha": "~1.16.2",
45+
"react": "0.10.0",
4546
"react-async": "~0.8.0",
4647
"react-router-component": "~0.15.0",
47-
"grunt-amd-wrap": "^1.0.1"
48+
"requirejs": "~2.1.9",
49+
"sinon": "^1.10.3"
4850
}
4951
}

src/Input.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var Input = React.createClass({
7878
break;
7979
case 'submit':
8080
input = this.transferPropsTo(
81-
<Button componentClass={React.DOM.input} />
81+
<Button componentClass={React.DOM.input} ref='input' key='input' />
8282
);
8383
break;
8484
default:

test/InputSpec.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ var ReactTestUtils = require('react/lib/ReactTestUtils');
66
var Input = require('../cjs/Input');
77

88
describe('Input', function () {
9+
beforeEach(function() {
10+
sinon.spy(console, 'warn');
11+
})
12+
13+
afterEach(function() {
14+
if (typeof console.warn.restore === 'function') {
15+
console.warn.called.should.be.false;
16+
console.warn.restore();
17+
}
18+
});
19+
920
it('renders children when type is not set', function () {
1021
var instance = ReactTestUtils.renderIntoDocument(
1122
<Input>
@@ -42,7 +53,7 @@ describe('Input', function () {
4253

4354
it('renders a submit button element when type=submit', function () {
4455
var instance = ReactTestUtils.renderIntoDocument(
45-
<Input type="submit" bsStyle="danger" />
56+
<Input type="submit" bsStyle="danger" wrapperClassName='test' />
4657
);
4758

4859
node = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input').getDOMNode();

0 commit comments

Comments
 (0)