feat(test): diagnose failed effect assertions
This commit is contained in:
+19
-1
@@ -492,10 +492,28 @@ impl EffectInspector {
|
||||
})
|
||||
}
|
||||
|
||||
/// Assert that a generated target receives an HTML update containing text.
|
||||
/// Check that a generated target receives an HTML update containing text.
|
||||
/// req: test/001 req: dx/006
|
||||
pub fn updates_html_containing(&self, target: impl GeneratedTarget, needle: &str) -> bool {
|
||||
self.has_html_update_containing(target.__hemx_resource_id(), needle)
|
||||
}
|
||||
|
||||
/// Assert that a generated target receives an HTML update containing text.
|
||||
///
|
||||
/// Unlike wrapping [`Self::updates_html_containing`] in `assert!`, failures include the
|
||||
/// expected resource and payload fragment together with every actual effect operation.
|
||||
/// req: test/001 req: test/018 req: dx/006
|
||||
#[track_caller]
|
||||
pub fn assert_updates_html_containing(&self, target: impl GeneratedTarget, needle: &str) {
|
||||
let resource = target.__hemx_resource_id();
|
||||
assert!(
|
||||
self.has_html_update_containing(resource, needle),
|
||||
"expected an HTML update for {resource:?} containing {needle:?}; actual effects: {:#?}",
|
||||
self.batch.ops
|
||||
);
|
||||
}
|
||||
|
||||
fn has_html_update_containing(&self, resource: ResourceId, needle: &str) -> bool {
|
||||
self.batch.ops.iter().any(|op| {
|
||||
matches!(
|
||||
op,
|
||||
|
||||
Reference in New Issue
Block a user