From 933379c79847f2172b392fb453548411a95bc33d Mon Sep 17 00:00:00 2001 From: Sunshine Date: Sun, 22 Mar 2020 19:03:33 -0400 Subject: [PATCH] ensure consistent naming across all tests --- src/tests/cli.rs | 1 - src/tests/html.rs | 116 +++++++++++++++++++++++----------------------- src/tests/js.rs | 7 +-- 3 files changed, 61 insertions(+), 63 deletions(-) diff --git a/src/tests/cli.rs b/src/tests/cli.rs index d0d0b90..a376499 100644 --- a/src/tests/cli.rs +++ b/src/tests/cli.rs @@ -290,7 +290,6 @@ fn local_file_target_input_absolute_target_path() -> Result<(), Box { let node_name = name.local.as_ref().to_string(); - let parent = get_parent_node(node); - let parent_node_name = get_node_name(&parent); + let parent = html::get_parent_node(node); + let parent_node_name = html::get_node_name(&parent); if node_name == "head" || node_name == "body" { assert_eq!(parent_node_name, "html"); } else if node_name == "div" { @@ -60,11 +58,11 @@ fn test_get_parent_node_name() { } #[test] -fn test_walk_and_embed_assets() { +fn walk_and_embed_assets() { let cache = &mut HashMap::new(); let html = "

"; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let opt_no_css: bool = false; @@ -75,7 +73,7 @@ fn test_walk_and_embed_assets() { let client = Client::new(); - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -97,9 +95,9 @@ fn test_walk_and_embed_assets() { } #[test] -fn test_walk_and_embed_assets_ensure_no_recursive_iframe() { +fn walk_and_embed_assets_ensure_no_recursive_iframe() { let html = "

"; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let cache = &mut HashMap::new(); @@ -111,7 +109,7 @@ fn test_walk_and_embed_assets_ensure_no_recursive_iframe() { let client = Client::new(); - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -133,9 +131,9 @@ fn test_walk_and_embed_assets_ensure_no_recursive_iframe() { } #[test] -fn test_walk_and_embed_assets_ensure_no_recursive_frame() { +fn walk_and_embed_assets_ensure_no_recursive_frame() { let html = ""; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let cache = &mut HashMap::new(); @@ -147,7 +145,7 @@ fn test_walk_and_embed_assets_ensure_no_recursive_frame() { let client = Client::new(); - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -169,11 +167,11 @@ fn test_walk_and_embed_assets_ensure_no_recursive_frame() { } #[test] -fn test_walk_and_embed_assets_no_css() { +fn walk_and_embed_assets_no_css() { let html = "\ \
"; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let cache = &mut HashMap::new(); @@ -184,7 +182,7 @@ fn test_walk_and_embed_assets_no_css() { let opt_silent = true; let client = Client::new(); - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -214,10 +212,10 @@ fn test_walk_and_embed_assets_no_css() { } #[test] -fn test_walk_and_embed_assets_no_images() { +fn walk_and_embed_assets_no_images() { let html = "\
"; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let cache = &mut HashMap::new(); @@ -229,7 +227,7 @@ fn test_walk_and_embed_assets_no_images() { let client = Client::new(); - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -264,7 +262,7 @@ fn test_walk_and_embed_assets_no_images() { #[test] fn walk_and_embed_assets_no_body_background_images() { let html = ""; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let cache = &mut HashMap::new(); @@ -276,7 +274,7 @@ fn walk_and_embed_assets_no_body_background_images() { let client = Client::new(); - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -298,9 +296,9 @@ fn walk_and_embed_assets_no_body_background_images() { } #[test] -fn test_walk_and_embed_assets_no_frames() { +fn walk_and_embed_assets_no_frames() { let html = ""; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let cache = &mut HashMap::new(); @@ -311,7 +309,7 @@ fn test_walk_and_embed_assets_no_frames() { let opt_silent = true; let client = Client::new(); - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -333,9 +331,9 @@ fn test_walk_and_embed_assets_no_frames() { } #[test] -fn test_walk_and_embed_assets_no_iframes() { +fn walk_and_embed_assets_no_iframes() { let html = ""; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let cache = &mut HashMap::new(); @@ -346,7 +344,7 @@ fn test_walk_and_embed_assets_no_iframes() { let opt_silent = true; let client = Client::new(); - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -368,12 +366,12 @@ fn test_walk_and_embed_assets_no_iframes() { } #[test] -fn test_walk_and_embed_assets_no_js() { +fn walk_and_embed_assets_no_js() { let html = "
\ \ \
"; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let cache = &mut HashMap::new(); @@ -385,7 +383,7 @@ fn test_walk_and_embed_assets_no_js() { let client = Client::new(); - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -408,11 +406,11 @@ fn test_walk_and_embed_assets_no_js() { } #[test] -fn test_walk_and_embed_with_no_integrity() { +fn walk_and_embed_with_no_integrity() { let html = "No integrity\ \ "; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let url = "http://localhost"; let cache = &mut HashMap::new(); let client = Client::new(); @@ -422,7 +420,7 @@ fn test_walk_and_embed_with_no_integrity() { let opt_no_images: bool = true; let opt_silent = true; - walk_and_embed_assets( + html::walk_and_embed_assets( cache, &client, &url, @@ -447,9 +445,9 @@ fn test_walk_and_embed_with_no_integrity() { } #[test] -fn test_stringify_document() { +fn stringify_document() { let html = "
"; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let opt_no_css: bool = false; let opt_no_frames: bool = false; @@ -458,7 +456,7 @@ fn test_stringify_document() { let opt_isolate: bool = false; assert_eq!( - stringify_document( + html::stringify_document( &dom.document, opt_no_css, opt_no_frames, @@ -471,12 +469,12 @@ fn test_stringify_document() { } #[test] -fn test_stringify_document_isolate() { +fn stringify_document_isolate() { let html = "Isolated document\ \ \
"; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let opt_no_css: bool = false; let opt_no_frames: bool = false; @@ -485,7 +483,7 @@ fn test_stringify_document_isolate() { let opt_isolate: bool = true; assert_eq!( - stringify_document( + html::stringify_document( &dom.document, opt_no_css, opt_no_frames, @@ -510,12 +508,12 @@ fn test_stringify_document_isolate() { } #[test] -fn test_stringify_document_no_css() { +fn stringify_document_no_css() { let html = "\ Unstyled document\ \
"; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let opt_no_css: bool = true; let opt_no_frames: bool = false; @@ -524,7 +522,7 @@ fn test_stringify_document_no_css() { let opt_isolate: bool = false; assert_eq!( - stringify_document( + html::stringify_document( &dom.document, opt_no_css, opt_no_frames, @@ -545,12 +543,12 @@ fn test_stringify_document_no_css() { } #[test] -fn test_stringify_document_no_frames() { +fn stringify_document_no_frames() { let html = "\ Frameless document\ \
"; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let opt_no_css: bool = false; let opt_no_frames: bool = true; @@ -559,7 +557,7 @@ fn test_stringify_document_no_frames() { let opt_isolate: bool = false; assert_eq!( - stringify_document( + html::stringify_document( &dom.document, opt_no_css, opt_no_frames, @@ -580,7 +578,7 @@ fn test_stringify_document_no_frames() { } #[test] -fn test_stringify_document_isolate_no_frames_no_js_no_css_no_images() { +fn stringify_document_isolate_no_frames_no_js_no_css_no_images() { let html = "\ no-frame no-css no-js no-image isolated document\ \ @@ -590,7 +588,7 @@ fn test_stringify_document_isolate_no_frames_no_js_no_css_no_images() { \ \ "; - let dom = html_to_dom(&html); + let dom = html::html_to_dom(&html); let opt_isolate: bool = true; let opt_no_css: bool = true; @@ -599,7 +597,7 @@ fn test_stringify_document_isolate_no_frames_no_js_no_css_no_images() { let opt_no_images: bool = true; assert_eq!( - stringify_document( + html::stringify_document( &dom.document, opt_no_css, opt_no_frames, diff --git a/src/tests/js.rs b/src/tests/js.rs index c25d05f..63cf76d 100644 --- a/src/tests/js.rs +++ b/src/tests/js.rs @@ -1,12 +1,13 @@ use crate::js::attr_is_event_handler; #[test] -fn test_attr_is_event_handler() { - // passing +fn attr_is_event_handler() { + // Passing assert!(attr_is_event_handler("onBlur")); assert!(attr_is_event_handler("onclick")); assert!(attr_is_event_handler("onClick")); - // failing + + // Failing assert!(!attr_is_event_handler("href")); assert!(!attr_is_event_handler("")); assert!(!attr_is_event_handler("class"));