-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(keyboard): dispatch change event on blur (#703)
- Loading branch information
1 parent
e5e78af
commit 9600abb
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {setup} from '__tests__/helpers/utils' | ||
import userEvent from '../../../' | ||
|
||
it('dispatch change event on blur', () => { | ||
const {element, getEvents} = setup('<input/>') | ||
|
||
;(element as HTMLInputElement).focus() | ||
userEvent.keyboard('foo') | ||
;(element as HTMLInputElement).blur() | ||
|
||
expect(getEvents('change')).toHaveLength(1) | ||
}) | ||
|
||
it('do not dispatch change event if value did not change', () => { | ||
const {element, getEvents} = setup('<input/>') | ||
|
||
;(element as HTMLInputElement).focus() | ||
userEvent.keyboard('foo') | ||
userEvent.keyboard('{backspace}{backspace}{backspace}') | ||
;(element as HTMLInputElement).blur() | ||
|
||
expect(getEvents('change')).toHaveLength(0) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters