Break down tests to be smaller. Check counter.

This commit is contained in:
Marcus Kammer 2024-02-04 11:57:03 +01:00
parent de600ea641
commit a59dd7ee06
2 changed files with 17 additions and 24 deletions

View file

@ -125,7 +125,7 @@ Example usage:
:type "button"
:data-bs-toggle "collapse"
:data-bs-target ,(concatenate 'string "#" collapse-id)
:aria-expanded "false"
:aria-expanded ,(if (= counter 1) "true" "false")
:aria-controls ,collapse-id
,title))
(:div :id ,collapse-id

View file

@ -42,31 +42,24 @@
(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)))))
(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.")))))
(deftest test-accordion-correct-classes
(let ((result (with-output-to-string (spinneret:*html*) (accordion (:id "accordionExample" :flush t) ("Accordion Item #1" "Accordion Content #1") ("Accordion Item #2" "Accordion Content #2") ("Accordion Item #3" "Accordion Content #3")))))
(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)))))
(deftest test-accordion-correct-id
(let ((result (with-output-to-string (spinneret:*html*) (accordion (:id "accordionExample" :flush t) ("Accordion Item #1" "Accordion Content #1") ("Accordion Item #2" "Accordion Content #2") ("Accordion Item #3" "Accordion Content #3")))))
(testing "Generates correct HTML for accordion"
(ok (search "id=accordionExample" result))
(ok (search "id=collapse-accordionExample-1" result))
(ok (search "id=collapse-accordionExample-2" result)))))
(deftest test-accordion-correct-aria
(let ((result (with-output-to-string (spinneret:*html*) (accordion (:id "accordionExample" :flush t) ("Accordion Item #1" "Accordion Content #1") ("Accordion Item #2" "Accordion Content #2") ("Accordion Item #3" "Accordion Content #3")))))
(testing "Generates correct HTML for accordion"
(ok (search "aria-expanded=true" result))
(ok (search "aria-expanded=false" result))
(ok (search "aria-controls=collapse-accordionExample-1" result)))))