-
Notifications
You must be signed in to change notification settings - Fork 36
fix(tests and events): resolves unsupported events and passing tests #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3378830
fix(tests and events): resolves unsupported events and passing tests
mikerob215 a7d2a07
Update src/pure.js
mikerob215 6281caa
Update src/file-event.js
mikerob215 06309b6
fix(tests and events): rename file
mikerob215 85fac9a
Update src/fire-event.js
mikerob215 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,18 @@ | ||
import { fireEvent as domFireEvent, createEvent } from '@testing-library/dom' | ||
|
||
// Similar to RTL we make are own fireEvent helper that just calls DTL's fireEvent with that | ||
// we can that any specific behaviors to the helpers we need | ||
export const fireEvent = (...args) => domFireEvent(...args) | ||
|
||
Object.keys(domFireEvent).forEach((key) => { | ||
fireEvent[key] = (elem) => { | ||
// Preact registers event-listeners in lower-case, so onPointerStart becomes pointerStart | ||
// here we will copy this behavior, when we fire an element we will fire it in lowercase so | ||
// wae hit the Preact listeners. | ||
mikerob215 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const eventName = `on${key.toLowerCase()}` | ||
const isInElem = eventName in elem | ||
return isInElem | ||
? domFireEvent[key](elem) | ||
: domFireEvent(elem, createEvent(key[0].toUpperCase() + key.slice(1), elem)) | ||
} | ||
}) |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a test specifically for the issue tagged here or is that one not intended to be solved by this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added those to the big list of tests, they should be covered, they were just missing before. With this bug they would have passing tests anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other related issue, I think the bottom issue in open was about events that were already covered in this test suite too. All passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the description to link to the issue as that was missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth adding reverse tests? I dont know if if thats a thing but we could write tests that check
'onpointerenter' in dom
and once they fail, we'd know we could delete these patches?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave them out for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding them in another pr? Like I said, looking for ways to contribute