From 783f711e9f4761b58c8c4b06d246fb815f5ca47c Mon Sep 17 00:00:00 2001 From: amtoine Date: Wed, 13 Nov 2024 19:18:17 +0100 Subject: [PATCH] add tests for `to ndnuon` --- crates/nu-std/tests/test_formats.nu | 14 ++++++++++++++ crates/nu-std/tests/test_std_formats.nu | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/nu-std/tests/test_formats.nu b/crates/nu-std/tests/test_formats.nu index 26f46fb8bd..17a9d1fc21 100644 --- a/crates/nu-std/tests/test_formats.nu +++ b/crates/nu-std/tests/test_formats.nu @@ -103,3 +103,17 @@ def from_ndnuon_single_object [] { def from_ndnuon_invalid_object [] { assert error { '{"a":1' | formats from ndnuon } } + +#[test] +def to_ndnuon_multiple_objects [] { + let result = [{a:1},{a:2},{a:3},{a:4},{a:5},{a:6}] | formats to ndnuon | str trim + let expect = test_data_multiline + assert equal $result $expect "could not convert to NDNUON" +} + +#[test] +def to_ndnuon_single_object [] { + let result = [{a:1}] | formats to ndnuon | str trim + let expect = "{a:1}" + assert equal $result $expect "could not convert to NDNUON" +} diff --git a/crates/nu-std/tests/test_std_formats.nu b/crates/nu-std/tests/test_std_formats.nu index 33eb24cd98..90fde8dde1 100644 --- a/crates/nu-std/tests/test_std_formats.nu +++ b/crates/nu-std/tests/test_std_formats.nu @@ -103,3 +103,18 @@ def from_ndnuon_single_object [] { def from_ndnuon_invalid_object [] { assert error { '{"a":1' | formats from ndnuon } } + + +#[test] +def to_ndnuon_multiple_objects [] { + let result = [{a:1},{a:2},{a:3},{a:4},{a:5},{a:6}] | formats to ndnuon | str trim + let expect = test_data_multiline + assert equal $result $expect "could not convert to NDNUON" +} + +#[test] +def to_ndnuon_single_object [] { + let result = [{a:1}] | formats to ndnuon | str trim + let expect = "{a:1}" + assert equal $result $expect "could not convert to NDNUON" +}