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.
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-12 04:52:41 +00:00
1 parent b284052acc
commit 6fff5328eb
1 file changed
+13 -4
+13 -4
View File
@@ -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", &params).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", &params).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");
}