Skip to content

Commit

Permalink
test the default config (#46)
Browse files Browse the repository at this point in the history
## changelog
- add `nu::value::from_nuon` to convert NUON text to a Nushell value
- read the default config file in the test to make sure it's the same as
the default implementation of `Config`
  • Loading branch information
amtoine authored Apr 15, 2024
1 parent 2894ed7 commit 709e72a
Show file tree
Hide file tree
Showing 4 changed files with 503 additions and 3 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ console = "0.15.7"
crossterm = "0.27.0"
nu-plugin = { git = "https://github.com/devyn/nushell", branch = "plugin-local-socket", package = "nu-plugin" }
nu-protocol = { git = "https://github.com/devyn/nushell", branch = "plugin-local-socket", package = "nu-protocol", features = ["plugin"] }
nu-parser = { git = "https://github.com/devyn/nushell", branch = "plugin-local-socket", package = "nu-parser" }
ratatui = "0.26.1"
url = "2.4.0"

Expand Down
13 changes: 13 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ mod tests {
use crossterm::event::KeyCode;
use nu_protocol::{record, Record, Value};

use crate::nu::value::from_nuon;

use super::{repr_keycode, Config};

#[test]
Expand Down Expand Up @@ -699,4 +701,15 @@ mod tests {
expected.keybindings.navigation.up = KeyCode::Char('x');
assert_eq!(Config::from_value(value), Ok(expected));
}

#[test]
fn same_as_default() {
assert_eq!(
Config::default(),
Config::from_value(
from_nuon(include_str!("../../examples/config/default.nuon")).unwrap()
)
.unwrap()
)
}
}
Loading

0 comments on commit 709e72a

Please sign in to comment.