use super::*;
#[test]
fn profile_config_reads_kick_timer_as_auto_start() {
let toml = "kick_timer = true\n";
let cfg: ProfileConfig = toml::from_str(toml).expect("parse old config");
assert!(cfg.auto_start);
}
#[test]
fn profile_config_reads_auto_start_directly() {
let toml = "auto_start = true\n";
let cfg: ProfileConfig = toml::from_str(toml).expect("parse new config");
assert!(cfg.auto_start);
}
#[test]
fn profile_name_is_serde_transparent() {
let toml = r#"active_profile = "work"
profiles = ["work", "play"]
fallback_chain = ["work"]
"#;
let state: AppState = toml::from_str(toml).expect("parse bare-string state");
assert_eq!(state.active_profile.as_deref(), Some("work"));
assert_eq!(state.profiles, ["work", "play"]);
assert_eq!(state.fallback_chain, ["work"]);
let rendered = toml::to_string_pretty(&state).expect("render state");
let reparsed: AppState = toml::from_str(&rendered).expect("reparse");
assert_eq!(reparsed.active_profile.as_deref(), Some("work"));
assert_eq!(reparsed.profiles, ["work", "play"]);
assert_eq!(reparsed.fallback_chain, ["work"]);
assert!(
rendered.contains("active_profile = \"work\""),
"active_profile must render as a bare string, got:\n{rendered}"
);
assert!(
rendered.contains("\"work\"") && rendered.contains("\"play\""),
"profile names must render as bare strings, got:\n{rendered}"
);
assert!(
!rendered.contains("ProfileName") && !rendered.contains("[profiles."),
"no newtype wrapper may appear on disk, got:\n{rendered}"
);
#[derive(serde::Serialize, Default)]
struct BareState {
active_profile: Option<String>,
profiles: Vec<String>,
fallback_chain: Vec<String>,
wrap_off: bool,
}
let control = BareState {
active_profile: Some("work".to_string()),
profiles: vec!["work".to_string(), "play".to_string()],
fallback_chain: vec!["work".to_string()],
..Default::default()
};
assert_eq!(
rendered,
toml::to_string_pretty(&control).expect("render control"),
"ProfileName AppState must serialize byte-identically to a String one"
);
}