mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-24 13:47:38 +00:00
0bc28c521d
- 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.
56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
use ansi_term::Color;
|
||
use std::io;
|
||
|
||
use crate::common::{self, TestCommand};
|
||
|
||
#[test]
|
||
fn char_symbol_configuration() -> io::Result<()> {
|
||
let expected = format!("{} ", Color::Green.bold().paint("❯"));
|
||
|
||
let output = common::render_module("character")
|
||
.use_config(toml::toml! {
|
||
[character]
|
||
symbol = "❯"
|
||
})
|
||
.output()?;
|
||
let actual = String::from_utf8(output.stdout).unwrap();
|
||
assert_eq!(expected, actual);
|
||
|
||
Ok(())
|
||
}
|
||
|
||
#[test]
|
||
fn disabled_module() -> io::Result<()> {
|
||
let output = common::render_module("package")
|
||
.use_config(toml::toml! {
|
||
[package]
|
||
disabled = true
|
||
})
|
||
.output()?;
|
||
let actual = String::from_utf8(output.stdout).unwrap();
|
||
assert_eq!("", actual);
|
||
|
||
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(())
|
||
}
|