1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-05 04:47:58 +00:00
starship/tests/nodejs.rs
2019-05-01 16:34:24 -04:00

63 lines
1.4 KiB
Rust

use ansi_term::Color;
use starship::segment::Segment;
use std::fs::{self, File};
use std::io;
use tempfile::TempDir;
mod common;
#[test]
#[ignore]
fn folder_with_package_json() -> io::Result<()> {
let dir = TempDir::new()?;
File::create(dir.path().join("package.json"))?;
let expected = format!(
"via {} ",
Segment::new("node")
.set_value("⬢ v12.0.0")
.set_style(Color::Green.bold())
);
let actual = common::render_module("nodejs", &dir.path());
assert_eq!(expected, actual);
Ok(())
}
#[test]
#[ignore]
fn folder_with_js_file() -> io::Result<()> {
let dir = TempDir::new()?;
File::create(dir.path().join("index.js"))?;
let expected = format!(
"via {} ",
Segment::new("node")
.set_value("⬢ v12.0.0")
.set_style(Color::Green.bold())
);
let actual = common::render_module("nodejs", &dir.path());
assert_eq!(expected, actual);
Ok(())
}
#[test]
#[ignore]
fn folder_with_node_modules() -> io::Result<()> {
let dir = TempDir::new()?;
let node_modules = dir.path().join("node_modules");
fs::create_dir_all(&node_modules)?;
let expected = format!(
"via {} ",
Segment::new("node")
.set_value("⬢ v12.0.0")
.set_style(Color::Green.bold())
);
let actual = common::render_module("nodejs", &dir.path());
assert_eq!(expected, actual);
Ok(())
}