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
This commit is contained in:
Juraj Dudak
2014-04-18 12:57:24 -07:00
committed by Paul O’Shannessy
parent 9a13393ce3
commit 385eb1cef1
+1 -4
View File
@@ -73,17 +73,14 @@ mergeInto(reactComponentExpect.prototype, {
// change soon.
this.toBeDOMComponent();
var renderedChildren = this.instance()._renderedChildren || {};
var nonEmptyCount = 0;
var name;
for (name in renderedChildren) {
if (!renderedChildren.hasOwnProperty(name)) {
continue;
}
if (renderedChildren[name]) {
if (nonEmptyCount === childIndex) {
if (renderedChildren[name]._mountIndex === childIndex) {
return new reactComponentExpect(renderedChildren[name]);
}
nonEmptyCount++;
}
}
throw new Error('Child:' + childIndex + ' is not found');