mirror of
https://github.com/nushell/nushell.git
synced 2025-08-13 22:58:40 +02:00
Command tests (#922)
* WIP command tests * Finish marking todo tests * update * update * Windows cd test ignoring
This commit is contained in:
98
crates/nu-command/tests/format_conversions/markdown.rs
Normal file
98
crates/nu-command/tests/format_conversions/markdown.rs
Normal file
@ -0,0 +1,98 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn md_empty() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [[]; []] | from json | to md
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn md_empty_pretty() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo "{}" | from json | to md -p
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn md_simple() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 3 | to md
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn md_simple_pretty() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 3 | to md -p
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn md_table() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [[name]; [jason]] | to md
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "|name||-||jason|");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn md_table_pretty() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [[name]; [joseph]] | to md -p
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "| name || ------ || joseph |");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn md_combined() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
def title [] {
|
||||
echo [[H1]; ["Nu top meals"]]
|
||||
};
|
||||
|
||||
def meals [] {
|
||||
echo [[dish]; [Arepa] [Taco] [Pizza]]
|
||||
};
|
||||
|
||||
title
|
||||
| append (meals)
|
||||
| to md --per-element --pretty
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"# Nu top meals| dish || ----- || Arepa || Taco || Pizza |"
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user