From 49df948de25d28601469e9ca993f33530989ebd0 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 22:55:49 +0100 Subject: v3.0.0: cursor-driven roulette felt with splits and corners; drop schema migrations; require 80x24 --- tests/client_ui.rs | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'tests/client_ui.rs') diff --git a/tests/client_ui.rs b/tests/client_ui.rs index 44febde..7969139 100644 --- a/tests/client_ui.rs +++ b/tests/client_ui.rs @@ -2,7 +2,7 @@ use std::time::Duration; use zagan_bet::client::ui::{ command_names, completion_lines, display_width, first_contact_lines, format_pong, help_lines, host_lines, input_cursor_column, lines_to_move_up, parse_bet_arg, record_history, - visual_line_count, + terminal_too_small, visual_line_count, MIN_COLUMNS, MIN_ROWS, }; #[test] @@ -255,3 +255,53 @@ fn hosts_without_a_fingerprint_are_never_merged() { 2 ); } + +#[test] +fn a_terminal_smaller_than_every_game_needs_is_refused() { + assert!(terminal_too_small(80, 24).is_none()); + assert!(terminal_too_small(120, 40).is_none()); + + assert!(terminal_too_small(79, 24).is_some()); + assert!(terminal_too_small(80, 23).is_some()); + + let message = terminal_too_small(40, 10).unwrap(); + assert!(message.contains("80x24")); + assert!(message.contains("40x10")); +} + +#[test] +fn the_roulette_felt_fits_the_minimum_terminal() { + use zagan_bet::client::games::roulette::{Cursor, RouletteGame, ROULETTE_BOARD_LINES}; + use zagan_bet::client::games::traits::{Game, GamePhase, GameState}; + use zagan_bet::roulette::Bets; + use std::collections::HashMap; + + let mut data = HashMap::new(); + data.insert("balance".to_string(), "1000".to_string()); + data.insert("chip".to_string(), "10".to_string()); + data.insert("status".to_string(), "place".to_string()); + data.insert("bets".to_string(), Bets::default().to_json()); + data.insert("cursor".to_string(), Cursor::Zero.encoded()); + let state = GameState { + game_type: "roulette".to_string(), + bet_amount: 0, + phase: GamePhase::WaitingToStart, + data, + }; + + let board = RouletteGame::new().render(&state); + let lines: Vec<&str> = board.split("\r\n").collect(); + assert_eq!(lines.len(), ROULETTE_BOARD_LINES); + assert_eq!(RouletteGame::new().render_lines(&state), ROULETTE_BOARD_LINES); + for line in lines { + assert!( + display_width(line) <= MIN_COLUMNS as usize, + "roulette line is {} wide: {line:?}", + display_width(line) + ); + } + assert!( + ROULETTE_BOARD_LINES + 4 <= MIN_ROWS as usize, + "the board must leave room for the prompt and a few transcript lines" + ); +} -- cgit v1.2.3