Fixed a bug in expectRenderedChildAt
React components have _mountIndex, that looks like it is their order in DOM. If you swap 2 elements in DOM, their order in children array isn't changed, but their _mountIndex is
Juraj Dudak committed
Apr 18, 2014 at 12:48 UTC
385eb1cef17b8babfdade6b448a618e7e1c679db
1 file changed
+1
-4
src/test/reactComponentExpect.js
+1
-4
@@ -73,17 +73,14 @@ mergeInto(reactComponentExpect.prototype, {
73
// change soon.
74
this.toBeDOMComponent();
75
var renderedChildren = this.instance()._renderedChildren || {};
76
- var nonEmptyCount = 0;
77
- var name;
76
for (name in renderedChildren) {
77
if (!renderedChildren.hasOwnProperty(name)) {
78
continue;
79
}
80
if (renderedChildren[name]) {
83
- if (nonEmptyCount === childIndex) {
81
+ if (renderedChildren[name]._mountIndex === childIndex) {
82
return new reactComponentExpect(renderedChildren[name]);
83
}
86
- nonEmptyCount++;
84
}
85
}
86
throw new Error('Child:' + childIndex + ' is not found');