Skip to content

Commit

Permalink
test(DatePicker): add test for open-by-keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
asudoh committed Feb 13, 2020
1 parent fdbf180 commit b687f80
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/react/src/components/DatePicker/DatePicker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,25 @@ describe('DatePickerSkeleton', () => {
});
});
});

describe('Opening up calendar dropdown', () => {
const wrapper = mount(
<DatePicker datePickerType="range" className="extra-class">
<DatePickerInput labelText="Date Picker label" id="input-from" />
<DatePickerInput labelText="Date Picker label" id="input-to" />
</DatePicker>
);

it('has the range date picker with min and max dates', () => {
const datePicker = wrapper.instance();
const input = wrapper.find('input').at(0);

jest.spyOn(datePicker.cal, 'open');

input
.getDOMNode()
.dispatchEvent(new window.KeyboardEvent('keydown', { key: 'ArrowDown' }));

expect(datePicker.cal.open).toHaveBeenCalled();
});
});

0 comments on commit b687f80

Please sign in to comment.