2024-01-15 08:59:47 +00:00
|
|
|
use super::{fail_test, run_test_std};
|
2023-11-04 20:18:57 +00:00
|
|
|
use crate::tests::TestResult;
|
2022-12-12 18:46:25 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config() -> TestResult {
|
2023-11-04 20:18:57 +00:00
|
|
|
run_test_std(
|
2022-12-12 18:46:25 +00:00
|
|
|
r#"$env.config.footer_mode = 30; $env.config.footer_mode"#,
|
|
|
|
"30",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config_nested_ls() -> TestResult {
|
2023-11-04 20:18:57 +00:00
|
|
|
run_test_std(
|
|
|
|
r#"$env.config.ls.clickable_links = false; $env.config.ls.clickable_links"#,
|
2022-12-12 18:46:25 +00:00
|
|
|
"false",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config_nested_table() -> TestResult {
|
2023-11-04 20:18:57 +00:00
|
|
|
run_test_std(
|
|
|
|
r#"
|
|
|
|
$env.config.table.trim.methodology = wrapping
|
|
|
|
$env.config.table.trim.wrapping_try_keep_words = false
|
|
|
|
$env.config.table.trim.wrapping_try_keep_words
|
|
|
|
"#,
|
2022-12-12 18:46:25 +00:00
|
|
|
"false",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config_nested_menu() -> TestResult {
|
2023-11-04 20:18:57 +00:00
|
|
|
run_test_std(
|
|
|
|
r#"
|
|
|
|
$env.config.menus = [
|
|
|
|
{
|
|
|
|
name: menu
|
|
|
|
only_buffer_difference: true
|
|
|
|
marker: "M "
|
|
|
|
type: {}
|
|
|
|
style: {}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
$env.config.menus.0.type.columns = 3;
|
|
|
|
$env.config.menus.0.type.columns
|
|
|
|
"#,
|
2022-12-12 18:46:25 +00:00
|
|
|
"3",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config_nested_keybindings() -> TestResult {
|
2023-11-04 20:18:57 +00:00
|
|
|
run_test_std(
|
|
|
|
r#"
|
|
|
|
$env.config.keybindings = [
|
|
|
|
{
|
|
|
|
name: completion_previous
|
|
|
|
modifier: shift
|
|
|
|
keycode: backtab
|
|
|
|
mode: [ vi_normal, vi_insert ]
|
|
|
|
event: { send: menuprevious }
|
|
|
|
}
|
|
|
|
];
|
|
|
|
$env.config.keybindings.0.keycode = 'char_x';
|
|
|
|
$env.config.keybindings.0.keycode
|
|
|
|
"#,
|
2022-12-12 18:46:25 +00:00
|
|
|
"char_x",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config_nested_color_nested() -> TestResult {
|
2023-11-04 20:18:57 +00:00
|
|
|
run_test_std(
|
2022-12-12 18:46:25 +00:00
|
|
|
r#"$env.config.color_config.shape_flag = 'cyan'; $env.config.color_config.shape_flag"#,
|
|
|
|
"cyan",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config_nested_completion() -> TestResult {
|
2023-11-04 20:18:57 +00:00
|
|
|
run_test_std(
|
2022-12-12 18:46:25 +00:00
|
|
|
r#"$env.config.completions.external.enable = false; $env.config.completions.external.enable"#,
|
|
|
|
"false",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config_nested_history() -> TestResult {
|
2023-11-04 20:18:57 +00:00
|
|
|
run_test_std(
|
2022-12-12 18:46:25 +00:00
|
|
|
r#"$env.config.history.max_size = 100; $env.config.history.max_size"#,
|
|
|
|
"100",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config_nested_filesize() -> TestResult {
|
2023-11-04 20:18:57 +00:00
|
|
|
run_test_std(
|
2022-12-12 18:46:25 +00:00
|
|
|
r#"$env.config.filesize.format = 'kb'; $env.config.filesize.format"#,
|
|
|
|
"kb",
|
|
|
|
)
|
|
|
|
}
|
2024-01-15 08:59:47 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn mutate_nu_config_plugin() -> TestResult {
|
|
|
|
run_test_std(
|
|
|
|
r#"
|
|
|
|
$env.config.plugins = {
|
|
|
|
config: {
|
|
|
|
key1: value
|
|
|
|
key2: other
|
|
|
|
}
|
|
|
|
};
|
|
|
|
$env.config.plugins.config.key1 = 'updated'
|
|
|
|
$env.config.plugins.config.key1
|
|
|
|
"#,
|
|
|
|
"updated",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn reject_nu_config_plugin_non_record() -> TestResult {
|
|
|
|
fail_test(r#"$env.config.plugins = 5"#, "should be a record")
|
|
|
|
}
|