From 63487941fb99d2cffa909cc61ad24e620ca03e4a Mon Sep 17 00:00:00 2001 From: Michael Angerman <1809991+stormasm@users.noreply.github.com> Date: Wed, 23 Feb 2022 08:43:36 -0800 Subject: [PATCH] add back in the tests for query_web in the nu_plugin_query (#4614) * fix first test * fix 2nd query_web test --- crates/nu_plugin_query/src/query_web.rs | 47 +++++++++++++------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/crates/nu_plugin_query/src/query_web.rs b/crates/nu_plugin_query/src/query_web.rs index a1bee4db83..700a81ff7c 100644 --- a/crates/nu_plugin_query/src/query_web.rs +++ b/crates/nu_plugin_query/src/query_web.rs @@ -276,28 +276,31 @@ pub fn css(selector: &str) -> ScraperSelector { ScraperSelector::parse(selector).expect("this should never trigger") } -// #[cfg(test)] -// mod tests { -// use super::*; +#[cfg(test)] +mod tests { + use super::*; -// const SIMPLE_LIST: &str = r#" -// -// "#; + const SIMPLE_LIST: &str = r#" + + "#; -// #[test] -// fn test_first_child_is_not_empty() { -// assert!(!execute_selector_query(SIMPLE_LIST, "li:first-child", false).is_empty()) -// } + #[test] + fn test_first_child_is_not_empty() { + assert!( + !execute_selector_query(SIMPLE_LIST, "li:first-child", false, Span::test_data()) + .is_empty() + ) + } -// #[test] -// fn test_first_child() { -// assert_eq!( -// vec!["Coffee".to_string()], -// execute_selector_query(SIMPLE_LIST, "li:first-child", false) -// ) -// } -// } + #[test] + fn test_first_child() { + let item = execute_selector_query(SIMPLE_LIST, "li:first-child", false, Span::test_data()); + let config = nu_protocol::Config::default(); + let out = item.into_string("\n", &config); + assert_eq!("[Coffee]".to_string(), out) + } +}