dev.metalisp.sbt/tests/component/accordion.lisp

73 lines
4.9 KiB
Common Lisp
Raw Normal View History

2023-11-25 09:59:03 +01:00
(defpackage dev.metalisp.sbt/tests/accordion
2023-07-22 19:08:42 +02:00
(:use
:cl
2023-11-25 09:59:03 +01:00
:dev.metalisp.sbt
2023-07-22 19:08:42 +02:00
:rove)
(:import-from
2023-12-18 11:34:54 +01:00
:dev.metalisp.sbt/component/accordion
2023-07-22 21:28:00 +02:00
:header
2023-09-01 10:41:52 +02:00
:collapse
:item
:accordion))
2023-07-22 19:08:42 +02:00
2023-11-25 09:59:03 +01:00
(in-package :dev.metalisp.sbt/tests/accordion)
2023-07-22 19:08:42 +02:00
(deftest test-header
2023-07-27 13:55:25 +02:00
(let ((result (spinneret:with-html-string (header "collapseOne" "Heading" t))))
2023-07-22 19:08:42 +02:00
(testing "Generates correct HTML for accordion header"
2023-07-27 13:55:25 +02:00
(ok (search "class=accordion-header" result))
(ok (search "class=accordion-button" result))
(ok (search "data-bs-target=#collapseOne" result))
(ok (search "aria-expanded=true" result))
(ok (search "aria-controls=#collapseOne" result))
(ok (search "Heading" result)))))
2023-07-22 21:28:00 +02:00
(deftest test-collapse
2023-07-27 13:55:25 +02:00
(let ((result (spinneret:with-html-string (collapse "accordionExample" "collapseOne" t))))
2023-07-22 21:28:00 +02:00
(testing "Generates correct HTML for accordion collapse"
2023-07-27 13:55:25 +02:00
(ok (search "class=\"accordion-collapse collapse show\"" result))
(ok (search "id=collapseOne" result))
(ok (search "data-bs-parent=#accordionExample" result))
(ok (search "class=accordion-body" result)))))
2023-09-01 10:41:52 +02:00
(deftest test-item
(let ((result (spinneret:with-html-string (item (header "collapseOne" "Heading" t) (collapse "accordionExample" "collapseOne" t "Some content")))))
(testing "Generates correct HTML for accordion item"
(ok (search "class=accordion-item" result))
(ok (search "class=accordion-header" result))
(ok (search "class=accordion-button" result))
(ok (search "class=\"accordion-collapse collapse show\"" result))
(ok (search "data-bs-target=#collapseOne" result))
(ok (search "aria-expanded=true" result))
(ok (search "aria-controls=#collapseOne" result))
(ok (search "Some content" result)))))
(deftest test-accordion
(let ((result (spinneret:with-html-string
(accordion "accordionExample"
(:target "collapseOne" :name "Accordion Item #1" :show t :content "This is the first item's accordion body.")
(:target "collapseTwo" :name "Accordion Item #2" :content "This is the second item's accordion body.")
(:target "collapseThree" :name "Accordion Item #3" :content "This is the third item's accordion body.")))))
(testing "Generates correct HTML for accordion"
(ok (search "class=accordion" result))
(ok (search "id=accordionExample" result))
(ok (search "class=accordion-item" result))
(ok (search "class=accordion-header" result))
(ok (search "class=accordion-button" result))
(ok (search "class=\"accordion-collapse collapse show\"" result))
(ok (search "data-bs-target=#collapseOne" result))
(ok (search "aria-expanded=true" result))
(ok (search "aria-controls=#collapseOne" result))
(ok (search "This is the first item's accordion body." result))
(ok (search "This is the second item's accordion body." result))
(ok (search "This is the third item's accordion body." result)))))
2024-02-01 10:06:30 +01:00
(deftest test-accordion-new-approach
(let ((result (with-output-to-string (spinneret:*html*) (accordion (:id "accordionExample" :flush t) (("Accordion Item #1" . "This is the first item's accordion body. It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.") ("Accordion Item #2" . "This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.") ("Accordion Item #3" . "This is the third item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow."))))))
(testing "Generates correct HTML for accordion"
(ok (search "class=accordion" result))
(ok (search "id=accordionExample" result))
(ok (search "class=accordion-item" result))
(ok (search "class=accordion-header" result))
(ok (search "class=accordion-button" result)))))