//! `Cli::apply_to` for `--sort size` with `-u gib`.

use clap::Parser;

use storageshower::cli::Cli;
use storageshower::prefs::Prefs;
use storageshower::types::{SortMode, UnitMode};

#[test]
fn sort_size_units_gib() {
    let cli = Cli::parse_from(["storageshower", "--sort", "size", "-u", "gib"]);
    let mut p = Prefs::default();
    cli.apply_to(&mut p);
    assert_eq!(p.sort_mode, SortMode::Size);
    assert_eq!(p.unit_mode, UnitMode::GiB);
}

#[test]
fn short_sort_size_gib_overrides_human() {
    let cli = Cli::parse_from(["storageshower", "-s", "size", "--units", "gib"]);
    let mut p = Prefs {
        unit_mode: UnitMode::Human,
        ..Default::default()
    };
    cli.apply_to(&mut p);
    assert_eq!(p.unit_mode, UnitMode::GiB);
}
