Cotton code
125 lines · 3.8 KB · RustRaw
//! The quoted-reply stripper's cases. They travel with the shim and move with//! it to `cotton-store` when the shim does.use super::strip_quoted_reply;#[test]fn leaves_a_body_with_no_quoted_history_unchanged_byte_for_byte() {    let body = "Hi team,\n\nThe build is up. Please take a look.\n\nRegards,\nMeera";    assert_eq!(strip_quoted_reply(body), body);}#[test]fn preserves_crlf_and_a_mid_word_from_in_a_clean_body() {    let body = "From the data we read this morning, the totals look right.\r\nRegards,\r\nMeera";    // No header pair follows, so nothing is cut — returned untouched.    assert_eq!(strip_quoted_reply(body), body);}#[test]fn cuts_the_outlook_underscore_divider_and_everything_after_it() {    let body = [        "Hi Meera,",        "Please find our responses below.",        "",        "Regards,",        "Asha",        "Phno: +91 0123462250",        "",        "________________________________",        "From: Owner Example <owner@example.com>",        "Sent: Friday, August 28, 2026 11:34 AM",        "To: Asha Example <asha@example.com>",        "Subject: Re: Project update",        "",        "Hi Asha, everyone — the updated build is live ...",    ]    .join("\n");    assert_eq!(        strip_quoted_reply(&body),        "Hi Meera,\nPlease find our responses below.\n\nRegards,\nAsha\nPhno: +91 0123462250"    );}#[test]fn cuts_a_gmail_on_date_name_wrote_attribution_on_one_line() {    let body = [        "Thanks Asha, that clarifies it.",        "",        "On Wed, Aug 26, 2026 at 12:50 PM Asha Example <asha@example.com> wrote:",        "> Please use the query below to list the active rows.",        "> WITH ...",    ]    .join("\n");    assert_eq!(strip_quoted_reply(&body), "Thanks Asha, that clarifies it.");}#[test]fn cuts_a_gmail_attribution_that_wraps_across_lines_before_wrote() {    let body = [        "Got it, will revert.",        "",        "On Wed, 19 Aug 2026 at 6:33 PM, Asha Example",        "<asha@example.com>",        "wrote:",        "> After discussion with Vikram, here are the updated responses.",    ]    .join("\n");    assert_eq!(strip_quoted_reply(&body), "Got it, will revert.");}#[test]fn cuts_a_bare_quoted_block() {    let body = "Sounds good.\n\n> earlier message text\n> more quoted text";    assert_eq!(strip_quoted_reply(body), "Sounds good.");}#[test]fn cuts_an_outlook_original_message_banner() {    let body = "See below.\n\n-----Original Message-----\nFrom: someone\nSent: yesterday";    assert_eq!(strip_quoted_reply(body), "See below.");}#[test]fn cuts_an_outlook_header_block_with_no_divider_line() {    let body = [        "Quick note before the call.",        "",        "From: Owner Example <owner@example.com>",        "Sent: Thursday, August 20, 2026 2:06 PM",        "To: Asha",        "Subject: Re: Project update",    ]    .join("\n");    assert_eq!(strip_quoted_reply(&body), "Quick note before the call.");}#[test]fn does_not_cut_prose_that_merely_starts_with_on_monday() {    let body = "On Monday we should sync on the report query.\n\nThanks,\nMeera";    assert_eq!(strip_quoted_reply(body), body);}#[test]fn does_not_cut_a_line_that_only_mentions_a_from_address_inside_a_sentence() {    let body = "From: field aside, the header looked fine to me.\nRegards";    assert_eq!(strip_quoted_reply(body), body);}#[test]fn keeps_the_original_when_the_body_is_nothing_but_quoted_history() {    let body = "________________________________\nFrom: x\nSent: y";    assert_eq!(strip_quoted_reply(body), body);}#[test]fn is_idempotent() {    let body = "Reply text.\n\nOn Wed, Aug 26, 2026 Asha <t@x.io> wrote:\n> old";    let once = strip_quoted_reply(body);    assert_eq!(strip_quoted_reply(&once), once);}#[test]fn handles_an_empty_body() {    assert_eq!(strip_quoted_reply(""), "");}