@@ -402,36 +402,74 @@ widthHelper maybeMin maybeMax len =
402 parentAvailableWidth =
402 parentAvailableWidth =
403 context.parent.bbox.width - (context.self.bbox.padding.left + context.self.bbox.padding.right)
403 context.parent.bbox.width - (context.self.bbox.padding.left + context.self.bbox.padding.right)
405− [ case context.parentLayout of
406+ [ case context.parentLayout of
406− Testable.IsNearby _ ->
407+ Testable.IsNearby _ ->
407− Testable.true "Nearby Element has fill width"
408+ [ Testable.true "Nearby Element has fill width"
408− ((floor context.parent.bbox.width == floor context.self.bbox.width)
409+ ((floor context.parent.bbox.width == floor context.self.bbox.width)
409− || minMaxTest (floor context.self.bbox.width)
410+ || minMaxTest (floor context.self.bbox.width)
412− Testable.InColumn ->
413− Testable.true "Element within column has fill width"
414− ((floor parentAvailableWidth == floor context.self.bbox.width)
415− || minMaxTest (floor context.self.bbox.width)
419− Testable.true "Element within element has fill width" <|
420− (floor parentAvailableWidth == floor context.self.bbox.width)
421− || minMaxTest (floor context.self.bbox.width)
423− _ ->
414+ Testable.InColumn ->
424− let
415+ [ Testable.true "Element within column has fill width"
416+ ((floor parentAvailableWidth == floor context.self.bbox.width)
417+ || minMaxTest (floor context.self.bbox.width)
422+ [ Testable.true "Element within element has fill width" <|
423+ (floor parentAvailableWidth == floor context.self.bbox.width)
424+ || minMaxTest (floor context.self.bbox.width)
425− spacePerPortion =
429+ spacePerPortion =
426− parentAvailableWidth / toFloat (List.length context.siblings + 1)
430+ parentAvailableWidth / toFloat (List.length context.siblings + 1)
428− Testable.true "element has fill width" <|
432+ [ Testable.true "element has fill width" <|
429− (floor spacePerPortion == floor context.self.bbox.width)
433+ (floor spacePerPortion == floor context.self.bbox.width)
430− || minMaxTest (floor context.self.bbox.width)
434+ || minMaxTest (floor context.self.bbox.width)
431− , Testable.lessThanOrEqual "not larger than parent"
436+ , [ Testable.lessThanOrEqual "not larger than parent"
432− context.self.bbox.width
437+ context.self.bbox.width
433− context.parent.bbox.width
438+ context.parent.bbox.width
440+ , case context.selfElement of
441+ Testable.Paragraph _ _ ->
442+ -- A paragraph with width fill
443+ -- we want to test for correct text wrapping here.
451+ |> List.map childWidth
452+ |> List.append (List.map .width context.self.textMetrics)
456+ context.self.bbox.padding.left + context.self.bbox.padding.right
458+ totalCalculatedWidth =
459+ totalChildren + horizontalPadding
462+ ceiling (totalCalculatedWidth / context.self.bbox.width)
464+ [ Testable.rounded "text wrapping, checking height"
465+ { expected = toFloat (expectedLines * 22)
466+ , found = context.self.bbox.height
437 Shrink ->
475 Shrink ->
@@ -460,8 +498,16 @@ widthHelper maybeMin maybeMax len =
461 horizontalPadding =
499 horizontalPadding =
462 context.self.bbox.padding.left + context.self.bbox.padding.right
500 context.self.bbox.padding.left + context.self.bbox.padding.right
506+ |> List.map childWidth
507+ , text = List.map .width context.self.textMetrics
464− [ expectRoundedEquality
510+ [ Testable.rounded "equals children"
465 { expected = totalChildren + horizontalPadding
511 { expected = totalChildren + horizontalPadding
466 , found = context.self.bbox.width
512 , found = context.self.bbox.width
@@ -746,9 +792,11 @@ heightHelper maybeMin maybeMax len =
746 -- |> List.sum
792 -- |> List.sum
747 -- TODO: apparently the font metrics we have are for the literal characters rendered
793 -- TODO: apparently the font metrics we have are for the literal characters rendered
748 -- not for the font itself.
794 -- not for the font itself.
749− -- so for now, we are stubbing this in as 20, which is the default font size.
795+ -- so for now, we are stubbing this in as 20, which is the default font size + line height.
750− Testable.true "expected multiple of 20"
796+ Testable.rounded "expected multiple of 20"
751− ((round context.self.bbox.height |> modBy 20) == 0)
797+ { expected = context.self.bbox.height
798+ , found = toFloat (List.length context.self.textMetrics * 20)
754 expectRoundedEquality
802 expectRoundedEquality