mirror of
https://github.com/nushell/nushell.git
synced 2024-12-13 10:41:52 +01:00
656f707a0b
# Description The working directory doesn't have to be set for those tests (or would be the default anyways). When appropriate also remove calls to the `pipeline()` function. In most places kept the diff minimal and only removed the superfluous part to not pollute the blame view. With simpler tests also simplified things to make them more readable overall (this included removal of the raw string literal). Work for #8670
72 lines
4.4 KiB
Rust
72 lines
4.4 KiB
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn out_html_simple() {
|
|
let actual = nu!(pipeline(
|
|
r#"
|
|
echo 3 | to html
|
|
"#
|
|
));
|
|
|
|
assert_eq!(
|
|
actual.out,
|
|
r"<html><style>body { background-color:white;color:black; }</style><body>3</body></html>"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn out_html_partial() {
|
|
let actual = nu!(r#"
|
|
echo 3 | to html -p
|
|
"#);
|
|
|
|
assert_eq!(
|
|
actual.out,
|
|
"<div style=\"background-color:white;color:black;\">3</div>"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn out_html_table() {
|
|
let actual = nu!(r#"
|
|
echo '{"name": "darren"}' | from json | to html
|
|
"#);
|
|
|
|
assert_eq!(
|
|
actual.out,
|
|
r"<html><style>body { background-color:white;color:black; }</style><body><table><thead><tr><th>name</th></tr></thead><tbody><tr><td>darren</td></tr></tbody></table></body></html>"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
#[ignore]
|
|
fn test_cd_html_color_flag_dark_false() {
|
|
let actual = nu!(r#"
|
|
cd --help | to html --html-color
|
|
"#);
|
|
assert_eq!(
|
|
actual.out,
|
|
r"<html><style>body { background-color:white;color:black; }</style><body>Change directory.<br><br><span style='color:green;'>Usage<span style='color:black;font-weight:normal;'>:<br> > cd (path) <br><br></span></span><span style='color:green;'>Flags<span style='color:black;font-weight:normal;'>:<br> </span></span><span style='color:#037979;'>-h</span>,<span style='color:black;font-weight:normal;'> </span><span style='color:#037979;'>--help<span style='color:black;font-weight:normal;'> - Display the help message for this command<br><br></span><span style='color:green;'>Signatures<span style='color:black;font-weight:normal;'>:<br> <nothing> | cd <string?> -> <nothing><br> <string> | cd <string?> -> <nothing><br><br></span></span><span style='color:green;'>Parameters<span style='color:black;font-weight:normal;'>:<br> (optional) </span></span></span><span style='color:#037979;'>path<span style='color:black;font-weight:normal;'> <</span><span style='color:blue;font-weight:bold;'>directory<span style='color:black;font-weight:normal;'>>: the path to change to<br><br></span></span><span style='color:green;'>Examples<span style='color:black;font-weight:normal;'>:<br> Change to your home directory<br> > </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'> </span></span></span></span><span style='color:#037979;'>~<span style='color:black;font-weight:normal;'><br><br> Change to a directory via abbreviations<br> > </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'> </span></span></span><span style='color:#037979;'>d/s/9<span style='color:black;font-weight:normal;'><br><br> Change to the previous working directory ($OLDPWD)<br> > </span><span style='color:#037979;font-weight:bold;'>cd<span style='color:black;font-weight:normal;'> </span></span></span><span style='color:#037979;'>-<span style='color:black;font-weight:normal;'><br><br></body></html></span></span>"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn test_no_color_flag() {
|
|
let actual = nu!(r#"
|
|
cd --help | to html --no-color
|
|
"#);
|
|
assert_eq!(
|
|
actual.out,
|
|
r"<html><style>body { background-color:white;color:black; }</style><body>Change directory.<br><br>Usage:<br> > cd (path) <br><br>Flags:<br> -h, --help - Display the help message for this command<br><br>Signatures:<br> <nothing> | cd <string?> -> <nothing><br> <string> | cd <string?> -> <nothing><br><br>Parameters:<br> path <directory>: the path to change to (optional)<br><br>Examples:<br> Change to your home directory<br> > cd ~<br><br> Change to a directory via abbreviations<br> > cd d/s/9<br><br> Change to the previous working directory ($OLDPWD)<br> > cd -<br><br></body></html>"
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn test_list() {
|
|
let actual = nu!(r#"to html --list | where name == C64 | get 0 | to nuon"#);
|
|
assert_eq!(
|
|
actual.out,
|
|
r##"{name: "C64", black: "#090300", red: "#883932", green: "#55a049", yellow: "#bfce72", blue: "#40318d", purple: "#8b3f96", cyan: "#67b6bd", white: "#ffffff", brightBlack: "#000000", brightRed: "#883932", brightGreen: "#55a049", brightYellow: "#bfce72", brightBlue: "#40318d", brightPurple: "#8b3f96", brightCyan: "#67b6bd", brightWhite: "#f7f7f7", background: "#40318d", foreground: "#7869c4"}"##
|
|
);
|
|
}
|