arkency/reactjs_koans

05 Challenge has confusing error

carver opened this issue · 1 comments

I'm seeing "Apples" in my list, but the test is failing with "GroceriesListItem should display a grocery name".

Changing the test in this way results in a passing test:

-      assert.equal(groceryItem.props.children, "Apples", "GroceriesListItem should display a grocery name");
+      let children = groceryItem.props.children;
+      assert.equal(React.Children.count(children), 1, "GroceriesListItem should contain one child element");
+      let expected = "Apples";
+      React.Children.forEach(children, function (c) { if (c != expected) { throw new Error("GroceriesListItem should display only: "+expected+" not "+c); }});

I'm going to assume that my code is broken instead of the test, since I'm new to React. Can someone help me improve this test so people can understand what's actually wrong?

Hey there!

There's already an issue for that: #4

We will take care of that, thanks for pointing exact place in code.