File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
test/src/main/scala/scommons/react/test/util Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -166,24 +166,26 @@ sealed trait RendererUtils[Instance <: RenderedInstance] extends Matchers {
166166 }
167167
168168 private def getComponentChildren (result : Instance ): List [Instance ] = {
169- val resultChildren = result.asInstanceOf [js.Dynamic ].children
169+ val resChildren = result.asInstanceOf [js.Dynamic ].children
170+ .asInstanceOf [js.UndefOr [scalajs.js.Array [Instance ]]]
170171
171172 // in case of ShallowInstance or ReactElement get children from props
172173 // in case of TestInstance return children as it is
173174 //
174- if (scalajs.js.isUndefined(resultChildren)) {
175- if (scalajs.js.isUndefined(result.props)) Nil
176- else {
177- val children = result.props.children
178-
179- if (scalajs.js.isUndefined(children)) Nil
180- else if (scalajs.js.Array .isArray(children)) {
181- children.asInstanceOf [scalajs.js.Array [Instance ]].toList
175+ resChildren.toOption match {
176+ case Some (children) if children.length > 0 => children.toList
177+ case _ =>
178+ if (scalajs.js.isUndefined(result.props)) Nil
179+ else {
180+ val children = result.props.children
181+
182+ if (scalajs.js.isUndefined(children)) Nil
183+ else if (scalajs.js.Array .isArray(children)) {
184+ children.asInstanceOf [scalajs.js.Array [Instance ]].toList
185+ }
186+ else List (children.asInstanceOf [Instance ])
182187 }
183- else List (children.asInstanceOf [Instance ])
184- }
185188 }
186- else resultChildren.asInstanceOf [js.Array [Instance ]].toList
187189 }
188190}
189191
You can’t perform that action at this time.
0 commit comments