be-found.md
March 2, 2024 · View on GitHub
🏠 → Documentation → Built-In Functionality → beFound
Other Assertions: beFound ・ beMissing ・ containText ・ haveAttributes ・ haveCalled ・ haveCssClass ・ haveEmitted ・ haveState ・ haveStyle ・ haveText
This assertion checks if its associated target(s) are present in the template of the component-under-test. Its assertion can be further specified via a configuration parameter.
Signature
beFound(opts?: FindingOptions);
Interface FindingOptions
interface FindingOptions {
times?: number;
}
Example
class the {
static CongratulationsText() {
return get('p.congrats');
}
static CartItems() {
return getAll(CartItemComponent);
}
}
it('should show a congratulations text, if the user has birthday', () => {
When(host)
.has(state({ userHasBirthday: true }))
.expect(the.CongratulationsText)
.to(beFound());
});
it('should show as many cart items as the user has ordered products', () => {
When(host)
.has(state({ items: ['Product 1', 'Product 2', 'Product 3'] }))
.expect(the.CartItems)
.to(beFound({ times: 3 }));
});