From dfc8ff52169c2eadf957b036da62486c2ee354b4 Mon Sep 17 00:00:00 2001 From: batistalucasv Date: Mon, 23 Nov 2026 01:25:51 -0300 Subject: [PATCH] test(platform): restore rtf_target_prefers_text_rtf test (wordcraft#7317) --- crates/platform/src/clipboard/offer/tests.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/platform/src/clipboard/offer/tests.rs b/crates/platform/src/clipboard/offer/tests.rs index cd667d8f6..bb714d846 100644 --- a/crates/platform/src/clipboard/offer/tests.rs +++ b/crates/platform/src/clipboard/offer/tests.rs @@ -26,3 +26,15 @@ fn cf_html_offsets_delimit_the_fragment_bytes() { assert_eq!(&data[end_html..], b"\0", "EndHTML excludes the trailing NUL"); assert_eq!(end_html, data.len() - 1); } + +/// Ported from WordCraft (#7317). When multiple RTF targets are offered, text/rtf is preferred over application/rtf and text/richtext. +#[cfg(all(unix, not(target_os = "macos")))] +#[test] +fn rtf_target_prefers_text_rtf() { + use super::unix::rtf_target; + let names = |n: &[&str]| n.iter().map(|s| s.to_string()).collect::>(); + assert_eq!(rtf_target(&names(&["TARGETS", "text/richtext", "application/rtf", "text/rtf"])), Some("text/rtf")); + assert_eq!(rtf_target(&names(&["text/richtext", "UTF8_STRING"])), Some("text/richtext")); + assert_eq!(rtf_target(&names(&["text/html", "text/rtf;charset=x"])), None); + assert_eq!(rtf_target(&[]), None); +}