@@ -11,40 +11,28 @@ defmodule ComponentsGuideWeb.CalendarComponentTest do
1111 { :ok , el: el }
1212 end
1313
14- @ tag assigns: [ year: 2022 , month: 4 ]
15- test "April 2022" , a do
16- % { el: el } = a
14+ @ tag assigns: [ current_date: ~D[ 2022-04-01] ]
15+ test "1st April 2022" , % { el: el } do
1716 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
28- current_date = el |> find ( "td[aria-current=date]" )
29- assert "1" == current_date |> text ( ) |> String . trim ( )
17+ assert "01 Apr" == current_date |> text ( ) |> String . trim ( )
3018 assert current_date |> Enum . count ( ) == 1
3119
3220 assert 7 == count ( el , "thead th" )
33- assert 5 == count ( el , "tbody tr" )
34- assert 30 == count ( el , "tbody td:not([role=presentation])" )
21+ assert 9 == count ( el , "tbody tr" )
22+ assert 9 * 7 == count ( el , "tbody td:not([role=presentation])" )
3523 end
3624
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
25+ @ tag assigns: [ current_date: ~D[ 2022-04-15] ]
26+ test "15th April 2022 " , % { el: el } do
3927 current_date = el |> find ( "td[aria-current=date]" )
40- assert "15" == current_date |> text ( ) |> String . trim ( )
28+ assert "15 Apr " == current_date |> text ( ) |> String . trim ( )
4129 end
4230
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
31+ @ tag assigns: [ current_date: ~D[ 2022-01-03] ]
32+ test "3rd January 2022 " , % { el: el } do
4533 current_date = el |> find ( "td[aria-current=date]" )
46- assert "3 " == current_date |> text ( ) |> String . trim ( )
47- assert 31 == count ( el , "tbody td:not([role=presentation])" )
34+ assert "03 Jan " == current_date |> text ( ) |> String . trim ( )
35+ assert 9 * 7 == count ( el , "tbody td:not([role=presentation])" )
4836 end
4937 end
5038end
0 commit comments