Skip to content

Commit

Permalink
Item/test: fix keyPress despatcher with charcode
Browse files Browse the repository at this point in the history
  • Loading branch information
ryota-murakami committed Aug 17, 2019
1 parent 44b4f63 commit 7c54d9f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/App/Item/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ test('should work edit mode toggle', () => {
fireEvent.change(getByTestId('todo-edit-input'), {
target: { value: 'cut tomato plus' }
})
//@TODO why fireEvent.keyPress() didn't work?
fireEvent.keyPress(getByTestId('todo-edit-input'), {
key: 'Enter',
code: 13,
charCode: 13
})

expect(getByTestId('todo-body-text')).toHaveTextContent('cut tomato plus')
// @TODO why fireEvent.keyPress() didn't work?
expect(container.querySelector('[class*="editing"]')).toBe(null)
// @TODO in jsdom, dynamic .editing css class doesn't apply. So tipically show/hide UI test are difficult.
// @ref https://spectrum.chat/testing-library/general/testing-an-accordion~b004a9b1-b104-4eb1-a73b-43c60b1a3630?m=MTU1NDQ4NDIzMTQ5Ng==
Expand Down

0 comments on commit 7c54d9f

Please sign in to comment.