test(build): close authoring diagnostic mutants
Assert exact selector-target and unknown-attribute InvalidData diagnostics and prove invalid scope IDs fail closed in unkeyed-loop diagnostics. req: locality/001 req: locality/002 req: htmx_equivalents/003 req: convention/009 req: diagnostics/002 req: test/021
This commit is contained in:
+26
-28
@@ -3754,6 +3754,14 @@ fn main() {{
|
||||
assert!(is_inside_keyed_for(&surface, nested_scope));
|
||||
assert!(!is_inside_keyed_for(&surface, sibling_scope));
|
||||
assert!(!is_inside_keyed_for(&surface, ScopeId(u32::MAX)));
|
||||
assert!(unkeyed_generated_target_diagnostic_for_scope(
|
||||
&surface,
|
||||
ScopeId(u32::MAX),
|
||||
Path::new("todo.heml"),
|
||||
"slot",
|
||||
"missing",
|
||||
)
|
||||
.is_none());
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
@@ -3777,24 +3785,21 @@ fn main() {{
|
||||
let out = base.join("out");
|
||||
let _ = std::fs::remove_dir_all(&base);
|
||||
std::fs::create_dir_all(&templates).unwrap();
|
||||
std::fs::write(templates.join("target.heml"), template).unwrap();
|
||||
let template_path = templates.join("target.heml");
|
||||
std::fs::write(&template_path, template).unwrap();
|
||||
|
||||
let err = app()
|
||||
.template_dir(&templates)
|
||||
.out_dir(&out)
|
||||
.run()
|
||||
.unwrap_err();
|
||||
assert!(
|
||||
err.to_string().contains(attr),
|
||||
"missing attr in diagnostic: {err}"
|
||||
);
|
||||
assert!(
|
||||
err.to_string().contains("selector-style targeting"),
|
||||
"missing selector diagnostic: {err}"
|
||||
);
|
||||
assert!(
|
||||
err.to_string().contains("data-hemx-slot"),
|
||||
"missing suggested slot fix: {err}"
|
||||
assert_eq!(err.kind(), io::ErrorKind::InvalidData);
|
||||
assert_eq!(
|
||||
err.to_string(),
|
||||
format!(
|
||||
"{}: `{attr}` is selector-style targeting; hemx uses generated resources instead. Add data-hemx-slot to the local element and return an effect for that generated slot.",
|
||||
template_path.display()
|
||||
)
|
||||
);
|
||||
|
||||
let _ = std::fs::remove_dir_all(&base);
|
||||
@@ -3809,8 +3814,9 @@ fn main() {{
|
||||
let out = base.join("out");
|
||||
let _ = std::fs::remove_dir_all(&base);
|
||||
std::fs::create_dir_all(&templates).unwrap();
|
||||
let template_path = templates.join("typo.heml");
|
||||
std::fs::write(
|
||||
templates.join("typo.heml"),
|
||||
&template_path,
|
||||
r#"<button data-hemx-handle="save" data-hemx-pendig-class="busy">Save</button>"#,
|
||||
)
|
||||
.unwrap();
|
||||
@@ -3820,21 +3826,13 @@ fn main() {{
|
||||
.out_dir(&out)
|
||||
.run()
|
||||
.unwrap_err();
|
||||
assert!(
|
||||
err.to_string().contains("data-hemx-pendig-class"),
|
||||
"missing attr in diagnostic: {err}"
|
||||
);
|
||||
assert!(
|
||||
err.to_string().contains("unknown hemx attribute"),
|
||||
"missing unknown-attr diagnostic: {err}"
|
||||
);
|
||||
assert!(
|
||||
err.to_string().contains("check the spelling"),
|
||||
"missing spelling guidance: {err}"
|
||||
);
|
||||
assert!(
|
||||
err.to_string().contains("non-hemx data-*"),
|
||||
"missing app metadata guidance: {err}"
|
||||
assert_eq!(err.kind(), io::ErrorKind::InvalidData);
|
||||
assert_eq!(
|
||||
err.to_string(),
|
||||
format!(
|
||||
"{}: unknown hemx attribute `data-hemx-pendig-class`; check the spelling or use a non-hemx data-* attribute for app-specific metadata",
|
||||
template_path.display()
|
||||
)
|
||||
);
|
||||
|
||||
let _ = std::fs::remove_dir_all(&base);
|
||||
|
||||
Reference in New Issue
Block a user