Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jikstra committed Sep 10, 2021
1 parent da591fc commit aed5087
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use select::predicate::Name;

#[rstest]
/// The ui displays the correct wget command to download the folder recursively
fn ui_displays_wget_element(server: TestServer) -> Result<(), Error> {
fn ui_displays_wget_element(#[with(&["-W"])] server: TestServer) -> Result<(), Error> {
let client = Client::new();

let body = client.get(server.url()).send()?.error_for_status()?;
Expand Down Expand Up @@ -59,7 +59,7 @@ fn ui_displays_wget_element(server: TestServer) -> Result<(), Error> {

#[rstest]
/// All hrefs in raw mode are links to directories or files & directories end with ?raw=true
fn raw_mode_links_to_directories_end_with_raw_true(server: TestServer) -> Result<(), Error> {
fn raw_mode_links_to_directories_end_with_raw_true(#[with(&["-W"])] server: TestServer) -> Result<(), Error> {
fn verify_a_tags(parsed: Document) {
// Ensure all links end with ?raw=true or are files
for node in parsed.find(Name("a")) {
Expand Down
12 changes: 12 additions & 0 deletions tests/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use select::document::Document;
use select::node::Node;
use select::predicate::Name;
use select::predicate::Predicate;

/// Return the href attribute content for the closest anchor found by `text`.
pub fn get_link_from_text(document: &Document, text: &str) -> Option<String> {
let a_elem = document
.find(Name("a").and(|x: &Node| x.children().any(|x| x.text() == text)))
.next()?;
Some(a_elem.attr("href")?.to_string())
}

0 comments on commit aed5087

Please sign in to comment.