diff options
author | Matan Kushner <hello@matchai.me> | 2019-07-27 18:25:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-27 18:25:13 -0400 |
commit | 0bc28c521df789d3aae5ceb541ee336aefa14340 (patch) | |
tree | 2f5aca63ac63e9970ff0587f5e4dc973d56cc0a9 /tests | |
parent | 95ce43ee70d51ce1181806b7c0f1ce623a618b4b (diff) |
feat: Add configuration for add_newline (#116)
- Replace TableExt with a Config trait that extends toml::value::Table
Add configuration for add_newline
- add_newline is a root-level configuration value. When set to false, the initial newline before the prompt is removed.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testsuite/common.rs | 5 | ||||
-rw-r--r-- | tests/testsuite/configuration.rs | 21 |
2 files changed, 24 insertions, 2 deletions
diff --git a/tests/testsuite/common.rs b/tests/testsuite/common.rs index ee817d8d5..a2bc10f12 100644 --- a/tests/testsuite/common.rs +++ b/tests/testsuite/common.rs @@ -9,8 +9,8 @@ lazy_static! { static ref EMPTY_CONFIG: PathBuf = MANIFEST_DIR.join("empty_config.toml"); } -/// Run an instance of starship -fn run_starship() -> process::Command { +/// Render the full starship prompt +pub fn render_prompt() -> process::Command { let mut command = process::Command::new("./target/debug/starship"); command @@ -22,6 +22,7 @@ fn run_starship() -> process::Command { command } +/// Render a specific starship module by name pub fn render_module(module_name: &str) -> process::Command { let mut command = process::Command::new("./target/debug/starship"); diff --git a/tests/testsuite/configuration.rs b/tests/testsuite/configuration.rs index 189ee3658..a9daefb63 100644 --- a/tests/testsuite/configuration.rs +++ b/tests/testsuite/configuration.rs @@ -32,3 +32,24 @@ fn disabled_module() -> io::Result<()> { Ok(()) } + +#[test] +fn add_newline_configuration() -> io::Result<()> { + // Start prompt with newline + let default_output = common::render_prompt().output()?; + let actual = String::from_utf8(default_output.stdout).unwrap(); + let expected = actual.trim_start(); + assert_ne!(actual, expected); + + // Start prompt without newline + let output = common::render_prompt() + .use_config(toml::toml! { + add_newline = false + }) + .output()?; + let actual = String::from_utf8(output.stdout).unwrap(); + let expected = actual.trim_start(); + assert_eq!(expected, actual); + + Ok(()) +} |