Skip to content

Commit 1bcb933

Browse files
committed
Fix test for calendar component
1 parent d8594a5 commit 1bcb933

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

test/collected_live_web/components/calendar_component_test.exs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,20 @@ defmodule ComponentsGuideWeb.CalendarComponentTest do
1111
{:ok, el: el}
1212
end
1313

14-
@tag assigns: [date: ~D[2022-04-01]]
15-
test "April 1 2022", %{el: el} do
14+
@tag assigns: [year: 2022, month: 4]
15+
test "April 2022", a do
16+
%{el: el} = a
17+
current_date = el |> find("td[aria-current=date]")
18+
assert current_date |> Enum.count() == 0
19+
20+
assert 7 == count(el, "thead th")
21+
assert 5 == count(el, "tbody tr")
22+
assert 30 == count(el, "tbody td:not([role=presentation])")
23+
end
24+
25+
@tag assigns: [year: 2022, month: 4, current_date: ~D[2022-04-01]]
26+
test "April 2022 with 1st as current date", a do
27+
%{el: el} = a
1628
current_date = el |> find("td[aria-current=date]")
1729
assert "1" == current_date |> text() |> String.trim()
1830
assert current_date |> Enum.count() == 1
@@ -22,14 +34,14 @@ defmodule ComponentsGuideWeb.CalendarComponentTest do
2234
assert 30 == count(el, "tbody td:not([role=presentation])")
2335
end
2436

25-
@tag assigns: [date: ~D[2022-04-15]]
26-
test "April 15 2022", %{el: el} do
37+
@tag assigns: [year: 2022, month: 4, current_date: ~D[2022-04-15]]
38+
test "April 2022 with 15th as current date", %{el: el} do
2739
current_date = el |> find("td[aria-current=date]")
2840
assert "15" == current_date |> text() |> String.trim()
2941
end
3042

31-
@tag assigns: [date: ~D[2022-01-03]]
32-
test "January 3 2022", %{el: el} do
43+
@tag assigns: [year: 2022, month: 1, current_date: ~D[2022-01-03]]
44+
test "January 2022 with 3rd as current date", %{el: el} do
3345
current_date = el |> find("td[aria-current=date]")
3446
assert "3" == current_date |> text() |> String.trim()
3547
assert 31 == count(el, "tbody td:not([role=presentation])")

0 commit comments

Comments
 (0)