Files
clj-ui-framework/test/ui/breadcrumb_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

38 lines
1.4 KiB
Clojure

(ns ui.breadcrumb-test
(:require [clojure.test :refer [deftest is testing]]
[ui.breadcrumb :as breadcrumb]))
(deftest breadcrumb-component-test
(testing "renders a nav with breadcrumb list"
(let [result (breadcrumb/breadcrumb
{:items [{:label "Home" :href "/"}
{:label "Projects" :href "/projects"}
{:label "Current"}]})]
(is (= :nav (first result)))
(is (= "Breadcrumb" (get-in result [1 :aria-label])))
;; ol is inside
(let [ol (nth result 2)]
(is (= :ol (first ol)))
(is (= "breadcrumb" (get-in ol [1 :class])))
;; 3 items
(is (= 3 (count (drop 2 ol)))))))
(testing "last item is active"
(let [result (breadcrumb/breadcrumb
{:items [{:label "Home" :href "/"}
{:label "Active"}]})
ol (nth result 2)
items (drop 2 ol)
last-item (last items)]
(is (clojure.string/includes? (get-in last-item [1 :class]) "breadcrumb-item--active")))))
(deftest breadcrumb-links-test
(testing "non-active items have links"
(let [result (breadcrumb/breadcrumb
{:items [{:label "Home" :href "/"}
{:label "End"}]})
ol (nth result 2)
first-item (nth ol 2)]
;; first item should have an anchor child
(is (= :a (first (nth first-item 2)))))))