//! Tests for RFC normative statement parsers.

use super::parsers::{contains_normative, extract_strongest_keyword, parse_normative_statements};

#[test]
fn test_parse_jwt_statements() {
    // Sample JWT RFC text (simplified)
    let text = r#"
        4.1.3.  "aud" (Audience) Claim

        The "aud" (audience) claim identifies the recipients that the JWT is
        intended for.  Each principal intended to process the JWT MUST
        identify itself with a value in the audience claim.

        4.1.4.  "exp" (Expiration Time) Claim

        The "exp" (expiration time) claim identifies the expiration time on
        or after which the JWT MUST NOT be accepted for processing.

        The signature MUST be verified.
        The "alg" header parameter. Using "none" algorithm is forbidden.
    "#;

    let statements = parse_normative_statements(text, 7519);

    assert!(
        statements.iter().any(|s| s.subject.contains("audience_validation")),
        "Should find audience validation"
    );
    assert!(
        statements.iter().any(|s| s.subject.contains("expiry_validation")),
        "Should find expiry validation"
    );
    assert!(
        statements.iter().any(|s| s.subject.contains("signature_verification")),
        "Should find signature verification"
    );
}

#[test]
fn test_parse_tls_statements() {
    let text = r#"
        The certificate chain MUST be verified.
        cipher_suite selection is important.
    "#;

    let statements = parse_normative_statements(text, 8446);

    assert!(
        statements.iter().any(|s| s.subject.contains("cert_verification")),
        "Should find cert verification"
    );
}

#[test]
fn test_extract_strongest_keyword() {
    assert_eq!(extract_strongest_keyword("MUST NOT do this"), "MUST NOT");
    assert_eq!(extract_strongest_keyword("MUST do this"), "MUST");
    assert_eq!(extract_strongest_keyword("SHOULD do this"), "SHOULD");
    assert_eq!(extract_strongest_keyword("MUST do this and SHOULD do that"), "MUST");
}

#[test]
fn test_contains_normative() {
    let text = "The aud claim MUST be validated";
    assert!(contains_normative(text, "aud", "MUST"));
    assert!(!contains_normative(text, "aud", "SHOULD"));
}
