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

Contains #153

Closed
SeeThruHead opened this issue Feb 1, 2016 · 6 comments · Fixed by #154
Closed

Contains #153

SeeThruHead opened this issue Feb 1, 2016 · 6 comments · Fixed by #154
Labels

Comments

@SeeThruHead
Copy link

I kinda was expecting this to not pass

  const wrapper2 = shallow(<Button><span>Hello</span><div>Goodbye</div></Button>);
  const expectedChildren = [
    <span>wrong</span>,
    <div>Goodbye</div>
  ];

  t.ok(wrapper2.contains(expectedChildren), 'should render children');

Any thoughts?

@lelandrichardson
Copy link
Collaborator

whoa. I'd call that a bug.

@SeeThruHead
Copy link
Author

workarounds:

  // fails like expected
  const expectedChildren = [
    <span>bye</span>,
    <div>Goodbye</div>
  ];

  t.deepEqual(wrapper2.props().children, expectedChildren, 'should render children');
  // Passing
  t.ok(wrapper2.contains(<span>Hello</span>), 'should render children');
  t.ok(wrapper2.contains(<div>Goodbye</div>), 'should render children');

Maybe it's fine that contains only accepts single nodes?

@lelandrichardson
Copy link
Collaborator

@SeeThruHead Yeah. I'm not sure what contains would actually do when passed an array... I don't think the case is ever handled specifically so I'm not sure what it actually does in that case.

@SeeThruHead
Copy link
Author

Looks like it will try to compare the array to every node using nodeEqual from './Utils'

I'll take a look at it later to see if I can figure out why nodeEqual(Array, Node) is passing.

@lelandrichardson
Copy link
Collaborator

@SeeThruHead I believe I've fixed this ^^. Thanks for reporting the bug!

@SeeThruHead
Copy link
Author

Awesome thanks a lot @lelandrichardson

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

Successfully merging a pull request may close this issue.

2 participants