LithoViewAssert#containsComponent)
instead.@Deprecated
public final class SubComponentDeepExtractor
extends java.lang.Object
org.assertj.core.api.Assertions#assertThat
.
Recursively extracts sub components from a Component, wrapping them in an InspectableComponent
.
Components are extracted in a depth-first way so that they match the hierarchy indices when going from top to bottom.
In most cases you will want to use the #deepSubComponentWith(ComponentContext,
Condition)
combinator.
Modifier and Type | Method and Description |
---|---|
static <any> |
deepSubComponentWith(ComponentContext c,
<any> inner)
Deprecated.
Verify that a component tree contains a component that matches the provided condition at any
level in its tree.
|
java.util.List<InspectableComponent> |
extract(Component input)
Deprecated.
|
static SubComponentDeepExtractor |
subComponentsDeeply(ComponentContext c)
Deprecated.
Extract sub components recursively, from a provided Component in a depth-first manner.
|
public java.util.List<InspectableComponent> extract(Component input)
public static SubComponentDeepExtractor subComponentsDeeply(ComponentContext c)
E.g.
assertThat(lithoView).extracting(subComponentsDeeply(c)).hasSize(2);
public static <any> deepSubComponentWith(ComponentContext c, <any> inner)
Note that asserting on indirect children breaks encapsulation and can lead to Change
Detector Tests[0]. Prefer SubComponentExtractor#subComponentWith(ComponentContext,
Condition)
over this whenever possible.
MyWrapperComponentSpec
that creates a Card
which contains a Text
for a
text
prop that your component accepts.
You want to ensure that the text truncation logic correctly applies to the text that sits
inside the card. Using SubComponentExtractor#subComponentWith(ComponentContext,
Condition)
won't work here as it will only be able to make assertions on the Card
but not the Text
sitting
inside.
mComponent = MyWrapperComponent.create(c).text("I'm Mr. Meeseeks! Look at me!").build();
assertThat(c, mComponent)
.has(deepSubComponentWith(c, textEquals("I'm Mr. Meeseeks!")))
.doesNotHave(deepSubComponentWith(c, text(containsString("wubba lubba dub dub"))));
For more applicable combinators, see below:c
- The ComponentContext used to create the tree.inner
- The condition that at least one sub component needs to match.
[0] https://testing.googleblog.com/2015/01/testing-on-toilet-change-detector-tests.html
org.hamcrest.CoreMatchers
,
ComponentConditions