nushell/crates/nu-command/tests/commands/into_filesize.rs
Stefan Holderbach 656f707a0b
Clean up tests containing unnecessary cwd: tokens (#9692)
# Description
The working directory doesn't have to be set for those tests (or would
be the default anyways). When appropriate also remove calls to the
`pipeline()` function. In most places kept the diff minimal and only
removed the superfluous part to not pollute the blame view. With simpler
tests also simplified things to make them more readable overall (this
included removal of the raw string literal).

Work for #8670
2023-07-17 18:43:51 +02:00

71 lines
1.1 KiB
Rust

use nu_test_support::{nu, pipeline};
#[test]
fn into_filesize_int() {
let actual = nu!(r#"
1 | into filesize
"#);
assert!(actual.out.contains("1 B"));
}
#[test]
fn into_filesize_decimal() {
let actual = nu!(r#"
1.2 | into filesize
"#);
assert!(actual.out.contains("1 B"));
}
#[test]
fn into_filesize_str() {
let actual = nu!(r#"
'2000' | into filesize
"#);
assert!(actual.out.contains("2.0 KiB"));
}
#[test]
fn into_filesize_str_newline() {
let actual = nu!(pipeline(
r#"
"2000
" | into filesize
"#
));
assert!(actual.out.contains("2.0 KiB"));
}
#[test]
fn into_filesize_str_many_newlines() {
let actual = nu!(pipeline(
r#"
"2000
" | into filesize
"#
));
assert!(actual.out.contains("2.0 KiB"));
}
#[test]
fn into_filesize_filesize() {
let actual = nu!(r#"
3kib | into filesize
"#);
assert!(actual.out.contains("3.0 KiB"));
}
#[test]
fn into_filesize_negative_filesize() {
let actual = nu!(r#"
-3kib | into filesize
"#);
assert!(actual.out.contains("-3.0 KiB"));
}