nushell/crates/nu-command/tests/commands/into_filesize.rs
Darren Schroeder ece1e43238
fix into filesize tests and filesize (#932)
* fix into filesize tests and filesize

* tweaks

* added span back for like the 10th time

* Update filesize.rs

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
2022-02-04 13:26:08 -06:00

77 lines
1.2 KiB
Rust

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