Skip to content

Commit ac49447

Browse files
Merge pull request #3560 from bixlabs/make-onRequestClose-optional
[Snackbar] Make on request close optional
2 parents b264502 + ed993b1 commit ac49447

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"karma-sourcemap-loader": "^0.3.7",
9797
"karma-webpack": "^1.7.0",
9898
"mocha": "^2.2.5",
99+
"nodemon": "^1.9.1",
99100
"phantomjs": "^1.9.17",
100101
"react": "^0.14.0",
101102
"react-addons-test-utils": "^0.14.7",

src/snackbar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const Snackbar = React.createClass({
119119
*
120120
* @param {string} reason Can be:`"timeout"` (`autoHideDuration` expired) or: `"clickaway"`
121121
*/
122-
onRequestClose: React.PropTypes.func.isRequired,
122+
onRequestClose: React.PropTypes.func,
123123

124124
/**
125125
* Controls whether the `Snackbar` is opened or not.

test/unit/Snackbar.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import {shallow} from 'enzyme';
3+
import {assert} from 'chai';
4+
import Snackbar from 'src/snackbar';
5+
6+
describe('<Snackbar />', () => {
7+
it('renders hidden by default', () => {
8+
const wrapper = shallow(
9+
<Snackbar open={false} message="Message" autoHideDuration={4000} />
10+
);
11+
12+
assert.equal(
13+
wrapper.find('div').at(0).node.props.style.visibility,
14+
'hidden',
15+
'visibility should be hidden'
16+
);
17+
});
18+
});

0 commit comments

Comments
 (0)