a789495a98
FreeBSD Smoke / FreeBSD Smoke (x86_64) (push) Has been cancelled
CI / Quality Guardrails (push) Has been cancelled
CI / Build & Test (macos-latest) (push) Has been cancelled
CI / Build & Test (ubuntu-latest) (push) Has been cancelled
CI / Build & Test (windows-latest) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / PowerShell Syntax (push) Has been cancelled
CI / Windows Cross-Target Check (Linux) (push) Has been cancelled
39 lines
1.4 KiB
Rust
39 lines
1.4 KiB
Rust
#[test]
|
|
fn launch_hotkeys_config_round_trips_toml() {
|
|
use jcode_config_types::{LaunchHotkeyEntry, LaunchHotkeysConfig};
|
|
#[derive(serde::Serialize, serde::Deserialize, Default)]
|
|
#[serde(default)]
|
|
struct W {
|
|
launch_hotkeys: LaunchHotkeysConfig,
|
|
}
|
|
let w = W {
|
|
launch_hotkeys: LaunchHotkeysConfig {
|
|
enabled: Some(true),
|
|
imported: true,
|
|
entries: vec![
|
|
LaunchHotkeyEntry {
|
|
chord: "cmd+;".into(),
|
|
dir: "/Users/jeremy/jcode-github".into(),
|
|
label: "jcode-github".into(),
|
|
self_dev: false,
|
|
},
|
|
LaunchHotkeyEntry {
|
|
chord: "cmd+'".into(),
|
|
dir: "$HOME".into(),
|
|
label: "home".into(),
|
|
self_dev: false,
|
|
},
|
|
],
|
|
},
|
|
};
|
|
let toml = toml::to_string(&w).unwrap();
|
|
let back: W = toml::from_str(&toml).unwrap();
|
|
assert_eq!(back.launch_hotkeys.entries.len(), 2);
|
|
assert_eq!(back.launch_hotkeys.enabled, Some(true));
|
|
// Empty config (no section) -> defaults: no entries, enabled None.
|
|
let empty: W = toml::from_str("").unwrap();
|
|
assert!(empty.launch_hotkeys.entries.is_empty());
|
|
assert_eq!(empty.launch_hotkeys.enabled, None);
|
|
assert!(!empty.launch_hotkeys.imported);
|
|
}
|