@@ -1,4 +1,43 @@
1−module Testable.Element exposing (..)
1+module Testable.Element exposing
2+ ( Length(..)
3+ , above
4+ , alignBottom
5+ , alignLeft
6+ , alignRight
7+ , alignTop
8+ , alpha
9+ , behindContent
10+ , below
11+ , centerX
12+ , centerY
13+ , column
14+ , el
15+ , expectRoundedEquality
16+ , fill
17+ , fillPortion
18+ , height
19+ , heightHelper
20+ , inFront
21+ , isVisible
22+ , label
23+ , maximum
24+ , minimum
25+ , none
26+ , onLeft
27+ , onRight
28+ , padding
29+ , paddingXY
30+ , paragraph
31+ , px
32+ , row
33+ , shrink
34+ , spacing
35+ , text
36+ , textColumn
37+ , transparent
38+ , width
39+ , widthHelper
40+ )
241
342{-| This module should mirror the top level `Element` api, with one important distinction.
443
@@ -15,6 +54,7 @@ In order to run the test:
1554import Dict
1655import Element
1756import Expect
57+import Html.Attributes
1858import Testable
1959
2060
@@ -100,6 +140,7 @@ transparent on =
100140 { label =
101141 if on then
102142 "transparent"
143+
103144 else
104145 "opaque"
105146 , attr = Element.transparent on
@@ -114,6 +155,7 @@ transparent on =
114155 value =
115156 if on then
116157 "0"
158+
117159 else
118160 "1"
119161 in
@@ -121,6 +163,18 @@ transparent on =
121163 }
122164
123165
166+{-| -}
167+isVisible : Testable.Attr msg
168+isVisible =
169+ Testable.LabeledTest
170+ { label = "is-visible"
171+ , attr = Element.htmlAttribute (Html.Attributes.style "not" "applicable")
172+ , test =
173+ \context _ ->
174+ Expect.equal context.self.isVisible True
175+ }
176+
177+
124178{-| -}
125179alpha : Float -> Testable.Attr msg
126180alpha a =
@@ -265,6 +319,7 @@ widthHelper maybeMin maybeMax len =
265319 \context _ ->
266320 if List.member context.location [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
267321 Expect.true "width fill doesn't apply to onright/onleft elements" True
322+
268323 else
269324 let
270325 parentAvailableWidth =
@@ -329,6 +384,7 @@ widthHelper maybeMin maybeMax len =
329384 -- TODO: The issue is that we have a hard time measuring `text` elements
330385 -- So if a element has a text child, then it's width isn't going to show up in the system.
331386 expectRoundedEquality context.self.bbox.width context.self.bbox.width
387+
332388 else
333389 -- This fails if this element is actually a column
334390 -- So we need to capture what this element is in order to do this calculation.
@@ -422,6 +478,7 @@ heightHelper maybeMin maybeMax len =
422478 \context _ ->
423479 if List.member context.location [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
424480 Expect.true "height fill doesn't apply to above/below elements" True
481+
425482 else
426483 let
427484 parentAvailableHeight =
@@ -486,6 +543,7 @@ heightHelper maybeMin maybeMax len =
486543 -- TODO: The issue is that we have a hard time measuring `text` elements
487544 -- So if a element has a text child, then it's height isn't going to show up in the system.
488545 expectRoundedEquality context.self.bbox.height context.self.bbox.height
546+
489547 else
490548 -- This fails if this element is actually a column
491549 -- So we need to capture what this element is in order to do this calculation.
@@ -529,10 +587,12 @@ spacing space =
529587 in
530588 [ if horizontal > 0 then
531589 horizontal
590+
532591 else
533592 space
534593 , if vertical > 0 then
535594 vertical
595+
536596 else
537597 space
538598 ]
@@ -548,6 +608,7 @@ spacing space =
548608 (\x wrong ->
549609 if not (x >= space) then
550610 x :: wrong
611+
551612 else
552613 wrong
553614 )
@@ -588,6 +649,7 @@ alignLeft =
588649 \found _ ->
589650 if List.member found.location [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
590651 Expect.true "alignLeft doesn't apply to elements that are onLeft or onRight" True
652+
591653 else if
592654 List.member found.location
593655 [ Testable.IsNearby Testable.InFront
@@ -599,10 +661,12 @@ alignLeft =
599661 expectRoundedEquality
600662 found.self.bbox.left
601663 found.parent.bbox.left
664+
602665 else if List.length found.siblings == 0 then
603666 expectRoundedEquality
604667 found.self.bbox.left
605668 (found.parent.bbox.left + found.parent.bbox.padding.left)
669+
606670 else
607671 case found.location of
608672 Testable.InRow ->
@@ -648,10 +712,12 @@ centerX =
648712 in
649713 if List.member found.location [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
650714 Expect.true "centerX doesn't apply to elements that are onLeft or onRight" True
715+
651716 else if List.length found.siblings == 0 then
652717 expectRoundedEquality
653718 selfCenter
654719 parentCenter
720+
655721 else
656722 case found.location of
657723 Testable.InRow ->
@@ -702,6 +768,7 @@ alignRight =
702768 \found _ ->
703769 if List.member found.location [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
704770 Expect.true "alignRight doesn't apply to elements that are onLeft or onRight" True
771+
705772 else if
706773 List.member found.location
707774 [ Testable.IsNearby Testable.InFront
@@ -713,10 +780,12 @@ alignRight =
713780 expectRoundedEquality
714781 found.self.bbox.right
715782 found.parent.bbox.right
783+
716784 else if List.length found.siblings == 0 then
717785 expectRoundedEquality
718786 found.self.bbox.right
719787 (found.parent.bbox.right + found.parent.bbox.padding.right)
788+
720789 else
721790 case found.location of
722791 Testable.InRow ->
@@ -753,6 +822,7 @@ alignTop =
753822 \found _ ->
754823 if List.member found.location [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
755824 Expect.true "alignTop doesn't apply to elements that are above or below" True
825+
756826 else if
757827 List.member found.location
758828 [ Testable.IsNearby Testable.InFront
@@ -764,10 +834,12 @@ alignTop =
764834 expectRoundedEquality
765835 found.self.bbox.top
766836 found.parent.bbox.top
837+
767838 else if List.length found.siblings == 0 then
768839 expectRoundedEquality
769840 found.self.bbox.top
770841 (found.parent.bbox.top + found.parent.bbox.padding.top)
842+
771843 else
772844 case found.location of
773845 Testable.InColumn ->
@@ -804,6 +876,7 @@ alignBottom =
804876 \found _ ->
805877 if List.member found.location [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
806878 Expect.true "alignBottom doesn't apply to elements that are above or below" True
879+
807880 else if
808881 List.member found.location
809882 [ Testable.IsNearby Testable.InFront
@@ -815,10 +888,12 @@ alignBottom =
815888 expectRoundedEquality
816889 found.self.bbox.bottom
817890 found.parent.bbox.bottom
891+
818892 else if List.length found.siblings == 0 then
819893 expectRoundedEquality
820894 found.self.bbox.bottom
821895 (found.parent.bbox.bottom + found.parent.bbox.padding.bottom)
896+
822897 else
823898 case found.location of
824899 Testable.InColumn ->
@@ -867,10 +942,12 @@ centerY =
867942 in
868943 if List.member found.location [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
869944 Expect.true "centerY doesn't apply to elements that are above or below" True
945+
870946 else if List.length found.siblings == 0 then
871947 expectRoundedEquality
872948 selfCenter
873949 parentCenter
950+
874951 else
875952 case found.location of
876953 Testable.InColumn ->
@@ -978,6 +1055,7 @@ inFront element =
9781055 [ (found.self.bbox.right <= found.parent.bbox.right)
9791056 || (found.self.bbox.left >= found.parent.bbox.left)
9801057 ]
1058+
9811059 else
9821060 [ found.self.bbox.right <= found.parent.bbox.right
9831061 , found.self.bbox.left >= found.parent.bbox.left
@@ -988,6 +1066,7 @@ inFront element =
9881066 [ (found.self.bbox.top >= found.parent.bbox.top)
9891067 || (found.self.bbox.bottom <= found.parent.bbox.bottom)
9901068 ]
1069+
9911070 else
9921071 [ found.self.bbox.top >= found.parent.bbox.top
9931072 , found.self.bbox.bottom <= found.parent.bbox.bottom
@@ -1019,6 +1098,7 @@ behindContent element =
10191098 [ (found.self.bbox.right <= found.parent.bbox.right)
10201099 || (found.self.bbox.left >= found.parent.bbox.left)
10211100 ]
1101+
10221102 else
10231103 [ found.self.bbox.right <= found.parent.bbox.right
10241104 , found.self.bbox.left >= found.parent.bbox.left
@@ -1029,6 +1109,7 @@ behindContent element =
10291109 [ (found.self.bbox.top >= found.parent.bbox.top)
10301110 || (found.self.bbox.bottom <= found.parent.bbox.bottom)
10311111 ]
1112+
10321113 else
10331114 [ found.self.bbox.top >= found.parent.bbox.top
10341115 , found.self.bbox.bottom <= found.parent.bbox.bottom