From 9c1723d44f403d6b742136f7881515083b413cc2 Mon Sep 17 00:00:00 2001 From: cflmy Date: Sat, 21 Nov 2026 15:57:13 +0800 Subject: [PATCH] test(markdown): cover the removed syntax-selector key probe frontmatter::has_key() is what rejects marqdo_semantics/syntax directives; add unit coverage for a present key, an absent key and invalid YAML (which reports no key rather than panicking). Verified: cargo test -p marqdo-markdown and the workspace suite green (507 passed, 0 failed, 2 ignored). --- crates/marqdo-markdown/src/frontmatter.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/marqdo-markdown/src/frontmatter.rs b/crates/marqdo-markdown/src/frontmatter.rs index 1c23f20..3d9ed50 100644 --- a/crates/marqdo-markdown/src/frontmatter.rs +++ b/crates/marqdo-markdown/src/frontmatter.rs @@ -166,6 +166,18 @@ mod tests { assert!(fm.imports().is_err()); } + #[test] + fn detects_removed_syntax_selector_keys() { + let literal = "---\nmarqdo_semantics: 2\nimport:\n x: \"@x\"\n---\n"; + let fm = parse_literal(literal, Span::new(0, literal.len())); + assert!(fm.has_key("marqdo_semantics")); + assert!(!fm.has_key("syntax")); + assert!(fm.has_key("import")); + + let invalid = parse_literal("---\nimport: [unclosed\n---", Span::new(0, 24)); + assert!(!invalid.has_key("import"), "invalid YAML reports no key"); + } + #[test] fn import_shapes_are_validated() { let literal = "---\nimport: geometry\n---\n";