Skip to content

Commit

Permalink
Merge pull request #127 from emirhankudevi/master
Browse files Browse the repository at this point in the history
BDateTimePicker fixed error for validateConstraint.
  • Loading branch information
mstgms authored May 13, 2019
2 parents aac05b6 + 97a5316 commit 9c7f766
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/components/src/DateTimePicker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ class DatePicker extends ComponentBase {

validateConstraint() {
const { dateFormat, timeFormat } = this.props;
const instanceDate = this.bActionInputDate.getInstance();
const instanceTime = this.bActionInputTime.getInstance();
const instanceDate = dateFormat ? this.bActionInputDate.getInstance() : undefined;
const instanceTime = timeFormat ? this.bActionInputTime.getInstance() : undefined;

const dateResult = dateFormat && instanceDate ? instanceDate.validateConstraint() : true;
if (!dateResult) {
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/DateTimePicker/DateTimePicker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { AppProvider } from '@kuveytturk/boa-base';
import DateTimePicker from './DateTimePicker';
import { context, createMount } from '@kuveytturk/boa-test/utils';
import { assert } from 'chai';

describe('<DateTimePicker />', () => {
let mount;
Expand Down Expand Up @@ -38,4 +39,12 @@ describe('<DateTimePicker />', () => {
.last()
.simulate('click');
});

it('should validateConstraint', () => {
const wrapper = mount(
<DateTimePicker context={context} />,
);
const dateInput = wrapper.instance();
assert.isTrue(dateInput.validateConstraint());
});
});

0 comments on commit 9c7f766

Please sign in to comment.