From 712654d4c023a2ab13190c6905d313e0ba897965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 2 Oct 2023 19:26:40 +0200 Subject: Rewrite test running system. --- tests/html-components/caltable.scm | 108 ++++++++++++++++++++++++++++++++++++ tests/html-components/component.scm | 36 ++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 tests/html-components/caltable.scm create mode 100644 tests/html-components/component.scm (limited to 'tests/html-components') diff --git a/tests/html-components/caltable.scm b/tests/html-components/caltable.scm new file mode 100644 index 00000000..fec1ace4 --- /dev/null +++ b/tests/html-components/caltable.scm @@ -0,0 +1,108 @@ +(define-module (test html caltable) + :use-module (srfi srfi-64) + :use-module (srfi srfi-64 test-error) + :use-module (srfi srfi-88) + :use-module (calp html caltable) + :use-module (datetime) + ;; causes translated parts of the generated document to work + :use-module (calp translation) + ) + +;; Not the most robust test, but at least it shows us when we break something +(test-equal "Whole fucking caltable" + `(div (@ (class "small-calendar")) + (div (@ (class "column-head row-head")) ,(G_ "v.")) + (div (@ (class "column-head")) "Må") + (div (@ (class "column-head")) "Ti") + (div (@ (class "column-head")) "On") + (div (@ (class "column-head")) "To") + (div (@ (class "column-head")) "Fr") + (div (@ (class "column-head")) "Lö") + (div (@ (class "column-head")) "Sö") + (div (@ (class "row-head")) 13) + (div (@ (class "row-head")) 14) + (div (@ (class "row-head")) 15) + (div (@ (class "row-head")) 16) + (div (@ (class "row-head")) 17) + (a (@ (class "prev") + (href "2022-03-01.html" "#" "2022-03-28")) + (time (@ (datetime "2022-03-28")) 28)) + (a (@ (class "prev") + (href "2022-03-01.html" "#" "2022-03-29")) + (time (@ (datetime "2022-03-29")) 29)) + (a (@ (class "prev") + (href "2022-03-01.html" "#" "2022-03-30")) + (time (@ (datetime "2022-03-30")) 30)) + (a (@ (class "prev") + (href "2022-03-01.html" "#" "2022-03-31")) + (time (@ (datetime "2022-03-31")) 31)) + (a (@ (href "#" "2022-04-01")) + (time (@ (datetime "2022-04-01")) 1)) + (a (@ (href "#" "2022-04-02")) + (time (@ (datetime "2022-04-02")) 2)) + (a (@ (href "#" "2022-04-03")) + (time (@ (datetime "2022-04-03")) 3)) + (a (@ (href "#" "2022-04-04")) + (time (@ (datetime "2022-04-04")) 4)) + (a (@ (href "#" "2022-04-05")) + (time (@ (datetime "2022-04-05")) 5)) + (a (@ (href "#" "2022-04-06")) + (time (@ (datetime "2022-04-06")) 6)) + (a (@ (href "#" "2022-04-07")) + (time (@ (datetime "2022-04-07")) 7)) + (a (@ (href "#" "2022-04-08")) + (time (@ (datetime "2022-04-08")) 8)) + (a (@ (href "#" "2022-04-09")) + (time (@ (datetime "2022-04-09")) 9)) + (a (@ (href "#" "2022-04-10")) + (time (@ (datetime "2022-04-10")) 10)) + (a (@ (href "#" "2022-04-11")) + (time (@ (datetime "2022-04-11")) 11)) + (a (@ (href "#" "2022-04-12")) + (time (@ (datetime "2022-04-12")) 12)) + (a (@ (href "#" "2022-04-13")) + (time (@ (datetime "2022-04-13")) 13)) + (a (@ (href "#" "2022-04-14")) + (time (@ (datetime "2022-04-14")) 14)) + (a (@ (href "#" "2022-04-15")) + (time (@ (datetime "2022-04-15")) 15)) + (a (@ (href "#" "2022-04-16")) + (time (@ (datetime "2022-04-16")) 16)) + (a (@ (href "#" "2022-04-17")) + (time (@ (datetime "2022-04-17")) 17)) + (a (@ (href "#" "2022-04-18")) + (time (@ (datetime "2022-04-18")) 18)) + (a (@ (href "#" "2022-04-19")) + (time (@ (datetime "2022-04-19")) 19)) + (a (@ (href "#" "2022-04-20")) + (time (@ (datetime "2022-04-20")) 20)) + (a (@ (href "#" "2022-04-21")) + (time (@ (datetime "2022-04-21")) 21)) + (a (@ (href "#" "2022-04-22")) + (time (@ (datetime "2022-04-22")) 22)) + (a (@ (href "#" "2022-04-23")) + (time (@ (datetime "2022-04-23")) 23)) + (a (@ (href "#" "2022-04-24")) + (time (@ (datetime "2022-04-24")) 24)) + (a (@ (href "#" "2022-04-25")) + (time (@ (datetime "2022-04-25")) 25)) + (a (@ (href "#" "2022-04-26")) + (time (@ (datetime "2022-04-26")) 26)) + (a (@ (href "#" "2022-04-27")) + (time (@ (datetime "2022-04-27")) 27)) + (a (@ (href "#" "2022-04-28")) + (time (@ (datetime "2022-04-28")) 28)) + (a (@ (href "#" "2022-04-29")) + (time (@ (datetime "2022-04-29")) 29)) + (a (@ (href "#" "2022-04-30")) + (time (@ (datetime "2022-04-30")) 30)) + (a (@ (class "next") + (href "2022-05-01.html" "#" "2022-05-01")) + (time (@ (datetime "2022-05-01")) 1))) + + (parameterize ((week-start mon)) + (cal-table start-date: #2022-04-01 + end-date: #2022-04-30 + next-start: (lambda (d) (date+ d (date month: 1))) + prev-start: (lambda (d) (date- d (date month: 1)))))) + diff --git a/tests/html-components/component.scm b/tests/html-components/component.scm new file mode 100644 index 00000000..a1fbdfbc --- /dev/null +++ b/tests/html-components/component.scm @@ -0,0 +1,36 @@ +(define-module (test html caltable) + :use-module (srfi srfi-64) + :use-module (srfi srfi-64 test-error) + :use-module (srfi srfi-88) + :use-module (calp translation) + + :use-module (calp html components) + ) + +(test-equal + '(button (@ (class "btn") (onclick "onclick")) "Body") + (btn onclick: "onclick" "Body")) + +(test-equal "href button, without body" + '(a (@ (class "btn") (href "href"))) + (btn href: "href")) + +(test-error 'wrong-type-arg + (btn href: "a" onclick: "b")) + +(test-equal "btn no specifier, but class" + '(button (@ (class "btn test")) "body") + (btn class: '("test") "body")) + +;; tabset + +(test-equal '(link (@ (type "text/css") (rel "stylesheet") (href "style.css"))) + (include-css "style.css")) + +(test-equal + '(link (@ (type "text/css") (rel "stylesheet") (href "style.css") (class "test"))) + (include-css "style.css" '(class "test"))) + +(test-equal + '(link (@ (type "text/css") (rel "alternate stylesheet") (href "style.css"))) + (include-alt-css "style.css")) -- cgit v1.2.3