Files
clj-ui-framework/test/ui/switch_test.clj
Florian Schroedl 18043cb150 feat: add 13 components adapted from Oat UI
Components (.cljc + .css + tests):
- Alert (success/warning/danger/info variants)
- Badge (primary/secondary/outline/success/warning/danger)
- Card (card/card-header/card-body/card-footer)
- Accordion (collapsible with open/closed state)
- Table (headers/rows, striped/bordered variants)
- Dialog (modal with header/body/footer sections)
- Breadcrumb (nav with active item)
- Pagination (current/total with prev/next)
- Progress (value bar with color variants)
- Spinner (sm/md/lg sizes)
- Skeleton (line/box/circle/heading placeholders)
- Switch (toggle with checked/disabled states)
- Tooltip (hover text via data-tooltip attr)

CSS-only additions:
- Form elements (inputs, selects, checkboxes, radios, range, groups)
- Grid (12-column system with offsets, responsive)
- Utilities (flex, spacing, alignment, sr-only)

Also adds warning/fg-on-warning tokens to light and dark themes.
All 3 dev targets updated with full component showcase.
40 tests, 213 assertions, all passing.
2026-03-03 11:37:05 +01:00

28 lines
1.0 KiB
Clojure

(ns ui.switch-test
(:require [clojure.test :refer [deftest is testing]]
[ui.switch :as switch]))
(deftest switch-class-list-test
(testing "default switch"
(is (= ["switch"] (switch/switch-class-list {}))))
(testing "disabled switch"
(is (= ["switch" "switch--disabled"] (switch/switch-class-list {:disabled true})))))
(deftest switch-component-test
(testing "renders a label"
(let [result (switch/switch-toggle {:label "Notifications"})]
(is (= :label (first result)))
(is (= "switch" (get-in result [1 :class])))))
(testing "checked switch has checked track class"
(let [result (switch/switch-toggle {:checked true :label "On"})]
;; Find the track span
(let [track (nth result 3)]
(is (= "switch-track switch-track--checked" (get-in track [1 :class]))))))
(testing "unchecked switch has no checked track class"
(let [result (switch/switch-toggle {:checked false :label "Off"})]
(let [track (nth result 3)]
(is (= "switch-track" (get-in track [1 :class])))))))