use super::super::{CHAT_FLOOR, SIDE_FLOOR, widths};
use super::{TAIL_FLOOR, rows, shown, span};
const LINE: f32 = 16.0;
const CHROME: f32 = 40.0;
#[test]
fn a_seat_that_has_dragged_nothing_is_shown_exactly_what_the_yield_gives_it() {
for window in [400.0, 700.0, 900.0, 1020.0, 1440.0, 2560.0_f32] {
let (was, is) = (shown(window, None), widths(window));
assert!((was - is).abs() < f32::EPSILON, "at {window} points");
}
}
#[test]
fn an_edge_the_operator_dragged_is_the_width_the_pane_is_shown_at() {
let held = shown(1440.0, Some(200.0));
assert!((held - 200.0).abs() < f32::EPSILON, "{held}");
}
#[test]
fn a_window_too_narrow_for_the_drag_narrows_the_pane_and_not_the_fact() {
let held = Some(600.0);
let list = shown(900.0, held);
assert!(list < 600.0, "the window cannot afford 600: {list}");
let whole = shown(1440.0, held);
assert!(
(whole - 600.0).abs() < f32::EPSILON,
"and the window that can shows it whole: {whole}"
);
}
#[test]
fn an_edge_dragged_to_the_frame_still_leaves_the_conversation_its_floor() {
let list = shown(1440.0, Some(2000.0));
assert!(
1440.0 - list >= CHAT_FLOOR,
"the conversation is under its floor: {list} of 1440"
);
}
#[test]
fn a_window_with_no_room_at_all_holds_the_pane_at_its_own_floor() {
assert_eq!(span(200.0), (SIDE_FLOOR, SIDE_FLOOR));
let floored = shown(200.0, Some(50.0));
assert!((floored - SIDE_FLOOR).abs() < f32::EPSILON, "{floored}");
}
#[test]
fn the_cap_on_the_pane_is_what_the_conversation_leaves() {
assert_eq!(span(1440.0), (SIDE_FLOOR, 1440.0 - CHAT_FLOOR));
}
#[test]
fn the_rows_are_the_nearest_whole_line_to_where_the_edge_was_dropped() {
let window = 900.0;
assert_eq!(rows(CHROME + 3.0 * LINE, CHROME, LINE, window), 3);
assert_eq!(rows(CHROME + 3.4 * LINE, CHROME, LINE, window), 3);
assert_eq!(rows(CHROME + 3.6 * LINE, CHROME, LINE, window), 4);
}
#[test]
fn an_edge_dragged_to_the_foot_of_the_window_still_leaves_one_row() {
for asked in [CHROME, 0.0, -400.0_f32] {
assert_eq!(rows(asked, CHROME, LINE, 900.0), 1, "asked {asked}");
}
}
#[test]
fn an_edge_dragged_over_the_whole_window_leaves_the_tail_its_floor() {
let window = 900.0;
let most = rows(window * 2.0, CHROME, LINE, window);
assert!(
CHROME + f32::from(most) * LINE <= window - TAIL_FLOOR,
"{most} rows is past the tail's floor"
);
assert!(most > 1, "and there is room for more than one: {most}");
}
#[test]
fn a_window_smaller_than_its_own_floors_still_answers_one_row() {
assert_eq!(rows(400.0, CHROME, LINE, TAIL_FLOOR), 1);
}