@@ -11,40 +11,28 @@ defmodule ComponentsGuideWeb.CalendarComponentTest do
11
11
{ :ok , el: el }
12
12
end
13
13
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
17
16
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 ( )
30
18
assert current_date |> Enum . count ( ) == 1
31
19
32
20
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])" )
35
23
end
36
24
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
39
27
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 ( )
41
29
end
42
30
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
45
33
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])" )
48
36
end
49
37
end
50
38
end
0 commit comments