use katana_markdown_linter::{fix, implemented_rules, lint, LintOptions, RuleConfig};
use std::collections::HashMap;

fn only_rule(rule_id: &str) -> LintOptions {
    let mut options = LintOptions::default();
    for rule in implemented_rules() {
        options.rules.insert(
            rule.id.to_string(),
            RuleConfig {
                enabled: false,
                properties: HashMap::new(),
            },
        );
    }
    options.rules.insert(
        rule_id.to_string(),
        RuleConfig {
            enabled: true,
            properties: HashMap::new(),
        },
    );
    options
}

#[test]
fn md049_ignores_markers_that_start_and_end_in_separate_inline_code_spans() {
    let content = "Use `_ui.rs` for rendering and exclude it from coverage (`COVERAGE_IGNORE`).\n";
    let options = only_rule("MD049");

    let diagnostics = lint(content, &options).expect("lint should run");
    let fixed = fix(content, &options).expect("fix should run");

    assert!(diagnostics.is_empty());
    assert_eq!(fixed.content, content);
}

#[test]
fn md050_ignores_markers_that_start_and_end_in_separate_inline_code_spans() {
    let content =
        "Use `__ui.rs` for rendering and exclude it from coverage (`COVERAGE__IGNORE`).\n";
    let options = only_rule("MD050");

    let diagnostics = lint(content, &options).expect("lint should run");
    let fixed = fix(content, &options).expect("fix should run");

    assert!(diagnostics.is_empty());
    assert_eq!(fixed.content, content);
}
