@@ -10,6 +10,7 @@ module Testable.Element exposing
1010 , below
1111 , centerX
1212 , centerY
13+ , clip
1314 , column
1415 , el
1516 , expectRoundedEquality
@@ -20,9 +21,12 @@ module Testable.Element exposing
2021 , isVisible
2122 , label
2223 , layout
24+ , link
2325 , maximum
2426 , minimum
2527 , moveDown
28+ , moveLeft
29+ , moveRight
2630 , moveUp
2731 , none
2832 , onLeft
@@ -34,10 +38,14 @@ module Testable.Element exposing
3438 , rgb
3539 , rgba
3640 , row
41+ , scrollbarX
42+ , scrollbarY
43+ , scrollbars
3744 , shrink
3845 , spacing
3946 , text
4047 , textColumn
48+ , toProgram
4149 , transparent
4250 , width
4351 )
@@ -56,17 +64,21 @@ In order to run the test:
5664
5765import Dict
5866import Element
59−import Expect
6067import Html.Attributes
6168import Testable
6269import Testable.Runner
6370
6471
65−layout : List (Testable.Attr msg) -> Testable.Element Testable.Runner.Msg -> Testable.Runner.TestableProgram
72+{-| This is used when we want to run all tests in a test suite instead of one at a time.
73+-}
74+toProgram : Testable.Runner.Testable -> Testable.Runner.TestableProgram
75+toProgram testable =
76+ Testable.Runner.program [ testable ]
77+
78+
79+layout : List (Testable.Attr msg) -> Testable.Element Testable.Runner.Msg -> Testable.Runner.Testable
6680layout attrs elem =
67− Testable.Runner.program
68− [ ( "Open Case", elem )
69− ]
81+ Testable.Runner.testable "Test" elem
7082
7183
7284text : String -> Testable.Element msg
@@ -75,18 +87,18 @@ text =
7587
7688
7789el : List (Testable.Attr msg) -> Testable.Element msg -> Testable.Element msg
78−el =
79− Testable.El
90+el attrs =
91+ Testable.El (implicitWidthHeightShrink attrs)
8092
8193
8294row : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
83−row =
84− Testable.Row
95+row attrs =
96+ Testable.Row (implicitWidthHeightShrink attrs)
8597
8698
8799column : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
88−column =
89− Testable.Column
100+column attrs =
101+ Testable.Column (implicitWidthHeightShrink attrs)
90102
91103
92104none : Testable.Element msg
@@ -95,13 +107,66 @@ none =
95107
96108
97109paragraph : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
98−paragraph =
99− Testable.Paragraph
110+paragraph attrs =
111+ let
112+ withImplicits =
113+ implicitTest (widthHelper Nothing Nothing (Fill 1))
114+ :: implicitTest (heightHelper Nothing Nothing Shrink)
115+ :: attrs
116+ in
117+ Testable.Paragraph (skipOverridden withImplicits)
100118
101119
102120textColumn : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
103−textColumn =
104− Testable.TextColumn
121+textColumn attrs =
122+ let
123+ withImplicits =
124+ implicitTest (widthHelper (Just 500) (Just 750) (Fill 1))
125+ :: implicitTest (heightHelper Nothing Nothing Shrink)
126+ :: attrs
127+ in
128+ Testable.TextColumn (skipOverridden withImplicits)
129+
130+
131+link :
132+ List (Testable.Attr msg)
133+ ->
134+ { url : String
135+ , label : Testable.Element msg
136+ }
137+ -> Testable.Element msg
138+link attrs details =
139+ Testable.Link details.url
140+ (implicitWidthHeightShrink attrs)
141+ details.label
142+
143+
144+clip =
145+ Testable.Attr Element.clip
146+
147+
148+{-| -}
149+scrollbars : Testable.Attr msg
150+scrollbars =
151+ Testable.Attr Element.scrollbars
152+
153+
154+{-| -}
155+scrollbarY : Testable.Attr msg
156+scrollbarY =
157+ Testable.Attr Element.scrollbarY
158+
159+
160+{-| -}
161+scrollbarX : Testable.Attr msg
162+scrollbarX =
163+ Testable.Attr Element.scrollbarX
164+
165+
166+{-| Old labeling mechanism that i removed to hastily
167+-}
168+label str =
169+ Testable.Batch []
105170
106171
107172moveUp x =
@@ -112,6 +177,14 @@ moveDown x =
112177 Testable.Attr (Element.moveDown x)
113178
114179
180+moveRight x =
181+ Testable.Attr (Element.moveRight x)
182+
183+
184+moveLeft x =
185+ Testable.Attr (Element.moveLeft x)
186+
187+
115188type Length
116189 = Px Int
117190 | Fill Int
@@ -156,11 +229,6 @@ fillPortion =
156229 Fill
157230
158231
159−label : String -> Testable.Attr msg
160−label =
161− Testable.Label
162−
163−
164232transparent : Bool -> Testable.Attr msg
165233transparent on =
166234 Testable.LabeledTest
@@ -171,8 +239,9 @@ transparent on =
171239 else
172240 "opaque"
173241 , attr = Element.transparent on
242+ , id = Testable.NoId
174243 , test =
175− \context _ ->
244+ \context ->
176245 let
177246 selfTransparency =
178247 context.self.style
@@ -186,19 +255,19 @@ transparent on =
186255 else
187256 "1"
188257 in
189− Expect.equal value selfTransparency
258+ [ Testable.equal value selfTransparency ]
190259 }
191260
192261
193262{-| -}
194263isVisible : Testable.Attr msg
195264isVisible =
196− Testable.LabeledTest
265+ Testable.AttrTest
197266 { label = "is-visible"
198− , attr = Element.htmlAttribute (Html.Attributes.style "not" "applicable")
267+ , id = Testable.NoId
199268 , test =
200− \context _ ->
201− Expect.equal context.self.isVisible True
269+ \context ->
270+ [ Testable.equal context.self.isVisible True ]
202271 }
203272
204273
@@ -208,15 +277,16 @@ alpha a =
208277 Testable.LabeledTest
209278 { label = "alpha-" ++ String.fromFloat a
210279 , attr = Element.alpha a
280+ , id = Testable.NoId
211281 , test =
212− \context _ ->
282+ \context ->
213283 let
214284 selfTransparency =
215285 context.self.style
216286 |> Dict.get "opacity"
217287 |> Maybe.withDefault "notfound"
218288 in
219− Expect.equal (String.fromFloat a) selfTransparency
289+ [ Testable.equal (String.fromFloat a) selfTransparency ]
220290 }
221291
222292
@@ -226,9 +296,10 @@ padding pad =
226296 Testable.LabeledTest
227297 { label = "padding " ++ String.fromInt pad
228298 , attr = Element.padding pad
299+ , id = Testable.NoId
229300 , test =
230− \found _ ->
231− Expect.true ("Padding " ++ String.fromInt pad ++ " is present")
301+ \found ->
302+ [ Testable.true ("Padding " ++ String.fromInt pad ++ " is present")
232303 (List.all ((==) pad)
233304 [ floor found.self.bbox.padding.left
234305 , floor found.self.bbox.padding.right
@@ -236,6 +307,7 @@ padding pad =
236307 , floor found.self.bbox.padding.bottom
237308 ]
238309 )
310+ ]
239311 }
240312
241313
@@ -245,9 +317,10 @@ paddingXY x y =
245317 Testable.LabeledTest
246318 { label = "paddingXY " ++ String.fromInt x ++ ", " ++ String.fromInt y
247319 , attr = Element.paddingXY x y
320+ , id = Testable.NoId
248321 , test =
249− \found _ ->
250− Expect.true ("PaddingXY (" ++ String.fromInt x ++ ", " ++ String.fromInt y ++ ") is present")
322+ \found ->
323+ [ Testable.true ("PaddingXY (" ++ String.fromInt x ++ ", " ++ String.fromInt y ++ ") is present")
251324 (List.all ((==) x)
252325 [ floor found.self.bbox.padding.left
253326 , floor found.self.bbox.padding.right
@@ -257,9 +330,15 @@ paddingXY x y =
257330 , floor found.self.bbox.padding.bottom
258331 ]
259332 )
333+ ]
260334 }
261335
262336
337+listIf ls =
338+ List.filter Tuple.first ls
339+ |> List.map Tuple.second
340+
341+
263342widthHelper maybeMin maybeMax len =
264343 let
265344 addMin l =
@@ -319,6 +398,7 @@ widthHelper maybeMin maybeMax len =
319398 -- Pixel values should ignore min and max?
320399 Testable.LabeledTest
321400 { label = "width " ++ String.fromInt val ++ "px" ++ minLabel ++ maxLabel
401+ , id = Testable.IsWidth
322402 , attr =
323403 Element.width
324404 (Element.px val
@@ -326,18 +406,24 @@ widthHelper maybeMin maybeMax len =
326406 |> addMax
327407 )
328408 , test =
329− \found _ ->
330− Expect.all
331− [ \_ ->
332− Expect.true "exact width is exact" (floor found.self.bbox.width == val)
333− , \_ -> Expect.true "min/max is upheld" (minMaxTest (floor found.self.bbox.width))
334− ]
335− ()
409+ \found ->
410+ [ expectRoundedEquality
411+ { expected = toFloat val
412+ , found = found.self.bbox.width
413+ }
414+ , Testable.true "min/max is upheld" (minMaxTest (floor found.self.bbox.width))
415+ ]
336416 }
337417
338418 Fill portion ->
339419 Testable.LabeledTest
340− { label = "width fill-" ++ String.fromInt portion ++ minLabel ++ maxLabel
420+ { label =
421+ if portion == 1 then
422+ "width fill" ++ minLabel ++ maxLabel
423+
424+ else
425+ "width fill-" ++ String.fromInt portion ++ minLabel ++ maxLabel
426+ , id = Testable.IsWidth
341427 , attr =
342428 Element.width
343429 (Element.fillPortion portion
@@ -345,41 +431,102 @@ widthHelper maybeMin maybeMax len =
345431 |> addMax
346432 )
347433 , test =
348− \context _ ->
349− if List.member context.location [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
350− Expect.true "width fill doesn't apply to onright/onleft elements" True
434+ \context ->
435+ if List.member context.parentLayout [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
436+ [ Testable.true "width fill doesn't apply to onright/onleft elements" True ]
351437
352438 else
353439 let
354440 parentAvailableWidth =
355441 context.parent.bbox.width - (context.self.bbox.padding.left + context.self.bbox.padding.right)
356442 in
357− case context.location of
358− Testable.IsNearby _ ->
359− Expect.true "Nearby Element has fill width"
360− ((floor context.parent.bbox.width == floor context.self.bbox.width)
361− || minMaxTest (floor context.self.bbox.width)
362− )
363−
364− Testable.InColumn ->
365− Expect.true "Element within column has fill width"
366− ((floor parentAvailableWidth == floor context.self.bbox.width)
367− || minMaxTest (floor context.self.bbox.width)
368− )
369−
370− Testable.InEl ->
371− Expect.true "Element within element has fill width" <|
372− (floor parentAvailableWidth == floor context.self.bbox.width)
373− || minMaxTest (floor context.self.bbox.width)
374−
375− _ ->
376− let
377− spacePerPortion =
378− parentAvailableWidth / toFloat (List.length context.siblings + 1)
379− in
380− Expect.true "element has fill width" <|
381− (floor spacePerPortion == floor context.self.bbox.width)
382− || minMaxTest (floor context.self.bbox.width)
443+ List.concat
444+ [ case context.parentLayout of
445+ Testable.IsNearby _ ->
446+ [ Testable.true "Nearby Element has fill width"
447+ ((floor context.parent.bbox.width == floor context.self.bbox.width)
448+ || minMaxTest (floor context.self.bbox.width)
449+ )
450+ ]
451+
452+ Testable.InColumn ->
453+ [ Testable.true "Element within column has fill width"
454+ ((floor parentAvailableWidth == floor context.self.bbox.width)
455+ || minMaxTest (floor context.self.bbox.width)
456+ )
457+ ]
458+
459+ Testable.InEl ->
460+ [ Testable.true "Element within element has fill width" <|
461+ (floor parentAvailableWidth == floor context.self.bbox.width)
462+ || minMaxTest (floor context.self.bbox.width)
463+ ]
464+
465+ _ ->
466+ let
467+ spacePerPortion =
468+ parentAvailableWidth / toFloat (List.length context.siblings + 1)
469+ in
470+ [ Testable.true "element has fill width" <|
471+ (floor spacePerPortion == floor context.self.bbox.width)
472+ || minMaxTest (floor context.self.bbox.width)
473+ ]
474+ , [ Testable.lessThanOrEqual "not larger than parent"
475+ context.self.bbox.width
476+ context.parent.bbox.width
477+ ]
478+ , case context.selfElement of
479+ Testable.Paragraph _ _ ->
480+ -- A paragraph with width fill
481+ -- we want to test for correct text wrapping here.
482+ --
483+ let
484+ childWidth child =
485+ child.bbox.width
486+
487+ totalChildren =
488+ context.children
489+ |> List.map childWidth
490+ |> List.append (List.map .width context.self.textMetrics)
491+ |> List.sum
492+
493+ horizontalPadding =
494+ context.self.bbox.padding.left + context.self.bbox.padding.right
495+
496+ totalCalculatedWidth =
497+ totalChildren + horizontalPadding
498+
499+ expectedLines =
500+ if boxChildrenHeight > 20 then
501+ ceiling (boxChildrenHeight / 20)
502+
503+ else
504+ ceiling (totalCalculatedWidth / context.self.bbox.width)
505+
506+ boxChildrenHeight =
507+ context.children
508+ |> List.map
509+ (\c ->
510+ c.bbox.height
511+ )
512+ |> List.sum
513+ in
514+ [ Testable.true "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
518+ context.self.bbox.height >= (20 * 2)
519+
520+ else
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)
524+ )
525+ ]
526+
527+ _ ->
528+ []
529+ ]
383530 }
384531
385532 Shrink ->
@@ -391,33 +538,211 @@ widthHelper maybeMin maybeMax len =
391538 |> addMin
392539 |> addMax
393540 )
541+ , id = Testable.IsWidth
394542 , test =
395− \context _ ->
396− let
397− childWidth child =
398− -- TODO: add margin values to widths
399− child.bbox.width
400−
401− totalChildren =
402− context.children
403− |> List.map childWidth
404− |> List.sum
405−
406− horizontalPadding =
407− context.self.bbox.padding.left + context.self.bbox.padding.right
408−
409− spacingValue =
410− toFloat context.parentSpacing * (toFloat (List.length context.children) - 1)
411− in
412− if totalChildren == 0 then
413− -- TODO: The issue is that we have a hard time measuring `text` elements
414− -- So if a element has a text child, then it's width isn't going to show up in the system.
415− expectRoundedEquality context.self.bbox.width context.self.bbox.width
543+ \context ->
544+ case context.selfElement of
545+ Testable.El _ _ ->
546+ let
547+ childWidth child =
548+ child.bbox.width
549+
550+ totalChildren =
551+ context.children
552+ |> List.map childWidth
553+ |> List.append (List.map .width context.self.textMetrics)
554+ |> List.sum
555+
556+ horizontalPadding =
557+ context.self.bbox.padding.left + context.self.bbox.padding.right
558+ in
559+ listIf
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
565+ }
566+ )
567+ , ( context.parentLayout /= Testable.AtRoot
568+ , Testable.lessThanOrEqual "not larger than parent"
569+ context.self.bbox.width
570+ context.parent.bbox.width
571+ )
572+ ]
416573
417− else
418− -- This fails if this element is actually a column
419− -- So we need to capture what this element is in order to do this calculation.
420− expectRoundedEquality (totalChildren + horizontalPadding + spacingValue) context.self.bbox.width
574+ Testable.Link _ _ _ ->
575+ let
576+ childWidth child =
577+ child.bbox.width
578+
579+ totalChildren =
580+ context.children
581+ |> List.map childWidth
582+ |> List.append (List.map .width context.self.textMetrics)
583+ |> List.sum
584+
585+ horizontalPadding =
586+ context.self.bbox.padding.left + context.self.bbox.padding.right
587+ in
588+ listIf
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
594+ }
595+ )
596+ , ( context.parentLayout /= Testable.AtRoot
597+ , Testable.lessThanOrEqual "not larger than parent"
598+ context.self.bbox.width
599+ context.parent.bbox.width
600+ )
601+ ]
602+
603+ Testable.Row rowAttrs _ ->
604+ -- width of row is the sum of all children widths
605+ -- both text elements and others.
606+ let
607+ childWidth child =
608+ child.bbox.width
609+
610+ totalChildren =
611+ context.children
612+ |> List.map childWidth
613+ |> List.append (List.map .width context.self.textMetrics)
614+ |> List.sum
615+
616+ horizontalPadding =
617+ context.self.bbox.padding.left + context.self.bbox.padding.right
618+
619+ spacingAmount =
620+ Testable.getSpacingFromAttributes rowAttrs
621+
622+ totalSpacing =
623+ toFloat spacingAmount * (toFloat (List.length context.children) - 1)
624+ in
625+ listIf
626+ [ ( True
627+ , expectRoundedEquality
628+ { expected = totalChildren + horizontalPadding + totalSpacing
629+ , found = context.self.bbox.width
630+ }
631+ )
632+ , ( context.parentLayout /= Testable.AtRoot
633+ , Testable.lessThanOrEqual "not larger than parent"
634+ context.self.bbox.width
635+ context.parent.bbox.width
636+ )
637+ ]
638+
639+ Testable.Column _ _ ->
640+ -- The width of the column is the width of the widest child.
641+ let
642+ childWidth child =
643+ child.bbox.width
644+ + context.self.bbox.padding.left
645+ + context.self.bbox.padding.right
646+
647+ textChildren =
648+ List.map
649+ (\txt ->
650+ txt.width
651+ + context.self.bbox.padding.left
652+ + context.self.bbox.padding.right
653+ )
654+ context.self.textMetrics
655+
656+ allChildren =
657+ context.children
658+ |> List.map childWidth
659+ |> List.append textChildren
660+ in
661+ listIf
662+ [ ( True
663+ , expectRoundedEquality
664+ { expected = Maybe.withDefault 0 (List.maximum allChildren)
665+ , found = context.self.bbox.width
666+ }
667+ )
668+ , ( context.parentLayout /= Testable.AtRoot
669+ , Testable.lessThanOrEqual "not larger than parent"
670+ context.self.bbox.width
671+ context.parent.bbox.width
672+ )
673+ ]
674+
675+ Testable.TextColumn _ _ ->
676+ -- The width of the column is the width of the widest child.
677+ let
678+ childWidth child =
679+ child.bbox.width
680+ + context.self.bbox.padding.left
681+ + context.self.bbox.padding.right
682+
683+ textChildren =
684+ List.map
685+ (\txt ->
686+ txt.width
687+ + context.self.bbox.padding.left
688+ + context.self.bbox.padding.right
689+ )
690+ context.self.textMetrics
691+
692+ allChildren =
693+ context.children
694+ |> List.map childWidth
695+ |> List.append textChildren
696+ in
697+ listIf
698+ [ ( True
699+ , expectRoundedEquality
700+ { expected = Maybe.withDefault 0 (List.maximum allChildren)
701+ , found = context.self.bbox.width
702+ }
703+ )
704+ , ( context.parentLayout /= Testable.AtRoot
705+ , Testable.lessThanOrEqual "not larger than parent"
706+ context.self.bbox.width
707+ context.parent.bbox.width
708+ )
709+ ]
710+
711+ Testable.Paragraph _ _ ->
712+ -- This should be the size it's text,
713+ -- unless it takes up all available space, in which case it should wrap.
714+ let
715+ childWidth child =
716+ child.bbox.width
717+
718+ totalChildren =
719+ context.children
720+ |> List.map childWidth
721+ |> List.append (List.map .width context.self.textMetrics)
722+ |> List.sum
723+
724+ horizontalPadding =
725+ context.self.bbox.padding.left + context.self.bbox.padding.right
726+ in
727+ listIf
728+ [ ( True
729+ , expectRoundedEquality
730+ { expected = totalChildren + horizontalPadding
731+ , found = context.self.bbox.width
732+ }
733+ )
734+ , ( context.parentLayout /= Testable.AtRoot
735+ , Testable.lessThanOrEqual "not larger than parent"
736+ context.self.bbox.width
737+ context.parent.bbox.width
738+ )
739+ ]
740+
741+ Testable.Text _ ->
742+ []
743+
744+ Testable.Empty ->
745+ []
421746 }
422747
423748
@@ -486,17 +811,16 @@ heightHelper maybeMin maybeMax len =
486811 |> addMin
487812 |> addMax
488813 )
814+ , id = Testable.IsHeight
489815 , test =
490− \found _ ->
491− Expect.all
492− [ \_ ->
493− Expect.true ("exact height is exact: " ++ String.fromInt (floor found.self.bbox.height) ++ "," ++ String.fromInt val)
494− (floor found.self.bbox.height == val)
495− , \_ ->
496− Expect.true "min/max holds true"
497− (minMaxTest (floor found.self.bbox.height))
498− ]
499− ()
816+ \found ->
817+ [ expectRoundedEquality
818+ { expected = toFloat val
819+ , found = found.self.bbox.height
820+ }
821+ , Testable.true "min/max holds true"
822+ (minMaxTest (floor found.self.bbox.height))
823+ ]
500824 }
501825
502826 Fill portion ->
@@ -508,31 +832,32 @@ heightHelper maybeMin maybeMax len =
508832 |> addMin
509833 |> addMax
510834 )
835+ , id = Testable.IsHeight
511836 , test =
512− \context _ ->
513− if List.member context.location [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
514− Expect.true "height fill doesn't apply to above/below elements" True
837+ \context ->
838+ [ if List.member context.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
839+ Testable.true "height fill doesn't apply to above/below elements" True
515840
516− else
841+ else
517842 let
518843 parentAvailableHeight =
519844 context.parent.bbox.height - (context.self.bbox.padding.top + context.self.bbox.padding.bottom)
520845 in
521− case context.location of
846+ case context.parentLayout of
522847 Testable.IsNearby _ ->
523− Expect.true "Nearby Element has fill height"
848+ Testable.true "Nearby Element has fill height"
524849 ((floor context.parent.bbox.height == floor context.self.bbox.height)
525850 || minMaxTest (floor context.self.bbox.height)
526851 )
527852
528853 Testable.InColumn ->
529− Expect.true "Element within column has fill height"
854+ Testable.true "Element within column has fill height"
530855 ((floor parentAvailableHeight == floor context.self.bbox.height)
531856 || minMaxTest (floor context.self.bbox.height)
532857 )
533858
534859 Testable.InEl ->
535− Expect.true "Element within el has fill height" <|
860+ Testable.true "Element within el has fill height" <|
536861 (floor parentAvailableHeight == floor context.self.bbox.height)
537862 || minMaxTest (floor context.self.bbox.height)
538863
@@ -541,9 +866,10 @@ heightHelper maybeMin maybeMax len =
541866 spacePerPortion =
542867 parentAvailableHeight / toFloat (List.length context.siblings + 1)
543868 in
544− Expect.true "el has fill height" <|
869+ Testable.true "el has fill height" <|
545870 (floor spacePerPortion == floor context.self.bbox.height)
546871 || minMaxTest (floor context.self.bbox.height)
872+ ]
547873 }
548874
549875 Shrink ->
@@ -555,33 +881,134 @@ heightHelper maybeMin maybeMax len =
555881 |> addMin
556882 |> addMax
557883 )
884+ , id = Testable.IsHeight
558885 , test =
559− \context _ ->
560− let
561− childWidth child =
562− -- TODO: add margin values to heights
563− child.bbox.height
564−
565− totalChildren =
566− context.children
567− |> List.map childWidth
568− |> List.sum
569−
570− verticalPadding =
571− context.self.bbox.padding.top + context.self.bbox.padding.bottom
572−
573− spacingValue =
574− toFloat context.parentSpacing * (toFloat (List.length context.children) - 1)
575− in
576− if totalChildren == 0 then
577− -- TODO: The issue is that we have a hard time measuring `text` elements
578− -- So if a element has a text child, then it's height isn't going to show up in the system.
579− expectRoundedEquality context.self.bbox.height context.self.bbox.height
886+ \context ->
887+ case context.selfElement of
888+ Testable.El _ _ ->
889+ let
890+ childHeight child =
891+ child.bbox.height
892+ in
893+ if List.isEmpty context.children then
894+ -- context.self.textMetrics
895+ -- |> List.map Testable.textHeight
896+ -- |> List.sum
897+ -- TODO: apparently the font metrics we have are for the literal characters rendered
898+ -- not for the font itself.
899+ [ Testable.todo "calculate height from actual text metrics"
900+ ]
580901
581− else
582− -- This fails if this element is actually a column
583− -- So we need to capture what this element is in order to do this calculation.
584− expectRoundedEquality (totalChildren + verticalPadding + spacingValue) context.self.bbox.height
902+ else
903+ [ expectRoundedEquality
904+ { expected =
905+ context.children
906+ |> List.map childHeight
907+ |> List.sum
908+ |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
909+ , found = context.self.bbox.height
910+ }
911+ , Testable.lessThanOrEqual "not larger than parent"
912+ context.self.bbox.height
913+ context.parent.bbox.height
914+ ]
915+
916+ Testable.Link _ _ _ ->
917+ let
918+ childHeight child =
919+ child.bbox.height
920+ in
921+ if List.isEmpty context.children then
922+ -- context.self.textMetrics
923+ -- |> List.map Testable.textHeight
924+ -- |> List.sum
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"
928+ ]
929+
930+ else
931+ [ expectRoundedEquality
932+ { expected =
933+ context.children
934+ |> List.map childHeight
935+ |> List.sum
936+ |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
937+ , found = context.self.bbox.height
938+ }
939+ , Testable.lessThanOrEqual "not larger than parent"
940+ context.self.bbox.height
941+ context.parent.bbox.height
942+ ]
943+
944+ Testable.Row _ _ ->
945+ let
946+ childHeight child =
947+ child.bbox.height
948+ in
949+ if List.isEmpty context.children then
950+ -- context.self.textMetrics
951+ -- |> List.map Testable.textHeight
952+ -- |> List.sum
953+ -- TODO: apparently the font metrics we have are for the literal characters rendered
954+ -- not for the font itself.
955+ [ Testable.todo "calculate height from actual text metrics" ]
956+
957+ else
958+ [ expectRoundedEquality
959+ { expected =
960+ context.children
961+ |> List.map childHeight
962+ |> List.maximum
963+ |> Maybe.withDefault 0
964+ |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
965+ , found = context.self.bbox.height
966+ }
967+ , Testable.lessThanOrEqual "not larger than parent"
968+ context.self.bbox.height
969+ context.parent.bbox.height
970+ ]
971+
972+ Testable.Column colAttrs _ ->
973+ let
974+ childHeight child =
975+ child.bbox.height
976+
977+ totalChildren =
978+ context.children
979+ |> List.map childHeight
980+ |> List.append (List.map Testable.textHeight context.self.textMetrics)
981+ |> List.sum
982+
983+ verticalPadding =
984+ context.self.bbox.padding.top + context.self.bbox.padding.bottom
985+
986+ spacingAmount =
987+ Testable.getSpacingFromAttributes colAttrs
988+
989+ totalSpacing =
990+ toFloat spacingAmount * (toFloat (List.length context.children) - 1)
991+ in
992+ [ expectRoundedEquality
993+ { expected = totalChildren + verticalPadding + totalSpacing
994+ , found = context.self.bbox.height
995+ }
996+ , Testable.lessThanOrEqual "not larger than parent"
997+ context.self.bbox.height
998+ context.parent.bbox.height
999+ ]
1000+
1001+ Testable.TextColumn _ _ ->
1002+ []
1003+
1004+ Testable.Paragraph _ _ ->
1005+ []
1006+
1007+ Testable.Text _ ->
1008+ []
1009+
1010+ Testable.Empty ->
1011+ []
5851012 }
5861013
5871014
@@ -602,8 +1029,9 @@ spacing space =
6021029 , Testable.LabeledTest
6031030 { label = "spacing: " ++ String.fromInt space
6041031 , attr = Element.spacing space
1032+ , id = Testable.NoId
6051033 , test =
606− \found _ ->
1034+ \found ->
6071035 let
6081036 findDistance child total =
6091037 List.concatMap
@@ -649,7 +1077,7 @@ spacing space =
6491077 []
6501078 distances
6511079 in
652− Expect.true
1080+ [ Testable.true
6531081 ("All children are at least "
6541082 ++ String.fromInt space
6551083 ++ " pixels apart."
@@ -657,6 +1085,7 @@ spacing space =
6571085 ++ " are not though"
6581086 )
6591087 (allAreSpaced == [])
1088+ ]
6601089 }
6611090 ]
6621091
@@ -679,30 +1108,33 @@ alignLeft =
6791108 Testable.LabeledTest
6801109 { label = "alignLeft"
6811110 , attr = Element.alignLeft
1111+ , id = Testable.NoId
6821112 , test =
683− \found _ ->
684− if List.member found.location [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
685− Expect.true "alignLeft doesn't apply to elements that are onLeft or onRight" True
1113+ \found ->
1114+ [ if List.member found.parentLayout [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
1115+ Testable.true "alignLeft doesn't apply to elements that are onLeft or onRight" True
6861116
687− else if
688− List.member found.location
1117+ else if
1118+ List.member found.parentLayout
6891119 [ Testable.IsNearby Testable.InFront
6901120 , Testable.IsNearby Testable.Behind
6911121 , Testable.IsNearby Testable.Above
6921122 , Testable.IsNearby Testable.Below
6931123 ]
694− then
1124+ then
6951125 expectRoundedEquality
696− found.self.bbox.left
697− found.parent.bbox.left
1126+ { found = found.self.bbox.left
1127+ , expected = found.parent.bbox.left
1128+ }
6981129
699− else if List.length found.siblings == 0 then
1130+ else if List.length found.siblings == 0 then
7001131 expectRoundedEquality
701− found.self.bbox.left
702− (found.parent.bbox.left + found.parent.bbox.padding.left)
1132+ { found = found.self.bbox.left
1133+ , expected = found.parent.bbox.left + found.parent.bbox.padding.left
1134+ }
7031135
704− else
705− case found.location of
1136+ else
1137+ case found.parentLayout of
7061138 Testable.InRow ->
7071139 let
7081140 siblingsOnLeft =
@@ -717,13 +1149,16 @@ alignLeft =
7171149 |> List.sum
7181150 in
7191151 expectRoundedEquality
720− found.self.bbox.left
721− (found.parent.bbox.left + (found.parent.bbox.padding.left + widthsOnLeft + spacings))
1152+ { found = found.self.bbox.left
1153+ , expected = found.parent.bbox.left + (found.parent.bbox.padding.left + widthsOnLeft + spacings)
1154+ }
7221155
7231156 _ ->
7241157 expectRoundedEquality
725− found.self.bbox.left
726− (found.parent.bbox.left + found.parent.bbox.padding.left)
1158+ { found = found.self.bbox.left
1159+ , expected = found.parent.bbox.left + found.parent.bbox.padding.left
1160+ }
1161+ ]
7271162 }
7281163
7291164
@@ -733,8 +1168,9 @@ centerX =
7331168 Testable.LabeledTest
7341169 { label = "centerX"
7351170 , attr = Element.centerX
1171+ , id = Testable.NoId
7361172 , test =
737− \found _ ->
1173+ \found ->
7381174 let
7391175 selfCenter : Float
7401176 selfCenter =
@@ -744,16 +1180,18 @@ centerX =
7441180 parentCenter =
7451181 found.parent.bbox.left + (found.parent.bbox.width / 2)
7461182 in
747− if List.member found.location [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
748− Expect.true "centerX doesn't apply to elements that are onLeft or onRight" True
1183+ if List.member found.parentLayout [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
1184+ [ Testable.true "centerX doesn't apply to elements that are onLeft or onRight" True ]
7491185
7501186 else if List.length found.siblings == 0 then
751− expectRoundedEquality
752− selfCenter
753− parentCenter
1187+ [ expectRoundedEquality
1188+ { found = selfCenter
1189+ , expected = parentCenter
1190+ }
1191+ ]
7541192
7551193 else
756− case found.location of
1194+ case found.parentLayout of
7571195 Testable.InRow ->
7581196 let
7591197 siblingsOnLeft =
@@ -783,12 +1221,18 @@ centerX =
7831221 / 2
7841222 )
7851223 in
786− expectRoundedEquality
787− selfCenter
788− expectedCenter
1224+ [ expectRoundedEquality
1225+ { found = selfCenter
1226+ , expected = expectedCenter
1227+ }
1228+ ]
7891229
7901230 _ ->
791− expectRoundedEquality selfCenter parentCenter
1231+ [ expectRoundedEquality
1232+ { found = selfCenter
1233+ , expected = parentCenter
1234+ }
1235+ ]
7921236 }
7931237
7941238
@@ -798,30 +1242,35 @@ alignRight =
7981242 Testable.LabeledTest
7991243 { label = "alignRight"
8001244 , attr = Element.alignRight
1245+ , id = Testable.NoId
8011246 , test =
802− \found _ ->
803− if List.member found.location [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
804− Expect.true "alignRight doesn't apply to elements that are onLeft or onRight" True
1247+ \found ->
1248+ if List.member found.parentLayout [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
1249+ [ Testable.true "alignRight doesn't apply to elements that are onLeft or onRight" True ]
8051250
8061251 else if
807− List.member found.location
1252+ List.member found.parentLayout
8081253 [ Testable.IsNearby Testable.InFront
8091254 , Testable.IsNearby Testable.Behind
8101255 , Testable.IsNearby Testable.Above
8111256 , Testable.IsNearby Testable.Below
8121257 ]
8131258 then
814− expectRoundedEquality
815− found.self.bbox.right
816− found.parent.bbox.right
1259+ [ expectRoundedEquality
1260+ { found = found.self.bbox.right
1261+ , expected = found.parent.bbox.right
1262+ }
1263+ ]
8171264
8181265 else if List.length found.siblings == 0 then
819− expectRoundedEquality
820− found.self.bbox.right
821− (found.parent.bbox.right + found.parent.bbox.padding.right)
1266+ [ expectRoundedEquality
1267+ { found = found.self.bbox.right
1268+ , expected = found.parent.bbox.right + found.parent.bbox.padding.right
1269+ }
1270+ ]
8221271
8231272 else
824− case found.location of
1273+ case found.parentLayout of
8251274 Testable.InRow ->
8261275 let
8271276 siblingsOnRight =
@@ -835,14 +1284,18 @@ alignRight =
8351284 |> List.map (.width << .bbox)
8361285 |> List.sum
8371286 in
838− expectRoundedEquality
839− found.self.bbox.right
840− (found.parent.bbox.right - (found.parent.bbox.padding.right + widthsOnRight + spacings))
1287+ [ expectRoundedEquality
1288+ { found = found.self.bbox.right
1289+ , expected = found.parent.bbox.right - (found.parent.bbox.padding.right + widthsOnRight + spacings)
1290+ }
1291+ ]
8411292
8421293 _ ->
843− expectRoundedEquality
844− found.self.bbox.right
845− (found.parent.bbox.right + found.parent.bbox.padding.right)
1294+ [ expectRoundedEquality
1295+ { found = found.self.bbox.right
1296+ , expected = found.parent.bbox.right + found.parent.bbox.padding.right
1297+ }
1298+ ]
8461299 }
8471300
8481301
@@ -852,30 +1305,35 @@ alignTop =
8521305 Testable.LabeledTest
8531306 { label = "alignTop"
8541307 , attr = Element.alignTop
1308+ , id = Testable.NoId
8551309 , test =
856− \found _ ->
857− if List.member found.location [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
858− Expect.true "alignTop doesn't apply to elements that are above or below" True
1310+ \found ->
1311+ if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1312+ [ Testable.true "alignTop doesn't apply to elements that are above or below" True ]
8591313
8601314 else if
861− List.member found.location
1315+ List.member found.parentLayout
8621316 [ Testable.IsNearby Testable.InFront
8631317 , Testable.IsNearby Testable.Behind
8641318 , Testable.IsNearby Testable.OnRight
8651319 , Testable.IsNearby Testable.OnLeft
8661320 ]
8671321 then
868− expectRoundedEquality
869− found.self.bbox.top
870− found.parent.bbox.top
1322+ [ expectRoundedEquality
1323+ { found = found.self.bbox.top
1324+ , expected = found.parent.bbox.top
1325+ }
1326+ ]
8711327
8721328 else if List.length found.siblings == 0 then
873− expectRoundedEquality
874− found.self.bbox.top
875− (found.parent.bbox.top + found.parent.bbox.padding.top)
1329+ [ expectRoundedEquality
1330+ { found = found.self.bbox.top
1331+ , expected = found.parent.bbox.top + found.parent.bbox.padding.top
1332+ }
1333+ ]
8761334
8771335 else
878− case found.location of
1336+ case found.parentLayout of
8791337 Testable.InColumn ->
8801338 let
8811339 siblingsAbove =
@@ -889,14 +1347,18 @@ alignTop =
8891347 |> List.map (.height << .bbox)
8901348 |> List.sum
8911349 in
892− expectRoundedEquality
893− found.self.bbox.top
894− (found.parent.bbox.top + (found.parent.bbox.padding.top + heightsAbove + spacings))
1350+ [ expectRoundedEquality
1351+ { found = found.self.bbox.top
1352+ , expected = found.parent.bbox.top + (found.parent.bbox.padding.top + heightsAbove + spacings)
1353+ }
1354+ ]
8951355
8961356 _ ->
897− expectRoundedEquality
898− found.self.bbox.top
899− found.parent.bbox.top
1357+ [ expectRoundedEquality
1358+ { found = found.self.bbox.top
1359+ , expected = found.parent.bbox.top
1360+ }
1361+ ]
9001362 }
9011363
9021364
@@ -906,30 +1368,35 @@ alignBottom =
9061368 Testable.LabeledTest
9071369 { label = "alignBottom"
9081370 , attr = Element.alignBottom
1371+ , id = Testable.NoId
9091372 , test =
910− \found _ ->
911− if List.member found.location [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
912− Expect.true "alignBottom doesn't apply to elements that are above or below" True
1373+ \found ->
1374+ if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1375+ [ Testable.true "alignBottom doesn't apply to elements that are above or below" True ]
9131376
9141377 else if
915− List.member found.location
1378+ List.member found.parentLayout
9161379 [ Testable.IsNearby Testable.InFront
9171380 , Testable.IsNearby Testable.Behind
9181381 , Testable.IsNearby Testable.OnRight
9191382 , Testable.IsNearby Testable.OnLeft
9201383 ]
9211384 then
922− expectRoundedEquality
923− found.self.bbox.bottom
924− found.parent.bbox.bottom
1385+ [ expectRoundedEquality
1386+ { found = found.self.bbox.bottom
1387+ , expected = found.parent.bbox.bottom
1388+ }
1389+ ]
9251390
9261391 else if List.length found.siblings == 0 then
927− expectRoundedEquality
928− found.self.bbox.bottom
929− (found.parent.bbox.bottom + found.parent.bbox.padding.bottom)
1392+ [ expectRoundedEquality
1393+ { found = found.self.bbox.bottom
1394+ , expected = found.parent.bbox.bottom + found.parent.bbox.padding.bottom
1395+ }
1396+ ]
9301397
9311398 else
932− case found.location of
1399+ case found.parentLayout of
9331400 Testable.InColumn ->
9341401 let
9351402 siblingsBelow =
@@ -943,20 +1410,31 @@ alignBottom =
9431410 |> List.map (.height << .bbox)
9441411 |> List.sum
9451412 in
946− expectRoundedEquality
947− found.self.bbox.bottom
948− (found.parent.bbox.bottom - (found.parent.bbox.padding.bottom + heightsBelow + spacings))
1413+ [ expectRoundedEquality
1414+ { found = found.self.bbox.bottom
1415+ , expected = found.parent.bbox.bottom - (found.parent.bbox.padding.bottom + heightsBelow + spacings)
1416+ }
1417+ ]
9491418
9501419 _ ->
951− expectRoundedEquality
952− found.self.bbox.bottom
953− (found.parent.bbox.bottom + found.parent.bbox.padding.bottom)
1420+ [ expectRoundedEquality
1421+ { found = found.self.bbox.bottom
1422+ , expected = found.parent.bbox.bottom + found.parent.bbox.padding.bottom
1423+ }
1424+ ]
9541425 }
9551426
9561427
957−expectRoundedEquality x y =
958− Expect.true ("within 1 of each other " ++ String.fromFloat x ++ ":" ++ String.fromFloat y)
959− (abs (x - y) < 1)
1428+expectRoundedEquality : { expected : Float, found : Float } -> Testable.LayoutExpectation
1429+expectRoundedEquality { expected, found } =
1430+ Testable.true
1431+ ("expected " ++ floatToString expected ++ ", found " ++ floatToString found)
1432+ (abs (expected - found) < 1)
1433+
1434+
1435+floatToString : Float -> String
1436+floatToString x =
1437+ String.fromFloat (toFloat (round (x * 100)) / 100)
9601438
9611439
9621440{-| -}
@@ -965,8 +1443,9 @@ centerY =
9651443 Testable.LabeledTest
9661444 { label = "centerY"
9671445 , attr = Element.centerY
1446+ , id = Testable.NoId
9681447 , test =
969− \found _ ->
1448+ \found ->
9701449 let
9711450 selfCenter =
9721451 found.self.bbox.top + (found.self.bbox.height / 2)
@@ -974,16 +1453,18 @@ centerY =
9741453 parentCenter =
9751454 found.parent.bbox.top + (found.parent.bbox.height / 2)
9761455 in
977− if List.member found.location [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
978− Expect.true "centerY doesn't apply to elements that are above or below" True
1456+ if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1457+ [ Testable.true "centerY doesn't apply to elements that are above or below" True ]
9791458
9801459 else if List.length found.siblings == 0 then
981− expectRoundedEquality
982− selfCenter
983− parentCenter
1460+ [ expectRoundedEquality
1461+ { found = selfCenter
1462+ , expected = parentCenter
1463+ }
1464+ ]
9841465
9851466 else
986− case found.location of
1467+ case found.parentLayout of
9871468 Testable.InColumn ->
9881469 let
9891470 siblingsOnTop =
@@ -1013,12 +1494,18 @@ centerY =
10131494 / 2
10141495 )
10151496 in
1016− expectRoundedEquality
1017− selfCenter
1018− expectedCenter
1497+ [ expectRoundedEquality
1498+ { found = selfCenter
1499+ , expected = expectedCenter
1500+ }
1501+ ]
10191502
10201503 _ ->
1021− expectRoundedEquality selfCenter parentCenter
1504+ [ expectRoundedEquality
1505+ { found = selfCenter
1506+ , expected = parentCenter
1507+ }
1508+ ]
10221509 }
10231510
10241511
@@ -1030,8 +1517,12 @@ above element =
10301517 , element = element
10311518 , label = "above"
10321519 , test =
1033− \found _ ->
1034− expectRoundedEquality found.self.bbox.bottom found.parent.bbox.top
1520+ \found ->
1521+ [ expectRoundedEquality
1522+ { found = found.self.bbox.bottom
1523+ , expected = found.parent.bbox.top
1524+ }
1525+ ]
10351526 }
10361527
10371528
@@ -1043,8 +1534,12 @@ below element =
10431534 , element = element
10441535 , label = "below"
10451536 , test =
1046− \found _ ->
1047− expectRoundedEquality found.self.bbox.top found.parent.bbox.bottom
1537+ \found ->
1538+ [ expectRoundedEquality
1539+ { found = found.self.bbox.top
1540+ , expected = found.parent.bbox.bottom
1541+ }
1542+ ]
10481543 }
10491544
10501545
@@ -1056,8 +1551,12 @@ onRight element =
10561551 , element = element
10571552 , label = "onRight"
10581553 , test =
1059− \found _ ->
1060− expectRoundedEquality found.self.bbox.left found.parent.bbox.right
1554+ \found ->
1555+ [ expectRoundedEquality
1556+ { found = found.self.bbox.left
1557+ , expected = found.parent.bbox.right
1558+ }
1559+ ]
10611560 }
10621561
10631562
@@ -1069,8 +1568,12 @@ onLeft element =
10691568 , element = element
10701569 , label = "onLeft"
10711570 , test =
1072− \found _ ->
1073− expectRoundedEquality found.self.bbox.right found.parent.bbox.left
1571+ \found ->
1572+ [ expectRoundedEquality
1573+ { found = found.self.bbox.right
1574+ , expected = found.parent.bbox.left
1575+ }
1576+ ]
10741577 }
10751578
10761579
@@ -1086,11 +1589,12 @@ inFront element =
10861589 , element = element
10871590 , label = "inFront"
10881591 , test =
1089− withinHelper
1592+ \found ->
1593+ [ withinHelper found ]
10901594 }
10911595
10921596
1093−withinHelper found _ =
1597+withinHelper found =
10941598 let
10951599 horizontalCheck =
10961600 if found.self.bbox.width > found.parent.bbox.width then
@@ -1114,7 +1618,7 @@ withinHelper found _ =
11141618 , compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
11151619 ]
11161620 in
1117− Expect.true "within the confines of the parent"
1621+ Testable.true "within the confines of the parent"
11181622 (List.all ((==) True)
11191623 (List.concat
11201624 [ horizontalCheck
@@ -1132,5 +1636,88 @@ behindContent element =
11321636 , element = element
11331637 , label = "behindContent"
11341638 , test =
1135− withinHelper
1639+ \found ->
1640+ [ withinHelper found ]
11361641 }
1642+
1643+
1644+
1645+{- Implicit width/height calcualtions -}
1646+
1647+
1648+implicitWidthHeightShrink attrs =
1649+ let
1650+ withImplicits =
1651+ implicitTest (widthHelper Nothing Nothing Shrink)
1652+ :: implicitTest (heightHelper Nothing Nothing Shrink)
1653+ :: attrs
1654+ in
1655+ skipOverridden withImplicits
1656+
1657+
1658+attrId attr =
1659+ case attr of
1660+ Testable.LabeledTest details ->
1661+ details.id
1662+
1663+ Testable.AttrTest details ->
1664+ details.id
1665+
1666+ _ ->
1667+ Testable.NoId
1668+
1669+
1670+skipOverridden ls =
1671+ List.foldr
1672+ (\attr ( found, caught ) ->
1673+ let
1674+ ( skip, has ) =
1675+ case attrId attr of
1676+ Testable.NoId ->
1677+ ( False, found )
1678+
1679+ Testable.IsWidth ->
1680+ ( found.hasWidth
1681+ , { hasWidth = True
1682+ , hasHeight = found.hasHeight
1683+ }
1684+ )
1685+
1686+ Testable.IsHeight ->
1687+ ( found.hasHeight
1688+ , { hasWidth = found.hasWidth
1689+ , hasHeight = True
1690+ }
1691+ )
1692+ in
1693+ ( has
1694+ , if skip then
1695+ caught
1696+
1697+ else
1698+ attr :: caught
1699+ )
1700+ )
1701+ ( { hasWidth = False
1702+ , hasHeight = False
1703+ }
1704+ , []
1705+ )
1706+ ls
1707+ |> Tuple.second
1708+ |> List.reverse
1709+
1710+
1711+{-| This is taking a normal test and rmoving its ability to attach a real `Element` attribute.
1712+-}
1713+implicitTest attr =
1714+ case attr of
1715+ Testable.LabeledTest details ->
1716+ Testable.AttrTest
1717+ { test = details.test
1718+ , label = "Implicit -> " ++ details.label
1719+ , id = details.id
1720+ }
1721+
1722+ otherwise ->
1723+ otherwise