mirror of
https://github.com/lsd-rs/lsd.git
synced 2026-04-21 02:45:58 +02:00
theme/test: 🔍 🔨 update tests to fit theme update
Signed-off-by: zwPapEr <zw.paper@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@ mod theme;
|
||||
|
||||
use theme::Theme;
|
||||
|
||||
use crate::flags::color::ThemeOption;
|
||||
pub use crate::flags::color::ThemeOption;
|
||||
|
||||
use ansi_term::{ANSIString, Colour, Style};
|
||||
use lscolors::{Indicator, LsColors};
|
||||
|
||||
@@ -210,6 +210,7 @@ color:
|
||||
# When "classic" is set, this is set to "never".
|
||||
# Possible values: never, auto, always
|
||||
when: auto
|
||||
theme: default
|
||||
|
||||
# == Date ==
|
||||
# This specifies the date format for the date column. The freeform format
|
||||
@@ -310,7 +311,7 @@ impl Config {
|
||||
mod tests {
|
||||
use super::Config;
|
||||
use crate::config_file;
|
||||
use crate::flags::color::ColorOption;
|
||||
use crate::flags::color::{ColorOption, ThemeOption};
|
||||
use crate::flags::icons::{IconOption, IconTheme};
|
||||
use crate::flags::layout::Layout;
|
||||
use crate::flags::size::SizeFlag;
|
||||
@@ -334,7 +335,8 @@ mod tests {
|
||||
.into()
|
||||
),
|
||||
color: Some(config_file::Color {
|
||||
when: ColorOption::Auto,
|
||||
when: Some(ColorOption::Auto),
|
||||
theme: Some(ThemeOption::Default)
|
||||
}),
|
||||
date: None,
|
||||
dereference: Some(false),
|
||||
|
||||
@@ -386,7 +386,7 @@ mod tests {
|
||||
},
|
||||
);
|
||||
let output = name.render(
|
||||
&Colors::new(color::Theme::NoColor),
|
||||
&Colors::new(color::ThemeOption::NoColor),
|
||||
&Icons::new(icon::Theme::NoIcon, " ".to_string()),
|
||||
&DisplayOption::FileName,
|
||||
);
|
||||
@@ -418,7 +418,7 @@ mod tests {
|
||||
);
|
||||
let output = name
|
||||
.render(
|
||||
&Colors::new(color::Theme::NoColor),
|
||||
&Colors::new(color::ThemeOption::NoColor),
|
||||
&Icons::new(icon::Theme::Fancy, " ".to_string()),
|
||||
&DisplayOption::FileName,
|
||||
)
|
||||
@@ -450,7 +450,7 @@ mod tests {
|
||||
);
|
||||
let output = name
|
||||
.render(
|
||||
&Colors::new(color::Theme::NoLscolors),
|
||||
&Colors::new(color::ThemeOption::NoLscolors),
|
||||
&Icons::new(icon::Theme::NoIcon, " ".to_string()),
|
||||
&DisplayOption::FileName,
|
||||
)
|
||||
@@ -486,7 +486,7 @@ mod tests {
|
||||
);
|
||||
let output = name
|
||||
.render(
|
||||
&Colors::new(color::Theme::NoColor),
|
||||
&Colors::new(color::ThemeOption::NoColor),
|
||||
&Icons::new(icon::Theme::NoIcon, " ".to_string()),
|
||||
&DisplayOption::FileName,
|
||||
)
|
||||
|
||||
@@ -249,7 +249,8 @@ mod test_color_option {
|
||||
fn test_from_config_always() {
|
||||
let mut c = Config::with_none();
|
||||
c.color = Some(config_file::Color {
|
||||
when: ColorOption::Always,
|
||||
when: Some(ColorOption::Always),
|
||||
theme: None,
|
||||
});
|
||||
|
||||
assert_eq!(Some(ColorOption::Always), ColorOption::from_config(&c));
|
||||
@@ -259,7 +260,8 @@ mod test_color_option {
|
||||
fn test_from_config_auto() {
|
||||
let mut c = Config::with_none();
|
||||
c.color = Some(config_file::Color {
|
||||
when: ColorOption::Auto,
|
||||
when: Some(ColorOption::Auto),
|
||||
theme: None,
|
||||
});
|
||||
assert_eq!(Some(ColorOption::Auto), ColorOption::from_config(&c));
|
||||
}
|
||||
@@ -268,7 +270,8 @@ mod test_color_option {
|
||||
fn test_from_config_never() {
|
||||
let mut c = Config::with_none();
|
||||
c.color = Some(config_file::Color {
|
||||
when: ColorOption::Never,
|
||||
when: Some(ColorOption::Never),
|
||||
theme: None,
|
||||
});
|
||||
assert_eq!(Some(ColorOption::Never), ColorOption::from_config(&c));
|
||||
}
|
||||
@@ -277,7 +280,8 @@ mod test_color_option {
|
||||
fn test_from_config_classic_mode() {
|
||||
let mut c = Config::with_none();
|
||||
c.color = Some(config_file::Color {
|
||||
when: ColorOption::Always,
|
||||
when: Some(ColorOption::Always),
|
||||
theme: None,
|
||||
});
|
||||
c.classic = Some(true);
|
||||
assert_eq!(Some(ColorOption::Never), ColorOption::from_config(&c));
|
||||
|
||||
@@ -53,7 +53,7 @@ impl Date {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::Date;
|
||||
use crate::color::{Colors, Theme};
|
||||
use crate::color::{Colors, ThemeOption};
|
||||
use crate::flags::{DateFlag, Flags};
|
||||
use ansi_term::Colour;
|
||||
use chrono::{DateTime, Duration, Local};
|
||||
@@ -108,7 +108,7 @@ mod test {
|
||||
.success();
|
||||
assert!(success, "failed to exec touch");
|
||||
|
||||
let colors = Colors::new(Theme::Default);
|
||||
let colors = Colors::new(ThemeOption::Default);
|
||||
let date = Date::from(&file_path.metadata().unwrap());
|
||||
let flags = Flags::default();
|
||||
|
||||
@@ -132,7 +132,7 @@ mod test {
|
||||
.success();
|
||||
assert!(success, "failed to exec touch");
|
||||
|
||||
let colors = Colors::new(Theme::Default);
|
||||
let colors = Colors::new(ThemeOption::Default);
|
||||
let date = Date::from(&file_path.metadata().unwrap());
|
||||
let flags = Flags::default();
|
||||
|
||||
@@ -156,7 +156,7 @@ mod test {
|
||||
.success();
|
||||
assert!(success, "failed to exec touch");
|
||||
|
||||
let colors = Colors::new(Theme::Default);
|
||||
let colors = Colors::new(ThemeOption::Default);
|
||||
let date = Date::from(&file_path.metadata().unwrap());
|
||||
let flags = Flags::default();
|
||||
|
||||
@@ -180,7 +180,7 @@ mod test {
|
||||
.success();
|
||||
assert!(success, "failed to exec touch");
|
||||
|
||||
let colors = Colors::new(Theme::Default);
|
||||
let colors = Colors::new(ThemeOption::Default);
|
||||
let date = Date::from(&file_path.metadata().unwrap());
|
||||
|
||||
let mut flags = Flags::default();
|
||||
@@ -205,7 +205,7 @@ mod test {
|
||||
.success();
|
||||
assert_eq!(true, success, "failed to exec touch");
|
||||
|
||||
let colors = Colors::new(Theme::Default);
|
||||
let colors = Colors::new(ThemeOption::Default);
|
||||
let date = Date::from(&file_path.metadata().unwrap());
|
||||
|
||||
let mut flags = Flags::default();
|
||||
|
||||
@@ -110,7 +110,7 @@ impl FileType {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::FileType;
|
||||
use crate::color::{Colors, Theme};
|
||||
use crate::color::{Colors, ThemeOption};
|
||||
use crate::meta::Meta;
|
||||
#[cfg(unix)]
|
||||
use crate::meta::Permissions;
|
||||
@@ -135,7 +135,7 @@ mod test {
|
||||
File::create(&file_path).expect("failed to create file");
|
||||
let meta = file_path.metadata().expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(Theme::NoLscolors);
|
||||
let colors = Colors::new(ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||
|
||||
assert_eq!(Colour::Fixed(184).paint("."), file_type.render(&colors));
|
||||
@@ -148,7 +148,7 @@ mod test {
|
||||
.expect("failed to get tempdir path");
|
||||
let metadata = tmp_dir.path().metadata().expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(Theme::NoLscolors);
|
||||
let colors = Colors::new(ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&metadata, None, &meta.permissions);
|
||||
|
||||
assert_eq!(Colour::Fixed(33).paint("d"), file_type.render(&colors));
|
||||
@@ -170,7 +170,7 @@ mod test {
|
||||
.symlink_metadata()
|
||||
.expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(Theme::NoLscolors);
|
||||
let colors = Colors::new(ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, Some(&meta), &Permissions::from(&meta));
|
||||
|
||||
assert_eq!(Colour::Fixed(44).paint("l"), file_type.render(&colors));
|
||||
@@ -192,7 +192,7 @@ mod test {
|
||||
.symlink_metadata()
|
||||
.expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(Theme::NoLscolors);
|
||||
let colors = Colors::new(ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, Some(&meta), &Permissions::from(&meta));
|
||||
|
||||
assert_eq!(Colour::Fixed(44).paint("l"), file_type.render(&colors));
|
||||
@@ -213,7 +213,7 @@ mod test {
|
||||
assert_eq!(true, success, "failed to exec mkfifo");
|
||||
let meta = pipe_path.metadata().expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(Theme::NoLscolors);
|
||||
let colors = Colors::new(ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||
|
||||
assert_eq!(Colour::Fixed(44).paint("|"), file_type.render(&colors));
|
||||
@@ -238,7 +238,7 @@ mod test {
|
||||
assert_eq!(true, success, "failed to exec mknod");
|
||||
let meta = char_device_path.metadata().expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(Theme::NoLscolors);
|
||||
let colors = Colors::new(ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||
|
||||
assert_eq!(Colour::Fixed(44).paint("c"), file_type.render(&colors));
|
||||
@@ -254,7 +254,7 @@ mod test {
|
||||
UnixListener::bind(&socket_path).expect("failed to create the socket");
|
||||
let meta = socket_path.metadata().expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(Theme::NoLscolors);
|
||||
let colors = Colors::new(ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||
|
||||
assert_eq!(Colour::Fixed(44).paint("s"), file_type.render(&colors));
|
||||
|
||||
@@ -192,7 +192,7 @@ mod test {
|
||||
File::create(&file_path).expect("failed to create file");
|
||||
let meta = file_path.metadata().expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(color::Theme::NoLscolors);
|
||||
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||
let name = Name::new(&file_path, file_type);
|
||||
|
||||
@@ -212,7 +212,7 @@ mod test {
|
||||
fs::create_dir(&dir_path).expect("failed to create the dir");
|
||||
let meta = Meta::from_path(&dir_path, false).unwrap();
|
||||
|
||||
let colors = Colors::new(color::Theme::NoLscolors);
|
||||
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||
|
||||
assert_eq!(
|
||||
Colour::Fixed(33).paint(" directory"),
|
||||
@@ -238,7 +238,7 @@ mod test {
|
||||
.expect("failed to get metas");
|
||||
let target_meta = symlink_path.metadata().ok();
|
||||
|
||||
let colors = Colors::new(color::Theme::NoLscolors);
|
||||
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, target_meta.as_ref(), &Permissions::from(&meta));
|
||||
let name = Name::new(&symlink_path, file_type);
|
||||
|
||||
@@ -266,7 +266,7 @@ mod test {
|
||||
.expect("failed to get metas");
|
||||
let target_meta = symlink_path.metadata().ok();
|
||||
|
||||
let colors = Colors::new(color::Theme::NoLscolors);
|
||||
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, target_meta.as_ref(), &Permissions::from(&meta));
|
||||
let name = Name::new(&symlink_path, file_type);
|
||||
|
||||
@@ -292,7 +292,7 @@ mod test {
|
||||
assert_eq!(true, success, "failed to exec mkfifo");
|
||||
let meta = pipe_path.metadata().expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(color::Theme::NoLscolors);
|
||||
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||
let name = Name::new(&pipe_path, file_type);
|
||||
|
||||
@@ -312,7 +312,7 @@ mod test {
|
||||
File::create(&file_path).expect("failed to create file");
|
||||
let meta = Meta::from_path(&file_path, false).unwrap();
|
||||
|
||||
let colors = Colors::new(color::Theme::NoColor);
|
||||
let colors = Colors::new(color::ThemeOption::NoColor);
|
||||
|
||||
assert_eq!(
|
||||
"file.txt",
|
||||
@@ -527,7 +527,7 @@ mod test {
|
||||
File::create(&file_path).expect("failed to create file");
|
||||
let meta = file_path.metadata().expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(color::Theme::NoLscolors);
|
||||
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||
let name = Name::new(&file_path, file_type);
|
||||
|
||||
@@ -540,7 +540,7 @@ mod test {
|
||||
File::create(&file_path).expect("failed to create file");
|
||||
let meta = file_path.metadata().expect("failed to get metas");
|
||||
|
||||
let colors = Colors::new(color::Theme::NoLscolors);
|
||||
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||
let name = Name::new(&file_path, file_type);
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ impl Size {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::Size;
|
||||
use crate::color::{Colors, Theme};
|
||||
use crate::color::{Colors, ThemeOption};
|
||||
use crate::flags::{Flags, SizeFlag};
|
||||
|
||||
#[test]
|
||||
@@ -325,7 +325,7 @@ mod test {
|
||||
let size = Size::new(42 * 1024); // 42 kilobytes
|
||||
let mut flags = Flags::default();
|
||||
flags.size = SizeFlag::Short;
|
||||
let colors = Colors::new(Theme::NoColor);
|
||||
let colors = Colors::new(ThemeOption::NoColor);
|
||||
|
||||
assert_eq!(size.render(&colors, &flags, Some(2)).to_string(), "42K");
|
||||
assert_eq!(size.render(&colors, &flags, Some(3)).to_string(), " 42K");
|
||||
|
||||
@@ -73,7 +73,7 @@ impl SymLink {
|
||||
mod tests {
|
||||
use super::SymLink;
|
||||
use crate::app;
|
||||
use crate::color::{Colors, Theme};
|
||||
use crate::color::{Colors, ThemeOption};
|
||||
use crate::config_file::Config;
|
||||
use crate::flags::Flags;
|
||||
|
||||
@@ -88,7 +88,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
format!("{}", " ⇒ /target"),
|
||||
link.render(
|
||||
&Colors::new(Theme::NoColor),
|
||||
&Colors::new(ThemeOption::NoColor),
|
||||
&Flags::configure_from(&matches, &Config::with_none()).unwrap()
|
||||
)
|
||||
.to_string()
|
||||
@@ -106,7 +106,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
format!("{}", " ⇒ /target"),
|
||||
link.render(
|
||||
&Colors::new(Theme::NoColor),
|
||||
&Colors::new(ThemeOption::NoColor),
|
||||
&Flags::configure_from(&matches, &Config::with_none()).unwrap()
|
||||
)
|
||||
.to_string()
|
||||
|
||||
Reference in New Issue
Block a user