pub struct Testable { /* private fields */ }Expand description
A component mounted for a test, with its latest markup, snapshot, and effects.
Implementations§
Source§impl Testable
impl Testable
Sourcepub fn mount(
registry: Arc<ComponentRegistry>,
name: &str,
params: Params,
) -> Result<Self>
pub fn mount( registry: Arc<ComponentRegistry>, name: &str, params: Params, ) -> Result<Self>
Mounts name with params, as livewire(name, params) does in a page.
§Errors
Fails when the component is not registered in registry, when the caller’s component fails
to mount, or when its view renders no single root element.
Sourcepub async fn set(&mut self, path: &str, value: Value) -> Result<&mut Self>
pub async fn set(&mut self, path: &str, value: Value) -> Result<&mut Self>
Sets one wire-public field, by its name or by a dotted path, and renders again.
§Errors
Fails when the field is unknown or locked, or when the value does not fit its type.
Sourcepub async fn call(&mut self, method: &str, params: Params) -> Result<&mut Self>
pub async fn call(&mut self, method: &str, params: Params) -> Result<&mut Self>
Calls one action, and applies its effects.
§Errors
Fails when the action is unknown, when a parameter does not fit its type, or when the action itself reports an error.
Sourcepub async fn refresh(&mut self) -> Result<&mut Self>
pub async fn refresh(&mut self) -> Result<&mut Self>
Calls $refresh, which re-renders the component without running a method.
§Errors
Fails as Testable::call does.
Sourcepub fn effects(&self) -> &Map<String, Value>
pub fn effects(&self) -> &Map<String, Value>
The effects of the latest update, or of the mount when no update ran.
Sourcepub fn returns(&self) -> Value
pub fn returns(&self) -> Value
The values the latest update’s calls returned, one slot per call.
Sourcepub fn assert_see(&self, text: &str)
pub fn assert_see(&self, text: &str)
Asserts that the markup shows text, ignoring the markers a rendered block leaves.
§Panics
Panics with the markup when text does not appear.
Sourcepub fn assert_dont_see(&self, text: &str)
pub fn assert_dont_see(&self, text: &str)
Asserts that the markup does not show text, ignoring the markers a rendered block leaves.
§Panics
Panics with the markup when text does appear.
Sourcepub fn assert_set(&self, path: &str, expected: Value)
pub fn assert_set(&self, path: &str, expected: Value)
Asserts a wire-public field’s value, by its name or by a dotted path.
§Panics
Panics when the field holds another value or is absent from the snapshot.
Sourcepub fn assert_dispatched(&self, event: &str)
pub fn assert_dispatched(&self, event: &str)
Asserts that the latest update dispatched event to the browser.
§Panics
Panics when no dispatch effect names event.
Sourcepub fn assert_redirected_to(&self, url: &str)
pub fn assert_redirected_to(&self, url: &str)
Asserts that the latest update asked the browser to leave, either to url or anywhere.
§Panics
Panics when no redirect effect names that URL.
Sourcepub async fn assert_update_fails(
&mut self,
updates: Map<String, Value>,
) -> LivewireError
pub async fn assert_update_fails( &mut self, updates: Map<String, Value>, ) -> LivewireError
Asserts that the update failed, without panicking on the error, for a test of a guard.
§Panics
Panics when the update succeeded.