aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/navigation.rs16
-rw-r--r--tests/utils/mod.rs14
2 files changed, 13 insertions, 17 deletions
diff --git a/tests/navigation.rs b/tests/navigation.rs
index b921d4c..734424a 100644
--- a/tests/navigation.rs
+++ b/tests/navigation.rs
@@ -7,7 +7,7 @@ use rstest::rstest;
use select::document::Document;
use std::process::{Command, Stdio};
use utils::get_link_from_text;
-use utils::get_link_hrefs_from_text_with_prefix;
+use utils::get_link_hrefs_with_prefix;
#[rstest(
input,
@@ -154,22 +154,18 @@ fn can_navigate_using_breadcrumbs(
#[case(server(&["--default-sorting-method", "date", "--default-sorting-order", "asc"]))]
/// We can specify the default sorting order
fn can_specify_default_sorting_order(#[case] server: TestServer) -> Result<(), Error> {
- let slash = String::from("/");
- let base_url = server.url();
- let nested_url = base_url.join(&slash)?;
-
- let resp = reqwest::blocking::get(nested_url.as_str())?;
+ let resp = reqwest::blocking::get(server.url())?;
let body = resp.error_for_status()?;
let parsed = Document::from_read(body)?;
- let links = get_link_hrefs_from_text_with_prefix(&parsed, "/");
- let first_created_file = slash + FILES.first().unwrap();
+ let links = get_link_hrefs_with_prefix(&parsed, "/");
+ let first_created_file = FILES.first().unwrap();
- if links.first().unwrap() == &first_created_file {
+ if links.first().unwrap() == first_created_file {
assert_eq!("/very/?sort=date&order=asc", links.last().unwrap());
}
- if links.last().unwrap() == &first_created_file {
+ if links.last().unwrap() == first_created_file {
assert_eq!("/very/?sort=date&order=desc", links.first().unwrap());
}
diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs
index 64433fc..baffc29 100644
--- a/tests/utils/mod.rs
+++ b/tests/utils/mod.rs
@@ -13,16 +13,16 @@ pub fn get_link_from_text(document: &Document, text: &str) -> Option<String> {
Some(a_elem.attr("href")?.to_string())
}
-/// Return the href attributes of all links that start with the specified prefix `text`.
-pub fn get_link_hrefs_from_text_with_prefix(document: &Document, text: &str) -> Vec<String> {
+/// Return the href attributes of all links that start with the specified `prefix`.
+pub fn get_link_hrefs_with_prefix(document: &Document, prefix: &str) -> Vec<String> {
let mut vec: Vec<String> = Vec::new();
- let a_elem = document.find(Name("a"));
+ let a_elements = document.find(Name("a"));
- for element in a_elem {
- let str = element.attr("href").unwrap_or("");
- if str.to_string().starts_with(text) {
- vec.push(str.to_string());
+ for element in a_elements {
+ let s = element.attr("href").unwrap_or("");
+ if s.to_string().starts_with(prefix) {
+ vec.push(s.to_string());
}
}