diff --git a/resources/tests/readability/001/expected.html b/resources/tests/readability/001/expected.html index 38b4cd2..e246772 100644 --- a/resources/tests/readability/001/expected.html +++ b/resources/tests/readability/001/expected.html @@ -1,4 +1,4 @@ -

So finally you're testing your frontend JavaScript code? Great! The more you +

So finally you're testing your frontend JavaScript code? Great! The more you write tests, the more confident you are with your code… but how much precisely? That's where code coverage might help.

@@ -30,7 +30,7 @@ with nodejs.

Source files: blanket.js, mocha-blanket.js

As an example, let's reuse the silly Cow example we used - in a previous episode:

+ in a previous episode:

// cow.js
 (function(exports) {
   "use strict";
@@ -105,7 +105,7 @@ describe("Cow", function() {
                                 be loaded.
 
 

Running the tests now gives us something like this:

-

screenshot

+

screenshot

As you can see, the report at the bottom highlights that we haven't actually tested the case where an error is raised in case a target name is missing. We've been informed of that, nothing more, nothing less. We simply know diff --git a/src/full_text_parser/readability/tests.rs b/src/full_text_parser/readability/tests.rs index 52f6664..7a6820d 100644 --- a/src/full_text_parser/readability/tests.rs +++ b/src/full_text_parser/readability/tests.rs @@ -6,13 +6,13 @@ use crate::{ full_text_parser::{config::ConfigEntry, metadata}, }; -async fn run_test(name: &str, url: Option) { +async fn run_test(name: &str) { libxml::tree::node::set_node_rc_guard(10); let _ = env_logger::builder().is_test(true).try_init(); let empty_config = ConfigEntry::default(); - let url = url.unwrap_or_else(|| Url::parse("http://google.com").unwrap()); + let url = Url::parse("http://fakehost/test/base/").unwrap(); let html = std::fs::read_to_string(format!("./resources/tests/readability/{name}/source.html")) .expect("Failed to read source HTML"); let document = crate::FullTextParser::parse_html(&html, None, &empty_config).unwrap(); @@ -41,7 +41,7 @@ async fn run_test(name: &str, url: Option) { article.document = Some(article_document); let html = article.get_content().unwrap(); - //std::fs::write("expected.html", &html).unwrap(); + std::fs::write("expected.html", &html).unwrap(); let expected = std::fs::read_to_string(format!( "./resources/tests/readability/{name}/expected.html" @@ -53,49 +53,45 @@ async fn run_test(name: &str, url: Option) { #[tokio::test] async fn test_001() { - run_test("001", None).await + run_test("001").await } #[tokio::test] async fn test_002() { - run_test("002", None).await + run_test("002").await } #[tokio::test] async fn test_003() { - run_test("003", None).await + run_test("003").await } #[tokio::test] async fn aclu() { - run_test("aclu", None).await + run_test("aclu").await } #[tokio::test] async fn aktualne() { - run_test("aktualne", None).await + run_test("aktualne").await } #[tokio::test] async fn archive_of_our_own() { - run_test("archive-of-our-own", None).await + run_test("archive-of-our-own").await } #[tokio::test] async fn ars_1() { - run_test("ars-1", None).await + run_test("ars-1").await } #[tokio::test] async fn base_url_base_element_relative() { - run_test( - "base-url-base-element-relative", - Some(Url::parse("http://fakehost/test/base/").unwrap()), - ) - .await + run_test("base-url-base-element-relative").await } #[tokio::test] async fn webmd_1() { - run_test("webmd-1", None).await + run_test("webmd-1").await }