mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-28 12:46:48 -06:00
Fixes #1967 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
21 lines
731 B
Rust
21 lines
731 B
Rust
//! Typing a bare number into a Percentage-formatted cell enters it as a percent (issue #1967).
|
|
|
|
use gridcraft_engine::display::cell_text;
|
|
use serde_json::json;
|
|
|
|
fn enter(input: &str) -> String {
|
|
let mut s = gridcraft_engine::Session::new();
|
|
s.new_workbook();
|
|
s.execute("home.numberFormat", json!({"range": "A1", "format": "Percentage"})).unwrap();
|
|
s.execute("cell.set", json!({"cell": "A1", "input": input})).unwrap();
|
|
let d = s.doc().unwrap();
|
|
cell_text(&d.wb, d.wb.active().unwrap(), gridcraft_engine::core::CellRef::new(0, 0))
|
|
}
|
|
|
|
#[test]
|
|
fn bare_number_in_percent_cell_is_a_percent() {
|
|
assert_eq!(enter("3"), "3.00%");
|
|
assert_eq!(enter("0.03"), "3.00%");
|
|
assert_eq!(enter("3%"), "3.00%");
|
|
}
|