nushell/crates/nu-command/tests/commands/nth.rs
John-Goff c13fe83784
Rename count to length (#3166)
* update docs to refer to length instead of count

* rename count to length

* change all occurrences of 'count' to 'length' in tests

* format length command
2021-03-14 10:46:40 +13:00

38 lines
860 B
Rust

#[test]
fn selects_a_row() {
Playground::setup("nth_test_1", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
ls
| sort-by name
| nth 0
| get name
"#
));
assert_eq!(actual.out, "arepas.txt");
});
}
#[test]
fn selects_many_rows() {
Playground::setup("nth_test_2", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
ls
| get name
| nth 1 0
| length
"#
));
assert_eq!(actual.out, "2");
});
}