use dirigent_fermata::core::extract::{extract_path_candidates, Confidence};

#[test]
fn extracts_absolute_unix_path() {
    let s = "the file is at /home/user/.env and was modified";
    let cs = extract_path_candidates(s);
    assert!(cs.iter().any(|c| c.text == "/home/user/.env" && c.confidence == Confidence::High));
}

#[test]
fn extracts_absolute_windows_path() {
    let s = r"see C:\Users\me\secret.toml for details";
    let cs = extract_path_candidates(s);
    assert!(cs.iter().any(|c| c.text == r"C:\Users\me\secret.toml" && c.confidence == Confidence::High));
}

#[test]
fn extracts_relative_with_separator() {
    let s = "modified src/lib.rs and tests/foo.rs";
    let cs = extract_path_candidates(s);
    let texts: Vec<_> = cs.iter().map(|c| c.text.as_str()).collect();
    assert!(texts.contains(&"src/lib.rs"));
    assert!(texts.contains(&"tests/foo.rs"));
}

#[test]
fn bare_filename_with_extension_is_low_confidence() {
    let s = "open README.md please";
    let cs = extract_path_candidates(s);
    let r = cs.iter().find(|c| c.text == "README.md").unwrap();
    assert_eq!(r.confidence, Confidence::Low);
}

#[test]
fn ignores_pure_words() {
    let s = "the quick brown fox";
    let cs = extract_path_candidates(s);
    assert!(cs.is_empty());
}
