From 4cb22a6a4570855a3ceace826dae4e79975d1015 Mon Sep 17 00:00:00 2001 From: Sam Hedin Date: Sat, 28 Mar 2020 19:45:34 +0100 Subject: [PATCH] Add tests for headers command --- crates/nu-cli/tests/commands/headers.rs | 18 +++++++++++++++++- crates/nu-cli/tests/commands/mod.rs | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/nu-cli/tests/commands/headers.rs b/crates/nu-cli/tests/commands/headers.rs index 2a84625171..bc566ea4e6 100644 --- a/crates/nu-cli/tests/commands/headers.rs +++ b/crates/nu-cli/tests/commands/headers.rs @@ -1,7 +1,22 @@ use nu_test_support::{nu, pipeline}; #[test] -fn headers() { +fn headers_uses_first_row_as_header() { + let actual = nu!( + cwd: "tests/fixtures/formats", pipeline( + r#" + open sample_headers.xlsx + | get Sheet1 + | headers + | get header0 + | from-json"# + )); + + assert_eq!(actual, "r1c0r2c0") +} + +#[test] +fn headers_adds_missing_column_name() { let actual = nu!( cwd: "tests/fixtures/formats", pipeline( r#" @@ -11,5 +26,6 @@ fn headers() { | get Column1 | from-json"# )); + assert_eq!(actual, "r1c1r2c1") } diff --git a/crates/nu-cli/tests/commands/mod.rs b/crates/nu-cli/tests/commands/mod.rs index 49826b1f37..b2587415fa 100644 --- a/crates/nu-cli/tests/commands/mod.rs +++ b/crates/nu-cli/tests/commands/mod.rs @@ -10,6 +10,7 @@ mod first; mod format; mod get; mod group_by; +mod headers; mod histogram; mod insert; mod last;