@@ -10,7 +10,6 @@ module Testable.Element exposing
16 , expectRoundedEquality
15 , expectRoundedEquality
@@ -38,9 +37,6 @@ module Testable.Element exposing
@@ -136,31 +132,8 @@ link :
137 -> Testable.Element msg
133 -> Testable.Element msg
138link attrs details =
134link attrs details =
139− Testable.Link details.url
135+ -- TODO: this is not actually a link element!!
140− (implicitWidthHeightShrink attrs)
136+ Testable.El (implicitWidthHeightShrink attrs) details.label
145− Testable.Attr Element.clip
149−scrollbars : Testable.Attr msg
151− Testable.Attr Element.scrollbars
155−scrollbarY : Testable.Attr msg
157− Testable.Attr Element.scrollbarY
161−scrollbarX : Testable.Attr msg
163− Testable.Attr Element.scrollbarX
166{-| Old labeling mechanism that i removed to hastily
139{-| Old labeling mechanism that i removed to hastily
@@ -334,11 +307,6 @@ paddingXY x y =
338− List.filter Tuple.first ls
339− |> List.map Tuple.second
342widthHelper maybeMin maybeMax len =
310widthHelper maybeMin maybeMax len =
344 addMin l =
312 addMin l =
@@ -497,31 +465,12 @@ widthHelper maybeMin maybeMax len =
497 totalChildren + horizontalPadding
465 totalChildren + horizontalPadding
499 expectedLines =
467 expectedLines =
500− if boxChildrenHeight > 20 then
501− ceiling (boxChildrenHeight / 20)
504− ceiling (totalCalculatedWidth / context.self.bbox.width)
468+ ceiling (totalCalculatedWidth / context.self.bbox.width)
514− [ Testable.true "text wrapping, checking height"
470+ [ Testable.rounded "text wrapping, checking height"
515− -- all we're doing here is testing if wrapping is occurring
516− -- not the exact height, which is a little tricky to calculate perfectly without more information.
517− (if expectedLines > 1 then
471+ { expected = toFloat (expectedLines * 22)
518− context.self.bbox.height >= (20 * 2)
521− -- then it's less than 2 ~ line heights
522− -- there's some weird variance here which makes it hard to be exact.
523− context.self.bbox.height < (20 * 2)
472+ , found = context.self.bbox.height
@@ -555,50 +504,23 @@ widthHelper maybeMin maybeMax len =
556 horizontalPadding =
505 horizontalPadding =
557 context.self.bbox.padding.left + context.self.bbox.padding.right
506 context.self.bbox.padding.left + context.self.bbox.padding.right
560− [ ( (context.parentLayout /= Testable.InParagraph)
561− && (context.parentLayout /= Testable.InTextCol)
562− , Testable.rounded "equals children"
563− { expected = totalChildren + horizontalPadding
564− , found = context.self.bbox.width
567− , ( context.parentLayout /= Testable.AtRoot
568− , Testable.lessThanOrEqual "not larger than parent"
569− context.self.bbox.width
570− context.parent.bbox.width
574− Testable.Link _ _ _ ->
579− totalChildren =
508+ _ =
580− context.children
511+ context.children
581− |> List.map childWidth
512+ |> List.map childWidth
582− |> List.append (List.map .width context.self.textMetrics)
513+ , text = List.map .width context.self.textMetrics
586− context.self.bbox.padding.left + context.self.bbox.padding.right
589− [ ( (context.parentLayout /= Testable.InParagraph)
590− && (context.parentLayout /= Testable.InTextCol)
591− , Testable.rounded "equals children"
592− { expected = totalChildren + horizontalPadding
593− , found = context.self.bbox.width
596− , ( context.parentLayout /= Testable.AtRoot
516+ [ Testable.rounded "equals children"
517+ { expected = totalChildren + horizontalPadding
518+ , found = context.self.bbox.width
597− , Testable.lessThanOrEqual "not larger than parent"
520+ , Testable.lessThanOrEqual "not larger than parent"
598− context.self.bbox.width
521+ context.self.bbox.width
599− context.parent.bbox.width
522+ context.parent.bbox.width
603 Testable.Row rowAttrs _ ->
525 Testable.Row rowAttrs _ ->
604 -- width of row is the sum of all children widths
526 -- width of row is the sum of all children widths
@@ -622,19 +544,14 @@ widthHelper maybeMin maybeMax len =
622 totalSpacing =
544 totalSpacing =
623 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
545 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
627− , expectRoundedEquality
547+ [ expectRoundedEquality
628− { expected = totalChildren + horizontalPadding + totalSpacing
548+ { expected = totalChildren + horizontalPadding + totalSpacing
629− , found = context.self.bbox.width
549+ , found = context.self.bbox.width
632− , ( context.parentLayout /= Testable.AtRoot
633− , Testable.lessThanOrEqual "not larger than parent"
551+ , Testable.lessThanOrEqual "not larger than parent"
634− context.self.bbox.width
552+ context.self.bbox.width
635− context.parent.bbox.width
553+ context.parent.bbox.width
639 Testable.Column _ _ ->
556 Testable.Column _ _ ->
640 -- The width of the column is the width of the widest child.
557 -- The width of the column is the width of the widest child.
@@ -658,19 +575,14 @@ widthHelper maybeMin maybeMax len =
658 |> List.map childWidth
575 |> List.map childWidth
659 |> List.append textChildren
576 |> List.append textChildren
663− , expectRoundedEquality
578+ [ expectRoundedEquality
664− { expected = Maybe.withDefault 0 (List.maximum allChildren)
579+ { expected = Maybe.withDefault 0 (List.maximum allChildren)
665− , found = context.self.bbox.width
580+ , found = context.self.bbox.width
668− , ( context.parentLayout /= Testable.AtRoot
669− , Testable.lessThanOrEqual "not larger than parent"
582+ , Testable.lessThanOrEqual "not larger than parent"
670− context.self.bbox.width
583+ context.self.bbox.width
671− context.parent.bbox.width
584+ context.parent.bbox.width
675 Testable.TextColumn _ _ ->
587 Testable.TextColumn _ _ ->
676 -- The width of the column is the width of the widest child.
588 -- The width of the column is the width of the widest child.
@@ -694,19 +606,14 @@ widthHelper maybeMin maybeMax len =
694 |> List.map childWidth
606 |> List.map childWidth
695 |> List.append textChildren
607 |> List.append textChildren
699− , expectRoundedEquality
609+ [ expectRoundedEquality
700− { expected = Maybe.withDefault 0 (List.maximum allChildren)
610+ { expected = Maybe.withDefault 0 (List.maximum allChildren)
701− , found = context.self.bbox.width
611+ , found = context.self.bbox.width
704− , ( context.parentLayout /= Testable.AtRoot
705− , Testable.lessThanOrEqual "not larger than parent"
613+ , Testable.lessThanOrEqual "not larger than parent"
706− context.self.bbox.width
614+ context.self.bbox.width
707− context.parent.bbox.width
615+ context.parent.bbox.width
711 Testable.Paragraph _ _ ->
618 Testable.Paragraph _ _ ->
712 -- This should be the size it's text,
619 -- This should be the size it's text,
@@ -724,19 +631,14 @@ widthHelper maybeMin maybeMax len =
724 horizontalPadding =
631 horizontalPadding =
725 context.self.bbox.padding.left + context.self.bbox.padding.right
632 context.self.bbox.padding.left + context.self.bbox.padding.right
729− , expectRoundedEquality
634+ [ expectRoundedEquality
730− { expected = totalChildren + horizontalPadding
635+ { expected = totalChildren + horizontalPadding
731− , found = context.self.bbox.width
636+ , found = context.self.bbox.width
734− , ( context.parentLayout /= Testable.AtRoot
735− , Testable.lessThanOrEqual "not larger than parent"
638+ , Testable.lessThanOrEqual "not larger than parent"
736− context.self.bbox.width
639+ context.self.bbox.width
737− context.parent.bbox.width
640+ context.parent.bbox.width
741 Testable.Text _ ->
643 Testable.Text _ ->
@@ -890,45 +792,20 @@ heightHelper maybeMin maybeMax len =
890 childHeight child =
792 childHeight child =
891 child.bbox.height
793 child.bbox.height
893− if List.isEmpty context.children then
795+ [ if List.isEmpty context.children then
894 -- context.self.textMetrics
796 -- context.self.textMetrics
895 -- |> List.map Testable.textHeight
797 -- |> List.map Testable.textHeight
896 -- |> List.sum
798 -- |> List.sum
897 -- TODO: apparently the font metrics we have are for the literal characters rendered
799 -- TODO: apparently the font metrics we have are for the literal characters rendered
898 -- not for the font itself.
800 -- not for the font itself.
899− [ Testable.todo "calculate height from actual text metrics"
801+ -- so for now, we are stubbing this in as 20, which is the default font size + line height.
900− ]
802+ Testable.rounded "expected multiple of 20"
903− [ expectRoundedEquality
904− { expected =
803+ { expected = context.self.bbox.height
905− context.children
804+ , found = toFloat (List.length context.self.textMetrics * 20)
906− |> List.map childHeight
908− |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
909− , found = context.self.bbox.height
911− , Testable.lessThanOrEqual "not larger than parent"
912− context.self.bbox.height
913− context.parent.bbox.height
916− Testable.Link _ _ _ ->
921− if List.isEmpty context.children then
922− -- context.self.textMetrics
923− -- |> List.map Testable.textHeight
925− -- TODO: apparently the font metrics we have are for the literal characters rendered
926− -- not for the font itself.
927− [ Testable.todo "calculate height from actual text metrics"
931− [ expectRoundedEquality
808+ expectRoundedEquality
932 { expected =
809 { expected =
933 context.children
810 context.children
934 |> List.map childHeight
811 |> List.map childHeight
@@ -936,26 +813,28 @@ heightHelper maybeMin maybeMax len =
936 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
813 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
937 , found = context.self.bbox.height
814 , found = context.self.bbox.height
939− , Testable.lessThanOrEqual "not larger than parent"
816+ , Testable.lessThanOrEqual "not larger than parent"
940− context.self.bbox.height
817+ context.self.bbox.height
941− context.parent.bbox.height
818+ context.parent.bbox.height
944 Testable.Row _ _ ->
821 Testable.Row _ _ ->
946 childHeight child =
823 childHeight child =
947 child.bbox.height
824 child.bbox.height
949− if List.isEmpty context.children then
826+ [ if List.isEmpty context.children then
950 -- context.self.textMetrics
827 -- context.self.textMetrics
951 -- |> List.map Testable.textHeight
828 -- |> List.map Testable.textHeight
952 -- |> List.sum
829 -- |> List.sum
953 -- TODO: apparently the font metrics we have are for the literal characters rendered
830 -- TODO: apparently the font metrics we have are for the literal characters rendered
954 -- not for the font itself.
831 -- not for the font itself.
955− [ Testable.todo "calculate height from actual text metrics" ]
832+ -- so for now, we are stubbing this in as 20, which is the default font size.
833+ Testable.true "expected multiple of 20"
834+ ((round context.self.bbox.height |> modBy 20) == 0)
958− [ expectRoundedEquality
837+ expectRoundedEquality
959 { expected =
838 { expected =
960 context.children
839 context.children
961 |> List.map childHeight
840 |> List.map childHeight
@@ -964,10 +843,10 @@ heightHelper maybeMin maybeMax len =
964 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
843 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
965 , found = context.self.bbox.height
844 , found = context.self.bbox.height
967− , Testable.lessThanOrEqual "not larger than parent"
846+ , Testable.lessThanOrEqual "not larger than parent"
968− context.self.bbox.height
847+ context.self.bbox.height
969− context.parent.bbox.height
848+ context.parent.bbox.height
972 Testable.Column colAttrs _ ->
851 Testable.Column colAttrs _ ->
@@ -999,10 +878,16 @@ heightHelper maybeMin maybeMax len =
1001 Testable.TextColumn _ _ ->
880 Testable.TextColumn _ _ ->
881+ [ Testable.lessThanOrEqual "not larger than parent"
882+ context.self.bbox.height
883+ context.parent.bbox.height
1004 Testable.Paragraph _ _ ->
886 Testable.Paragraph _ _ ->
887+ [ Testable.lessThanOrEqual "not larger than parent"
888+ context.self.bbox.height
889+ context.parent.bbox.height
1007 Testable.Text _ ->
892 Testable.Text _ ->