2019-07-02 22:12:53 +02:00
|
|
|
|
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("❯"));
|
|
|
|
|
|
2019-07-19 22:18:52 +02:00
|
|
|
|
let output = common::render_module("character")
|
2019-07-02 22:12:53 +02:00
|
|
|
|
.use_config(toml::toml! {
|
2019-07-19 22:18:52 +02:00
|
|
|
|
[character]
|
2019-07-02 22:12:53 +02:00
|
|
|
|
symbol = "❯"
|
|
|
|
|
})
|
|
|
|
|
.output()?;
|
|
|
|
|
let actual = String::from_utf8(output.stdout).unwrap();
|
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 00:25:13 +02:00
|
|
|
|
#[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(())
|
|
|
|
|
}
|