2020-03-19 19:18:24 +00:00
|
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
|
|
|
|
#[test]
|
2020-11-06 17:40:53 +00:00
|
|
|
fn md_empty() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
2021-02-02 17:09:19 +00:00
|
|
|
echo [[]; []] | from json | to md
|
2020-11-06 17:40:53 +00:00
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
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() {
|
2020-03-19 19:18:24 +00:00
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
2020-05-04 08:44:33 +00:00
|
|
|
echo 3 | to md
|
2020-03-19 19:18:24 +00:00
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2020-05-07 11:03:43 +00:00
|
|
|
assert_eq!(actual.out, "3");
|
2020-03-19 19:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2020-11-06 17:40:53 +00:00
|
|
|
fn md_simple_pretty() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
|
|
|
echo 3 | to md -p
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual.out, "3");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn md_table() {
|
2020-03-19 19:18:24 +00:00
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
2021-02-02 17:09:19 +00:00
|
|
|
echo [[name]; [jason]] | to md
|
2020-03-19 19:18:24 +00:00
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2020-05-07 11:03:43 +00:00
|
|
|
assert_eq!(actual.out, "|name||-||jason|");
|
2020-03-19 19:18:24 +00:00
|
|
|
}
|
2020-10-15 03:20:55 +00:00
|
|
|
|
|
|
|
#[test]
|
2020-11-06 17:40:53 +00:00
|
|
|
fn md_table_pretty() {
|
2020-10-15 03:20:55 +00:00
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
2021-02-02 17:09:19 +00:00
|
|
|
echo [[name]; [joseph]] | to md -p
|
2020-10-15 03:20:55 +00:00
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2020-10-19 06:58:24 +00:00
|
|
|
assert_eq!(actual.out, "| name || ------ || joseph |");
|
2020-10-15 03:20:55 +00:00
|
|
|
}
|
2021-02-02 17:09:19 +00:00
|
|
|
|
|
|
|
#[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
|
2021-05-12 01:01:48 +00:00
|
|
|
| append (meals)
|
2021-02-02 17:09:19 +00:00
|
|
|
| to md --per-element --pretty
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
actual.out,
|
|
|
|
"# Nu top meals| dish || ----- || Arepa || Taco || Pizza |"
|
|
|
|
);
|
|
|
|
}
|