From c6956cf1e722395b56ea1d3a115503f2baa61e1b Mon Sep 17 00:00:00 2001 From: Lucas Myers Date: Wed, 28 Oct 2015 14:41:34 -0700 Subject: [PATCH] Fixes for tests --- src/DateTimePickerHours.js | 2 +- src/DateTimePickerIcons.js | 35 +++++++++++++++++++++ src/DateTimePickerMinutes.js | 2 +- src/__tests__/DateTimePickerHours-test.js | 2 +- src/__tests__/DateTimePickerMinutes-test.js | 2 +- src/__tests__/DateTimePickerMonths-test.js | 2 +- 6 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/DateTimePickerIcons.js diff --git a/src/DateTimePickerHours.js b/src/DateTimePickerHours.js index de1c53da..0f0947be 100644 --- a/src/DateTimePickerHours.js +++ b/src/DateTimePickerHours.js @@ -19,7 +19,7 @@ export default class DateTimePickerHours extends Component { - + diff --git a/src/DateTimePickerIcons.js b/src/DateTimePickerIcons.js new file mode 100644 index 00000000..e9d286be --- /dev/null +++ b/src/DateTimePickerIcons.js @@ -0,0 +1,35 @@ +import React, { Component, PropTypes } from "react"; + +export default class DateTimePickerIcons extends Component { + static defaultProps = { + defaultIcons: { + time: 'glyphicon glyphicon-time', + date: 'glyphicon glyphicon-calendar', + up: 'glyphicon glyphicon-chevron-up', + down: 'glyphicon glyphicon-chevron-down', + previous: 'glyphicon glyphicon-chevron-left', + next: 'glyphicon glyphicon-chevron-right', + today: 'glyphicon glyphicon-screenshot', + clear: 'glyphicon glyphicon-trash', + close: 'glyphicon glyphicon-remove' + } + } + + getIcon = () => { + var ret = this.props.icons && this.props.icons[this.props.glyph] ? this.props.icons[this.props.glyph] : this.props.defaultIcons[this.props.glyph]; + return ret; + } + + getClasses = () => { + var ret = this.props.className ? "" + this.props.className + " " + this.getIcon() : this.getIcon(); + return ret; + } + + render() { + return ( + + {this.props.children} + + ); + } +} diff --git a/src/DateTimePickerMinutes.js b/src/DateTimePickerMinutes.js index 1bda15fd..5fe18833 100644 --- a/src/DateTimePickerMinutes.js +++ b/src/DateTimePickerMinutes.js @@ -18,7 +18,7 @@ export default class DateTimePickerMinutes extends Component { - + diff --git a/src/__tests__/DateTimePickerHours-test.js b/src/__tests__/DateTimePickerHours-test.js index 36f63c93..c671604a 100644 --- a/src/__tests__/DateTimePickerHours-test.js +++ b/src/__tests__/DateTimePickerHours-test.js @@ -29,7 +29,7 @@ describe("DateTimePickerHours", function() { }); it("calls onSwitch when clicking the switch", function() { - const switchIcon = TestUtils.findRenderedDOMComponentWithClass(hours, "picker-switch"); + const switchIcon = TestUtils.findRenderedDOMComponentWithClass(hours, "togglePicker"); TestUtils.Simulate.click(switchIcon); expect(onSwitchMock.mock.calls.length).toBe(1); }); diff --git a/src/__tests__/DateTimePickerMinutes-test.js b/src/__tests__/DateTimePickerMinutes-test.js index 7708a56b..76063c5c 100644 --- a/src/__tests__/DateTimePickerMinutes-test.js +++ b/src/__tests__/DateTimePickerMinutes-test.js @@ -29,7 +29,7 @@ describe("DateTimePickerMinutes", function() { }); it("calls onSwitch when clicking the switch", function() { - const switchIcon = TestUtils.findRenderedDOMComponentWithClass(minutes, "picker-switch"); + const switchIcon = TestUtils.findRenderedDOMComponentWithClass(minutes, "togglePicker"); TestUtils.Simulate.click(switchIcon); expect(onSwitchMock.mock.calls.length).toBe(1); }); diff --git a/src/__tests__/DateTimePickerMonths-test.js b/src/__tests__/DateTimePickerMonths-test.js index ee8d99d2..006b2fc6 100644 --- a/src/__tests__/DateTimePickerMonths-test.js +++ b/src/__tests__/DateTimePickerMonths-test.js @@ -39,7 +39,7 @@ describe("DateTimePickerMonths", function() { }); it("calls showYears when clicking the year", function() { - const year = TestUtils.findRenderedDOMComponentWithClass(months, "switch"); + const year = TestUtils.findRenderedDOMComponentWithClass(months, "picker-switch"); TestUtils.Simulate.click(year); expect(showYearsMock.mock.calls.length).toBe(1); });