Skip to content
This repository was archived by the owner on Nov 16, 2018. It is now read-only.

Commit 9064d96

Browse files
committed
Adds test for when changing inputFormat prop
1 parent 4686f8f commit 9064d96

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/__tests__/DateTimeField-test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ const { TestUtils } = React.addons;
66
describe("DateTimeField", function() {
77
const moment = require("moment");
88
const DateTimeField = require("../DateTimeField.js");
9+
const happyDate = moment("1990-06-05 07:30");
910
let parent, TestParent;
1011

1112
beforeEach(() => {
1213
TestParent = React.createFactory(React.createClass({
1314
getInitialState() {
14-
return { dateTime: moment("1990-06-05 07:30").format("x") };
15+
return { dateTime: happyDate.format("x") };
1516
},
1617

1718
render() {
18-
return <DateTimeField dateTime={this.state.dateTime} />;
19+
return <DateTimeField {...this.state} />;
1920
}
2021
}));
2122
parent = TestUtils.renderIntoDocument(TestParent()); // eslint-disable-line
@@ -39,5 +40,12 @@ describe("DateTimeField", function() {
3940
expect(input.getDOMNode().value).toBe("06/04/81 5:45 AM");
4041
});
4142

43+
it("changes the displayed format when inputFormat changes", function() {
44+
const input = TestUtils.findRenderedDOMComponentWithTag(parent, "input");
45+
expect(input.getDOMNode().value).toBe("06/05/90 7:30 AM");
46+
parent.setState({inputFormat: "x"});
47+
expect(input.getDOMNode().value).toBe(happyDate.format("x"));
48+
});
49+
4250
});
4351
});

0 commit comments

Comments
 (0)