mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-09-21 12:19:03 +03:00
Adds a test against different height label content
This commit is contained in:
parent
868c0466d3
commit
f60a68e3f1
@ -77,7 +77,7 @@ getLabelHeightsSpec =
|
||||
Block.getLabelHeights [ "a" ]
|
||||
(Dict.singleton "a"
|
||||
{ label = dummyElement { x = 0, y = 0, width = 100, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = 20 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = startingHeight }
|
||||
}
|
||||
)
|
||||
|> Expect.equal
|
||||
@ -86,6 +86,45 @@ getLabelHeightsSpec =
|
||||
, arrowHeight = defaultArrowHeight
|
||||
}
|
||||
)
|
||||
, test "with different height measurements, prevents overlaps" <|
|
||||
\() ->
|
||||
let
|
||||
aStartingHeight =
|
||||
40
|
||||
|
||||
bStartingHeight =
|
||||
30
|
||||
in
|
||||
Block.getLabelHeights [ "a", "b", "c" ]
|
||||
([ -- A has taller content
|
||||
( "a"
|
||||
, { label = dummyElement { x = 0, y = 0, width = 100, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = aStartingHeight }
|
||||
}
|
||||
)
|
||||
, -- B has shorter content
|
||||
( "b"
|
||||
, { label = dummyElement { x = 0, y = 0, width = 200, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = bStartingHeight }
|
||||
}
|
||||
)
|
||||
]
|
||||
|> Dict.fromList
|
||||
)
|
||||
|> Expect.equal
|
||||
([ ( "a"
|
||||
, { totalHeight = aStartingHeight + defaultArrowHeight + balloonOffset
|
||||
, arrowHeight = defaultArrowHeight
|
||||
}
|
||||
)
|
||||
, ( "b"
|
||||
, { totalHeight = aStartingHeight + bStartingHeight + defaultArrowHeight + balloonOffset
|
||||
, arrowHeight = aStartingHeight + defaultArrowHeight
|
||||
}
|
||||
)
|
||||
]
|
||||
|> Dict.fromList
|
||||
)
|
||||
, test "with multiple ids and measurements, positions wider elements above narrower elements" <|
|
||||
\() ->
|
||||
let
|
||||
@ -96,19 +135,19 @@ getLabelHeightsSpec =
|
||||
([ -- A is the second-widest element
|
||||
( "a"
|
||||
, { label = dummyElement { x = 0, y = 0, width = 200, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 200, height = 20 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 200, height = startingHeight }
|
||||
}
|
||||
)
|
||||
, -- B is the narrowest element
|
||||
( "b"
|
||||
, { label = dummyElement { x = 0, y = 0, width = 100, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = 20 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = startingHeight }
|
||||
}
|
||||
)
|
||||
, -- C is the widest element
|
||||
( "c"
|
||||
, { label = dummyElement { x = 0, y = 0, width = 300, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 300, height = 20 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 300, height = startingHeight }
|
||||
}
|
||||
)
|
||||
]
|
||||
@ -148,12 +187,12 @@ getLabelHeightsSpec =
|
||||
Block.getLabelHeights [ "a", "b" ]
|
||||
([ ( "a"
|
||||
, { label = dummyElement { x = 0, y = 0, width = 100, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = 20 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = startingHeight }
|
||||
}
|
||||
)
|
||||
, ( "b"
|
||||
, { label = dummyElement { x = 0, y = 20, width = 100, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = 20 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = startingHeight }
|
||||
}
|
||||
)
|
||||
]
|
||||
@ -183,19 +222,19 @@ getLabelHeightsSpec =
|
||||
([ -- A is the second-widest element
|
||||
( "a"
|
||||
, { label = dummyElement { x = 0, y = 0, width = 200, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 200, height = 20 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 200, height = startingHeight }
|
||||
}
|
||||
)
|
||||
, -- B is the narrowest element
|
||||
( "b"
|
||||
, { label = dummyElement { x = 0, y = 0, width = 100, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = 20 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 100, height = startingHeight }
|
||||
}
|
||||
)
|
||||
, -- C is the widest element and it is also on a new line by itself
|
||||
( "c"
|
||||
, { label = dummyElement { x = 0, y = 20, width = 300, height = 100 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 300, height = 20 }
|
||||
, labelContent = dummyElement { x = 0, y = 0, width = 300, height = startingHeight }
|
||||
}
|
||||
)
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user