test(tui): make snapshots independent of local settings
This commit is contained in:
1 parent
9d480f8bfb
commit
28c0731478
3 files changed
+12
-3
No files matched your search
+9
-2
@@ -77,6 +77,7 @@ impl Default for ThemeConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
fn load_theme_config() -> ThemeConfig {
|
||||
let path = super::get_config_path().join("theme.toml");
|
||||
ensure_theme_exists(&path);
|
||||
@@ -89,6 +90,7 @@ fn load_theme_config() -> ThemeConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
fn ensure_theme_exists(path: &Path) {
|
||||
if path.exists() {
|
||||
return;
|
||||
@@ -207,8 +209,13 @@ impl BorderStyleStore {
|
||||
}
|
||||
}
|
||||
|
||||
static THEME_CONFIG: LazyLock<RwLock<ThemeConfig>> =
|
||||
LazyLock::new(|| RwLock::new(load_theme_config()));
|
||||
static THEME_CONFIG: LazyLock<RwLock<ThemeConfig>> = LazyLock::new(|| {
|
||||
#[cfg(test)]
|
||||
let config = ThemeConfig::default();
|
||||
#[cfg(not(test))]
|
||||
let config = load_theme_config();
|
||||
RwLock::new(config)
|
||||
});
|
||||
|
||||
pub static THEME: LazyLock<ThemeStore> = LazyLock::new(|| {
|
||||
let config = THEME_CONFIG
|
||||
|
||||
@@ -133,7 +133,8 @@ fn install_summary_checks_selected_mod_release_not_picker_version() {
|
||||
})
|
||||
.unwrap();
|
||||
assert!(
|
||||
format!("{}", terminal.backend()).contains("Mod version may be incompatible with 26.3")
|
||||
format!("{}", terminal.backend())
|
||||
.contains("This mod version may be incompatible with 26.3")
|
||||
);
|
||||
assert!(!format!("{}", terminal.backend()).contains("Warning:"));
|
||||
}
|
||||
|
||||
@@ -1400,6 +1400,7 @@ mod tests {
|
||||
#[test]
|
||||
fn launcher_choices_toggles_and_maintenance_are_interactive() {
|
||||
let mut state = State::new();
|
||||
state.config.ui.image_protocol = ImageProtocol::Auto;
|
||||
state.selected = 2;
|
||||
state.handle_key(&KeyEvent::from(KeyCode::Enter));
|
||||
assert_eq!(state.choice_picker, Some(ChoicePicker::ImageProtocol));
|
||||
|
||||
Reference in new issue
Block a user