towerops/test/towerops_web/live/config_timeline_live_helpers_test.exs
Graham McIntire ebcd54be5b refactor: remove daisyUI, use straight Tailwind v4 with custom color palette
- Remove daisyUI plugins and theme from app.css
- Define 5 custom color palettes: sweet-salmon, desert-sand, wheat, cool-steel, cerulean
- Add @utility card, badge, btn classes to replace daisyUI components
- Replace all daisyUI classes across 16+ template files
- Update tests for new class return values
- Set light mode as default theme
2026-06-23 10:44:20 -05:00

58 lines
2 KiB
Elixir

defmodule ToweropsWeb.ConfigTimelineLiveHelpersTest do
use ExUnit.Case, async: true
alias ToweropsWeb.ConfigTimelineLive
describe "change_size_class/1" do
test "> 50 returns error styling" do
assert "bg-sweet-salmon-100 text-sweet-salmon-800 dark:bg-sweet-salmon-900/30 dark:text-sweet-salmon-400" ==
ConfigTimelineLive.change_size_class(51)
assert "bg-sweet-salmon-100 text-sweet-salmon-800 dark:bg-sweet-salmon-900/30 dark:text-sweet-salmon-400" ==
ConfigTimelineLive.change_size_class(1_000)
end
test "21..50 returns warning styling" do
assert "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400" ==
ConfigTimelineLive.change_size_class(21)
assert "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400" ==
ConfigTimelineLive.change_size_class(50)
end
test "<= 20 returns info styling" do
assert "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400" == ConfigTimelineLive.change_size_class(0)
assert "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400" ==
ConfigTimelineLive.change_size_class(20)
end
test "non-integer returns info styling" do
assert "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400" ==
ConfigTimelineLive.change_size_class(nil)
assert "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400" ==
ConfigTimelineLive.change_size_class("foo")
end
end
describe "timeline_event/1" do
test "serializes to ISO timestamp map" do
changed_at = ~U[2026-01-15 12:00:00Z]
event = %{
id: "evt-1",
changed_at: changed_at,
sections_changed: ["dhcp", "ospf"],
change_size: 42
}
assert %{
id: "evt-1",
t: "2026-01-15T12:00:00Z",
sections: ["dhcp", "ospf"],
size: 42
} == ConfigTimelineLive.timeline_event(event)
end
end
end