Files
clj-ui-framework/test/ui/chip_test.clj
Florian Schroedl 9f3ebe453f refactor(dev): dogfood framework CSS in theme adapter panel
Replace all inline styles in theme-adapter.js with framework classes.
The panel now uses its own tokens (var(--bg-1), var(--fg-0), etc.) so
it visually adapts when you change theme colors — true dogfooding.

New framework components added to fill gaps:
- popover.css — fixed-position floating panel (.popover, .popover-br)
- chip.css + chip.cljc — selectable preset buttons (.chip, .chip-active)
- swatch.css — color preview strips (.swatch-row, .swatch)
- button.css — icon-only buttons (.btn-icon, .btn-icon-round)
- card.css — sectioned card variant (.card-flush, .card-section)
- utilities.css — text/flex helpers (.text-xs, .font-semibold, .flex-1, etc.)

Theme adapter JS shrunk from 340 to 250 lines by removing the 60-line
inline style object and applyStyle() helper.
2026-03-11 16:53:08 +01:00

37 lines
1.2 KiB
Clojure

(ns ui.chip-test
(:require [clojure.test :refer [deftest is testing]]
[ui.chip :as chip]))
(deftest chip-class-list-test
(testing "default chip"
(is (= ["chip"] (chip/chip-class-list {}))))
(testing "active chip"
(is (= ["chip" "chip-active"] (chip/chip-class-list {:active true})))))
(deftest chip-classes-test
(testing "space-joined"
(is (= "chip" (chip/chip-classes {})))
(is (= "chip chip-active" (chip/chip-classes {:active true})))))
(deftest chip-component-test
(testing "basic chip renders button"
(let [[tag attrs & children] (chip/chip {} "Label")]
(is (= :button tag))
(is (= "chip" (:class attrs)))
(is (= ["Label"] children))))
(testing "active chip"
(let [[tag attrs] (chip/chip {:active true} "Active")]
(is (= :button tag))
(is (= "chip chip-active" (:class attrs)))))
(testing "chip with dot-color"
(let [[_tag _attrs dot label] (chip/chip {:dot-color "#ff0000"} "Red")]
(is (= :span (first dot)))
(is (= "chip-dot" (:class (second dot))))
(is (= "Red" label))))
(testing "custom class"
(let [[_tag attrs] (chip/chip {:class "extra"} "X")]
(is (= "chip extra" (:class attrs))))))