Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

feat(jqLite): support isDefaultPrevented for triggerHandler dummies #8008

Closed
wants to merge 1 commit into from
Closed

feat(jqLite): support isDefaultPrevented for triggerHandler dummies #8008

wants to merge 1 commit into from

Conversation

shahata
Copy link
Contributor

@shahata shahata commented Jun 27, 2014

triggerHandler sends dummy events to an element, but although the event includes the preventDefault method, there is no way to see if it was called for the event. This is sometimes important when testing directives that use preventDefault

triggerHandler sends dummy events to an element, but although the event includes the preventDefault method, there is no way to see if it was called for the event. This is sometimes important when testing directives that use preventDefault
@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#8008)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@shahata
Copy link
Contributor Author

shahata commented Jun 27, 2014

This is just a simple patch to solve one particular use case that was bothering me with testing some directive. I think there are many other use cases this does not solve. For example, I might want to trigger a keydown event handler and have event.shiftKey = true. I think the best way to address this is to have a jqLite "extra" method that ppl can invoke with their own mocked event in tests instead of calling triggerHandler. Maybe simulateEvent(eventType, event[, extraParameters]) (which behaves just like triggerHandler, with the exception that the caller supplies the dummy event)... If this is something desirable, I can send a PR for this.

@shahata shahata added cla: yes and removed cla: no labels Jun 27, 2014
@IgorMinar
Copy link
Contributor

lgtm

@IgorMinar
Copy link
Contributor

if we went the simulateEvent route, it's likely that we'd need to provide a mock event too. your current approach is simple and gets the job done.

@IgorMinar IgorMinar closed this in 7e71acd Jun 28, 2014
ckknight pushed a commit to ckknight/angular.js that referenced this pull request Jul 16, 2014
triggerHandler sends dummy events to an element, but although the event includes the preventDefault method, there is no way to see if it was called for the event. This is sometimes important when testing directives that use preventDefault

Closes angular#8008
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants