From 6fff5328eb59a5fdff5d91df44034212cc07e670 Mon Sep 17 00:00:00 2001 From: ".CooCoo" Date: Wed, 11 Nov 2026 20:52:41 -0800 Subject: [PATCH] Tests: type.align refusal cases name the check that refuses each (#2662) Follows #2645. Its test said a misspelled key used to apply Align Left. Only empty params and a bare string did; the parameter check already refused a misspelled key, and the value parser refused an unknown value. Each case now asserts the refusal message it gets. --- crates/engine/src/cmd/text/format.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/text/format.rs b/crates/engine/src/cmd/text/format.rs index 10bce4841..64f3c17c7 100644 --- a/crates/engine/src/cmd/text/format.rs +++ b/crates/engine/src/cmd/text/format.rs @@ -1080,8 +1080,9 @@ mod align_param_tests { use crate::Session; - /// `type.align` with no `align` applied Align Left, so a script that misspelled the key - /// (`{"alignment": "center"}`) changed the paragraph to the opposite of what it asked for. + /// `type.align` with empty params (`{}`) or a bare value (`"center"`) applied Align Left. + /// A misspelled key and an unknown value were already refused, and each case checks which + /// check refuses it. #[test] fn type_align_without_a_value_is_refused_and_changes_nothing() { let mut s = Session::new(); @@ -1092,8 +1093,16 @@ mod align_param_tests { let align = |s: &mut Session| s.execute("type.selectionAttrs", &json!({})).unwrap()["para"]["align"].clone(); assert_eq!(align(&mut s), json!("right")); let steps = s.doc().unwrap().history.undo.len(); - for params in [json!({}), json!({"alignment": "center"}), json!("center"), json!({"align": "middle"})] { - assert!(s.execute("type.align", ¶ms).is_err(), "{params}"); + // `{}` and `"center"` reach the command without `align`. The parameter check refuses + // `{"alignment": …}` and the value parser refuses `"middle"`. + for (params, refusal) in [ + (json!({}), "`align` required"), + (json!("center"), "`align` required"), + (json!({"alignment": "center"}), "unknown parameter `alignment`"), + (json!({"align": "middle"}), "middle"), + ] { + let err = s.execute("type.align", ¶ms).unwrap_err().to_string(); + assert!(err.contains(refusal), "{params}: {err}"); assert_eq!(align(&mut s), json!("right"), "{params}"); assert_eq!(s.doc().unwrap().history.undo.len(), steps, "{params}: no undo step"); }