-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Remove remaining jQuery from View tests #3073
base: master
Are you sure you want to change the base?
Conversation
@akre54 should Backbone.Nativeview provide a Backbone.$ to check against? |
Why? It's not present and not needed. |
"which all jQuery-like apis should support" was what made me think of that, but I guess it's not really a jQuery API, but something that makes Backbone not need jQuery |
initialize: function() { | ||
this.listenTo(this.model, 'all x', function(){ ok(false); }); | ||
this.listenTo(this.collection, 'all x', function(){ ok(false); }); | ||
this.listenTo(this.model, 'all x', function(){ ok(false); }, 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.
We don't need the this
in the end.
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.
Good catch. Thanks.
Mind if I refactor the dispatchEvent shim and fix the custom event test? |
Go for it. Not sure why Travis is throwing a fit. Maybe we have to expose |
Nah, non-standard custom events just need to be created in a special way. |
Take a look at #3077. I think that sort of thing will make this process much easier. |
@braddunbar reverted View -> Backbone.View changes, and removed the |
This looks good to me. It turns out there wasn't an easy way to fire a custom event on IE<=8. Also, in case anyone is wondering why there's a click function, ariya/phantomjs#10795 is why. |
Hey guys, can this be merged or is there something else you think we should do? |
I do not think this one should be merged. From @jashkenas in #3077:
Testing via mocked event creation is certainly not the real thing. Further, it somewhat obscures the contract. |
How is this different from what we have now with Tests aren't the place to catch issues with the latest jQuery. We've faced it before (with PATCH support, e.g.), and there almost always is a reasonable solution. Specs should never test your dependencies. |
I'd prefer contract only tests in this case but using a trusted and tested library like jQuery is certainly better than an untested implementation written just for our tests. |
Totally, and I can appreciate that. But this isn't some far-out custom code that we just pulled out of thin air. jQuery's code itself is more synthetic than what we're doing here since its |
}; | ||
|
||
function click(element) { | ||
var event; |
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.
Hey @wyuenho, how come we couldn't just use element.click()
directly here? It'd obviate this messiness here. Only downside I see is that the element would have to live in the DOM already.
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.
We can and should get rid of the click shim as soon as that phantom bug gets fixed. Either that or we use a different test runner like Karma that actually tests on real browsers.
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.
Yeah it might be nice to get something like Sauce labs testing in here too since we're concerned about older browsers.
Shame about that bug though.
@braddunbar want to take one final pass through this and then either merge or close? I'm fine either way. |
@akre54 Has PhantomJS 2 fixed this click event issue? |
Now that #3003 is merged, we need an easy way for alternative View implementations to run against our View conformance test. This pulls jQuery out of the View tests except in for checking
view.$el instanceof Backbone.$
(which all jQuery-like apis should support).