From dd00909c0607c30a557cfaf9f822561a957e7a6b Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:50:13 -0500 Subject: [PATCH 01/13] Fix tags syntax in CI workflow Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d8f5026..545aac9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -3,7 +3,7 @@ on: push: branches: - master - tags: "*" + tags: ["*"] pull_request: concurrency: # Skip intermediate builds: always. From 51b6a241a91a2012eaccd83b9c55d41a2c23ff4a Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:52:07 -0500 Subject: [PATCH 02/13] Remove x86 tests Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- .github/workflows/CI.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 545aac9..0ee2175 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -27,10 +27,6 @@ jobs: - windows-latest arch: - x64 - - x86 - exclude: - - os: macOS-latest - arch: x86 steps: - uses: actions/checkout@v2 - uses: julia-actions/setup-julia@v1 From deea5baebf33c5db415b2e62b405414e2c262d8e Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:52:21 -0500 Subject: [PATCH 03/13] Remove Mac and Windows tests Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- .github/workflows/CI.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0ee2175..4703935 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,8 +23,6 @@ jobs: - "nightly" os: - ubuntu-latest - - macOS-latest - - windows-latest arch: - x64 steps: From b3e5319fadad5bd81decd38dc5ae526bdbd5c710 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:52:58 -0500 Subject: [PATCH 04/13] Switch to testing on latest stable instead of 1.7 Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4703935..e76b3e0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,7 +19,7 @@ jobs: matrix: version: - "1.6" - - "1.7" + - "1" - "nightly" os: - ubuntu-latest From ba57b38d5b91a9dce73e21b1722f9532b501afb2 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 12:18:08 -0500 Subject: [PATCH 05/13] Add Suppressor as a test dependency Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- Project.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 40c5796..c1f2545 100644 --- a/Project.toml +++ b/Project.toml @@ -7,13 +7,14 @@ version = "0.1.0" EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615" [compat] -julia = "1.6" EzXML = "1.1" +julia = "1.6" [extras] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" [targets] -test = ["Test", "Documenter", "EzXML"] +test = ["Test", "Documenter", "EzXML", "Suppressor"] From 9addd977b786f40579f74e48012e335240c6eb28 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 12:18:49 -0500 Subject: [PATCH 06/13] Add the Bootstrap starter template as an example test case Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- test/runtests.jl | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 6307cb2..b11bcd3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,9 +1,84 @@ using Documenter +using EzXML: AttributeNode, ElementNode, HTMLDocumentNode, TextNode, link!, prettyprint using Kelpie +using Suppressor using Test +# Set up doctests DocMeta.setdocmeta!(Kelpie, :DocTestSetup, :(using Kelpie); recursive=true) +# Set up the Bootstrap 5.1.3 starter template in EzXML nodes +function bootstrap_starter() + # Create the nodes + doc_node = HTMLDocumentNode("about:legacy-compat", nothing) + html_node = ElementNode("html") + head_node = ElementNode("head") + meta_charset_node = ElementNode("meta") + meta_viewport_node = ElementNode("meta") + css_link_node = ElementNode("link") + title_node = ElementNode("title") + body_node = ElementNode("body") + h1_node = ElementNode("h1") + script_node = ElementNode("script") + + # Add attributes + link!(html_node, AttributeNode("lang", "en")) + link!(meta_charset_node, AttributeNode("charset", "utf-8")) + link!(meta_viewport_node, AttributeNode("name", "viewport")) + link!( + meta_viewport_node, AttributeNode("content", "width=device-width, initial-scale=1") + ) + link!( + css_link_node, + AttributeNode( + "href", + "https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css", + ), + ) + link!(css_link_node, AttributeNode("rel", "stylesheet")) + link!( + css_link_node, + AttributeNode( + "integrity", + "sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3", + ), + ) + link!(css_link_node, AttributeNode("crossorigin", "anonymous")) + link!( + script_node, + AttributeNode( + "src", + "https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js", + ), + ) + link!( + script_node, + AttributeNode( + "integrity", + "sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p", + ), + ) + link!(script_node, AttributeNode("crossorigin", "anonymous")) + + # Add content + link!(title_node, TextNode("Hello, world!")) + link!(h1_node, TextNode("Hello, world!")) + link!(script_node, TextNode("")) + + # Link the tree together + link!(head_node, meta_charset_node) + link!(head_node, meta_viewport_node) + link!(head_node, css_link_node) + link!(head_node, title_node) + link!(body_node, h1_node) + link!(body_node, script_node) + link!(html_node, head_node) + link!(html_node, body_node) + link!(doc_node, html_node) + + return @capture_out prettyprint(doc_node) +end #function + @testset "Kelpie.jl" begin @testset "Doctests" begin doctest(Kelpie) From 5796ec2d315c741520ba2b6591db589ff56132af Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 12:47:01 -0500 Subject: [PATCH 07/13] Add the Foundation starter template as an example test case Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- test/runtests.jl | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index b11bcd3..c5cca0d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -79,6 +79,93 @@ function bootstrap_starter() return @capture_out prettyprint(doc_node) end #function +# Set up the Zurb Foundation 6.7.4 starter template in EzXML nodes +function foundation_template() + # Create the nodes + doc_node = HTMLDocumentNode("about:legacy-compat", nothing) + html_node = ElementNode("html") + head_node = ElementNode("head") + meta_charset_node = ElementNode("meta") + meta_http_equiv_node = ElementNode("meta") + meta_viewport_node = ElementNode("meta") + title_node = ElementNode("title") + css_link_node = ElementNode("link") + body_node = ElementNode("body") + h1_node = ElementNode("h1") + script_jquery_node = ElementNode("script") + script_whatinput_node = ElementNode("script") + script_foundation_node = ElementNode("script") + script_launch_node = ElementNode("script") + + # Add attributes + link!(html_node, AttributeNode("class", "no-js")) + link!(html_node, AttributeNode("lang", "en")) + link!(meta_charset_node, AttributeNode("charset", "utf-8")) + link!(meta_http_equiv_node, AttributeNode("http-equiv", "x-ua-compatible")) + link!(meta_http_equiv_node, AttributeNode("content", "ie=edge")) + link!(meta_viewport_node, AttributeNode("name", "viewport")) + link!( + meta_viewport_node, + AttributeNode("content", "width=device-width, initial-scale=1.0"), + ) + link!(css_link_node, AttributeNode("rel", "stylesheet")) + link!( + css_link_node, + AttributeNode( + "href", + "https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/css/foundation.min.css", + ), + ) + link!(css_link_node, AttributeNode("crossorigin", "anonymous")) + link!( + script_jquery_node, + AttributeNode( + "src", "https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" + ), + ) + link!(script_jquery_node, AttributeNode("crossorigin", "anonymous")) + link!( + script_whatinput_node, + AttributeNode( + "src", "https://cdn.jsdelivr.net/npm/what-input@5.2.10/dist/what-input.min.js" + ), + ) + link!(script_whatinput_node, AttributeNode("crossorigin", "anonymous")) + link!( + script_foundation_node, + AttributeNode( + "src", + "https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/js/foundation.min.js", + ), + ) + link!(script_foundation_node, AttributeNode("crossorigin", "anonymous")) + + # Add content + link!(title_node, TextNode("Foundation Starter Template")) + link!(h1_node, TextNode("Hello, world!")) + link!(script_jquery_node, TextNode("")) + link!(script_whatinput_node, TextNode("")) + link!(script_foundation_node, TextNode("")) + link!(script_launch_node, TextNode("\$(document).foundation();")) + + # Link the tree together + link!(head_node, meta_charset_node) + link!(head_node, meta_http_equiv_node) + link!(head_node, meta_viewport_node) + link!(head_node, title_node) + link!(head_node, css_link_node) + link!(body_node, h1_node) + link!(body_node, script_jquery_node) + link!(body_node, script_whatinput_node) + link!(body_node, script_foundation_node) + link!(body_node, script_launch_node) + link!(html_node, head_node) + link!(html_node, body_node) + link!(doc_node, html_node) + + return @capture_out prettyprint(doc_node) +end #function + @testset "Kelpie.jl" begin @testset "Doctests" begin doctest(Kelpie) From 8646a0ff631aba62ddfeb06defdc4c7615f67aa9 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 16:10:48 -0500 Subject: [PATCH 08/13] Refactor capuring pretty strings into its own function Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- test/runtests.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index c5cca0d..833416f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,6 +7,8 @@ using Test # Set up doctests DocMeta.setdocmeta!(Kelpie, :DocTestSetup, :(using Kelpie); recursive=true) +prettystring(xml) = @capture_out prettyprint(xml) + # Set up the Bootstrap 5.1.3 starter template in EzXML nodes function bootstrap_starter() # Create the nodes @@ -76,7 +78,7 @@ function bootstrap_starter() link!(html_node, body_node) link!(doc_node, html_node) - return @capture_out prettyprint(doc_node) + return prettystring(doc_node) end #function # Set up the Zurb Foundation 6.7.4 starter template in EzXML nodes @@ -163,7 +165,7 @@ function foundation_template() link!(html_node, body_node) link!(doc_node, html_node) - return @capture_out prettyprint(doc_node) + return prettystring(doc_node) end #function @testset "Kelpie.jl" begin From 403d34f4ce0bbc4cf54354d60e43fc5b50e26c52 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 16:02:54 -0500 Subject: [PATCH 09/13] Add test for Bootstrap starter template Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- test/runtests.jl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 833416f..c7e4a47 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -172,4 +172,32 @@ end #function @testset "Doctests" begin doctest(Kelpie) end #testset + + @testset "Frameworks" begin + bootstrap_kelpie = html( + head( + meta(; charset="utf-8"), + meta(; name="viewport", content="width=device-width, initial-scale=1"), + link(; + href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css", + rel="stylesheet", + integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3", + crossorigin="anonymous", + ), + title("Hello, world!"), + ), + body( + h1("Hello, world!"), + script( + ""; + src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js", + integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p", + crossorigin="anonymous", + ), + ); + lang="en", + ) + + @test prettystring(bootstrap_kelpie) == bootstrap_starter() + end #testset end #testset From 3144144a22f391a5c8e1cd84e0e4c981ccc8ac50 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 16:27:06 -0500 Subject: [PATCH 10/13] Add test for Foundation starter template Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- test/runtests.jl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index c7e4a47..097ff40 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -197,7 +197,42 @@ end #function ); lang="en", ) + foundation_kelpie = html( + head( + meta(; charset="utf-8"), + meta(; http_equiv="x-ua-compatible", content="ie=edge"), + meta(; name="viewport", content="width=device-width, initial-scale=1.0"), + title("Foundation Starter Template"), + link(; + rel="stylesheet", + href="https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/css/foundation.min.css", + crossorigin="anonymous", + ), + ), + body( + h1("Hello, world!"), + script( + ""; + src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js", + crossorigin="anonymous", + ), + script( + ""; + src="https://cdn.jsdelivr.net/npm/what-input@5.2.10/dist/what-input.min.js", + crossorigin="anonymous", + ), + script( + ""; + src="https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/js/foundation.min.js", + crossorigin="anonymous", + ), + script("\$(document).foundation();"), + ); + class="no-js", + lang="en", + ) @test prettystring(bootstrap_kelpie) == bootstrap_starter() + @test prettystring(foundation_kelpie) == foundation_template() end #testset end #testset From 8bf4c1d3a20ab3051b4b7e4c568f718a8df6b273 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 16:33:07 -0500 Subject: [PATCH 11/13] Add a test for underscores being turned into dashes Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- test/runtests.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 097ff40..70d614d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -235,4 +235,9 @@ end #function @test prettystring(bootstrap_kelpie) == bootstrap_starter() @test prettystring(foundation_kelpie) == foundation_template() end #testset + + @testset "Behaviors" begin + # Test that attributes with underscores become attributes with dashes + @test occursin("", prettystring(i(; data_tooltip="foo"))) + end #testset end #testset From 23960497e6ac66c630aa4f69b7548c3c35167b3f Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 16:33:48 -0500 Subject: [PATCH 12/13] Fix examples for `html_element` not being rendered as doctests Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- src/Kelpie.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kelpie.jl b/src/Kelpie.jl index da52885..79aa891 100644 --- a/src/Kelpie.jl +++ b/src/Kelpie.jl @@ -103,7 +103,7 @@ specified by `kwargs`. # Example -``` +```jldoctest julia> import EzXML: prettyprint julia> prettyprint(html_element("img"; src="https://millironx.com/images/charolette.jpg")) From 78b0f48c4d92d53e7f00a0760d096450f16085f1 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 16:37:21 -0500 Subject: [PATCH 13/13] Update CHANGELOG Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- .markdownlint.yml | 2 ++ CHANGELOG.md | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.markdownlint.yml b/.markdownlint.yml index d71a578..0059ce7 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -1,3 +1,5 @@ no-inline-html: allowed_elements: - kbd +no-duplicate-header: + allow_different_nesting: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 36bdf73..5ec0d6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Way more unit tests ([#4](https://github.com/MillironX/Kelpie.jl/pull/4)) + ### Changed - Arrays of content replaced with argument splatting ([#2](https://github.com/MillironX/Kelpie.jl/pull/2))