Will Gilbert (4) [Avatar] Offline
#1
The helper method 'getElement' is returning too many elements e.g as many elements as it is nested:

  const getElement = wrapper => elementType => classToSearchFor => (
  wrapper.find(elementType).findWhere(e => e.props().className && e.props().className.indexOf(classToSearchFor) !== -1)
);


However, changing to this seems to works and maintains the intent of the method:

const getElement = wrapper => elementType => classToSearchFor => (
  wrapper.find(elementType).filterWhere(n => n.hasClass(classToSearchFor))
);
Zac Braddy (8) [Avatar] Offline
#2
Hi Will

Thanks for the feedback mate, that is most odd. May I ask, does this behaviour happen when you're using a branch from the courses github repo without any changes to it or are you following along with your own codebase? If it is a branch which one are you seeing this in? If you are following along with your own code base would you care to share the code for the component that you're seeing this behaviour in?

Just interested to see if I can diagnose the problem you're having, even if that problem might simply be that I made a goof smilie

Cheers
Zac
Will Gilbert (4) [Avatar] Offline
#3
Currently working in branch 'u5-m3-doit'. As is, 'getElement' returns all nested matching elements; When I swap in the shorter version which I posted above all tests pass because a single element is returned.

BTW -- I love the way you use TDD. It was extremely helpful in learning how to do it in JavaScript & React. Have used TDD for years as a Java programmer.