//! Golden-file coverage of the v1 scope line (README §"v1 scope"). //! //! Two halves, and the second is the point: //! //! - **IN** — every construct the v1 scope claims gets an element-tree snapshot (parser //! correctness) and a rendered-HTML snapshot (renderer correctness). //! - **OUT** — every construct the v1 scope explicitly excludes gets an assertion that it //! *degrades predictably*: parsed and ignored, content preserved where that is the //! honest fallback, never a crash and never a half-rendered artifact. //! //! The OUT half is the scope guardrail: it is what defends against this project's stated //! #1 risk, creeping back toward all-of-org. use camino::Utf8PathBuf; use orgo::model::Document; use orgo::parser::parse; use orgo::render::{render, Html, SyntectHighlighter}; use orgo::resolve::ResolvedDoc; fn parse_fixture(name: &str) -> Document { let path = Utf8PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("fixtures") .join(name); let source = std::fs::read_to_string(&path).expect("read fixture"); // A stable relative path keeps snapshots free of absolute machine paths. parse(Utf8PathBuf::from("fixtures").join(name).as_path(), &source).expect("parse fixture") } fn render_fixture(name: &str) -> String { let document = parse_fixture(name); let Html(html) = render(&ResolvedDoc { document }, &SyntectHighlighter::new()); html } // --------------------------------------------------------------------------- // IN: the constructs v1 promises to handle // --------------------------------------------------------------------------- #[test] fn headings_element_tree() { insta::assert_json_snapshot!(parse_fixture("headings.org").root); } #[test] fn headings_html() { insta::assert_snapshot!(render_fixture("headings.org")); } #[test] fn lists_element_tree() { insta::assert_json_snapshot!(parse_fixture("lists.org").root); } #[test] fn lists_html() { insta::assert_snapshot!(render_fixture("lists.org")); } #[test] fn blocks_html() { insta::assert_snapshot!(render_fixture("blocks.org")); } #[test] fn timestamps_element_tree() { insta::assert_json_snapshot!(parse_fixture("timestamps.org").root); } #[test] fn timestamps_html() { insta::assert_snapshot!(render_fixture("timestamps.org")); } #[test] fn images_html() { insta::assert_snapshot!(render_fixture("images.org")); } /// A TODO keyword is a whole word from the configured set, not a prefix: `TODOs are not /// a keyword` is a plain title. This is the boundary rule most likely to regress. #[test] fn todo_keyword_requires_a_word_boundary() { let html = render_fixture("headings.org"); assert!( html.contains("TODO "), "a real TODO keyword is marked up:\n{html}" ); assert!( !html.contains("TODO s are"), "`TODOs` must not be split into a keyword plus a title:\n{html}" ); } /// Nesting is by indentation, so a nested list must land *inside* its parent `
  • `. #[test] fn nested_list_is_nested_in_the_parent_item() { let html = render_fixture("lists.org"); assert!( html.contains("
  • outer item