yog 0.0.1

yog: a balls-oriented session manager for lernie loops (egui frontend)
Documentation
//! Table tests for the pure ยง11 keymap: every key maps to its intent, every
//! digit to its tab (or nothing), and the tab helpers round-trip.

use super::*;

#[test]
fn arrows_step_the_roster() {
    assert_eq!(keymap(Key::Up), Some(KeyAction::RosterPrev));
    assert_eq!(keymap(Key::Down), Some(KeyAction::RosterNext));
}

#[test]
fn digits_one_through_five_select_the_inspector_tabs() {
    let want = [
        (1, InspectorTab::Transcript),
        (2, InspectorTab::Steps),
        (3, InspectorTab::Inbox),
        (4, InspectorTab::Files),
        (5, InspectorTab::Config),
    ];
    for (n, tab) in want {
        assert_eq!(keymap(Key::Digit(n)), Some(KeyAction::Tab(tab)));
        assert_eq!(InspectorTab::from_digit(n), Some(tab));
    }
}

#[test]
fn digits_outside_one_through_five_are_unbound() {
    assert_eq!(InspectorTab::from_digit(0), None);
    for n in 6..=9 {
        assert_eq!(keymap(Key::Digit(n)), None, "digit {n} binds no tab");
    }
}

#[test]
fn all_lists_the_five_tabs_in_order_and_labels_each() {
    let all = InspectorTab::all();
    assert_eq!(all.len(), 5);
    assert_eq!(all[0], InspectorTab::default(), "Transcript is the default");
    let labels: Vec<&str> = all.iter().map(|t| t.label()).collect();
    assert_eq!(
        labels,
        vec!["Transcript", "Steps", "Inbox", "Files", "Config"]
    );
    // The digit map and `all` agree: `all[i]` is digit `i + 1`.
    for (i, tab) in all.into_iter().enumerate() {
        assert_eq!(InspectorTab::from_digit(i as u8 + 1), Some(tab));
    }
}