Skip to content

Commit fd0b640

Browse files
committed
Merge pull request #2 from unthunk/markup-cleanup
Fixes for tests
2 parents f31559b + c6956cf commit fd0b640

File tree

6 files changed

+40
-5
lines changed

6 files changed

+40
-5
lines changed

src/DateTimePickerHours.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class DateTimePickerHours extends Component {
1919
<tbody>
2020
<tr>
2121
<td>
22-
<a onClick={this.props.onSwitch} data-action="togglePicker" title="Select Time">
22+
<a className="togglePicker" onClick={this.props.onSwitch} data-action="togglePicker" title="Select Time">
2323
<Glyphicon glyph="time" />
2424
</a>
2525
</td>

src/DateTimePickerIcons.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { Component, PropTypes } from "react";
2+
3+
export default class DateTimePickerIcons extends Component {
4+
static defaultProps = {
5+
defaultIcons: {
6+
time: 'glyphicon glyphicon-time',
7+
date: 'glyphicon glyphicon-calendar',
8+
up: 'glyphicon glyphicon-chevron-up',
9+
down: 'glyphicon glyphicon-chevron-down',
10+
previous: 'glyphicon glyphicon-chevron-left',
11+
next: 'glyphicon glyphicon-chevron-right',
12+
today: 'glyphicon glyphicon-screenshot',
13+
clear: 'glyphicon glyphicon-trash',
14+
close: 'glyphicon glyphicon-remove'
15+
}
16+
}
17+
18+
getIcon = () => {
19+
var ret = this.props.icons && this.props.icons[this.props.glyph] ? this.props.icons[this.props.glyph] : this.props.defaultIcons[this.props.glyph];
20+
return ret;
21+
}
22+
23+
getClasses = () => {
24+
var ret = this.props.className ? "" + this.props.className + " " + this.getIcon() : this.getIcon();
25+
return ret;
26+
}
27+
28+
render() {
29+
return (
30+
<span {...this.props} className={this.getClasses()}>
31+
{this.props.children}
32+
</span>
33+
);
34+
}
35+
}

src/DateTimePickerMinutes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class DateTimePickerMinutes extends Component {
1818
<tbody>
1919
<tr>
2020
<td>
21-
<a onClick={this.props.onSwitch} data-action="togglePicker" title="Select Time">
21+
<a className="togglePicker" onClick={this.props.onSwitch} data-action="togglePicker" title="Select Time">
2222
<Glyphicon glyph="time" />
2323
</a>
2424
</td>

src/__tests__/DateTimePickerHours-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("DateTimePickerHours", function() {
2929
});
3030

3131
it("calls onSwitch when clicking the switch", function() {
32-
const switchIcon = TestUtils.findRenderedDOMComponentWithClass(hours, "picker-switch");
32+
const switchIcon = TestUtils.findRenderedDOMComponentWithClass(hours, "togglePicker");
3333
TestUtils.Simulate.click(switchIcon);
3434
expect(onSwitchMock.mock.calls.length).toBe(1);
3535
});

src/__tests__/DateTimePickerMinutes-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("DateTimePickerMinutes", function() {
2929
});
3030

3131
it("calls onSwitch when clicking the switch", function() {
32-
const switchIcon = TestUtils.findRenderedDOMComponentWithClass(minutes, "picker-switch");
32+
const switchIcon = TestUtils.findRenderedDOMComponentWithClass(minutes, "togglePicker");
3333
TestUtils.Simulate.click(switchIcon);
3434
expect(onSwitchMock.mock.calls.length).toBe(1);
3535
});

src/__tests__/DateTimePickerMonths-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe("DateTimePickerMonths", function() {
3939
});
4040

4141
it("calls showYears when clicking the year", function() {
42-
const year = TestUtils.findRenderedDOMComponentWithClass(months, "switch");
42+
const year = TestUtils.findRenderedDOMComponentWithClass(months, "picker-switch");
4343
TestUtils.Simulate.click(year);
4444
expect(showYearsMock.mock.calls.length).toBe(1);
4545
});

0 commit comments

Comments
 (0)