Skip to content

Conversation

@chrismanciero
Copy link
Contributor

Description

Update unit tests for DatePicker component

@chrismanciero chrismanciero requested review from a team, bcullman, greg-a-smith and jbadan January 31, 2019 13:17
// check to make sure calendar is shown
expect(wrapper.state('hidden')).toBeFalsy();

// click to hide calendar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like the wrong comment. It's simulating a click in the input, which based on the next assertion, should not hide the calendar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greg-a-smith - thanks for noticing, i just updated the comment

let event = new MouseEvent('mousedown', {
target: document.querySelector('body')
});
document.dispatchEvent(event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why the added mousedown event, but then no additional assertions. I'm probably just missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed MouseEvent code since it was not necessary

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still seeing a couple of these in the files changed diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, missed that mouseDown event. Just added an assertion to check that calendar is hidden.

let event = new MouseEvent('mousedown', {
target: document.querySelector('body')
});
document.dispatchEvent(event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why the added mousedown event, but then no additional assertions. I'm probably just missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added assertion to check that calendar is hidden



// press Esc key
wrapper.find('input[type="text"]').simulate('keypress', { key: 'Esc' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't each test block end with an assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added assertions at the end of test

Copy link
Contributor

@greg-a-smith greg-a-smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 🚢

@chrismanciero chrismanciero merged commit 7fffa2a into master Jan 31, 2019
@chrismanciero chrismanciero deleted the fix/DatePicker-unit-tests branch January 31, 2019 19:59
greg-a-smith pushed a commit that referenced this pull request Mar 5, 2019
* fix: update unit tests

* fix comments, remove unnecessary test code

* added assertion check after MouseDown event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants