Reject invalid New Art Basic parameters

This commit is contained in:
dotCooCoo
2026-11-06 11:15:35 +07:00
committed by bflatastic
parent 3c7d9e1f90
commit 8a730bab6b
3 changed files with 17 additions and 2 deletions
+14
View File
@@ -29,6 +29,20 @@ fn undo_len(s: &Session) -> usize {
s.doc().unwrap().history.undo.len()
}
#[test]
fn invalid_new_art_basic_parameters_keep_the_preference_unchanged() {
let mut s = session();
let undo = undo_len(&s);
for params in [json!({"on": "false"}), json!({"on": 1})] {
assert!(s.execute("appearance.setNewArtBasic", &params).is_err(), "accepted {params}");
assert!(s.prefs.new_art_basic, "changed the preference for {params}");
assert_eq!(undo_len(&s), undo, "recorded undo for {params}");
}
// Left out, or null as for every command, it toggles.
assert_eq!(s.execute("appearance.setNewArtBasic", &json!(null)).unwrap(), json!({"on": false}));
assert_eq!(s.execute("appearance.setNewArtBasic", &json!({"on": null})).unwrap(), json!({"on": true}));
}
#[test]
fn stroke_options_set_with_nothing_selected_carry_to_the_next_object() {
let mut s = session();