Skip to content
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

mockDOMSource can't mock events for isolated nested components #279

Closed
m-orchard opened this issue Mar 23, 2016 · 5 comments
Closed

mockDOMSource can't mock events for isolated nested components #279

m-orchard opened this issue Mar 23, 2016 · 5 comments

Comments

@m-orchard
Copy link

There isn't a way to differentiate events mocked with mockDOMSource, where nested components are listening to events on the same namespace and relying on isolation to differentiate them.

For example, something like: https://jsfiddle.net/25a74k0k/.

The only way I can think to achieve this, is to pass in a custom class to the child (made unique by the parent), add it to the elements being listened to, and then use that custom class when selecting them. However, this is complicating the way a child must be initialised and basically duplicating what we are getting from isolate on the real DOMSource.

Also, in cases where :root is the only selector used, the child would have to wrap the root element in another element to be able to select the custom class, which bloats the mark up.

@m-orchard
Copy link
Author

I should mention, I've not had any ideas on how to solve this yet :) it may simply force isolation to be implemented in or copied to mockDOMSource, but I'm hoping someone has a better idea.

@chadrien
Copy link
Contributor

That's a tricky one. I have no idea how we could get past this, but what I know for sure is that the implementation should "force" us to be explicit about the fact that we mock events and observables for a nested component, otherwise reading the tests might make no sense to the reader ("why is he mocking a click on selector x? It doesn't event exists.")

@staltz
Copy link
Member

staltz commented Mar 23, 2016

Seems like mockDOMSource needs to take isolation into account. Thanks for pointing this out.

@staltz staltz changed the title mockDOMSource can't mock events for nested components that select the same namespace mockDOMSource can't mock events for isolated nested components Mar 23, 2016
@staltz
Copy link
Member

staltz commented Jun 29, 2016

Lifting this from priority 3 to 4.

@staltz staltz self-assigned this Jul 13, 2016
staltz added a commit to cyclejs/dom that referenced this issue Jul 13, 2016
Based on classNames, not on Snabbdom isolate module.

Fixes issue cyclejs/cyclejs#279.
@staltz
Copy link
Member

staltz commented Jul 13, 2016

Done in Cycle DOM v10.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants