import CoreGraphics import Testing @testable import Kanban /// `BoardMetrics` — the board strip's arithmetic. Most of it is a multiple of the body font and /// needs no assertion beyond the one every figure already carries (it renders what the board always /// rendered at 13pt); what is worth pinning is the one figure that is *not* font-derived at all. private let body: CGFloat = 13 @Suite("BoardMetrics · the card replica's width") struct CardReplicaWidthTests { @Test("The measured face's width wins — the replica is the face it was lifted from") func measuredWidthWins() { // A face in a wide lane, and one in a narrow three-column lane: neither is the nominal // figure, and both are what the drag image must be drawn at. #expect(BoardMetrics.cardReplicaWidth(measured: 340, bodyPointSize: body) == 340) #expect(BoardMetrics.cardReplicaWidth(measured: 148, bodyPointSize: body) == 148) } @Test("A face that has not laid out yet falls back to the representative width") func unmeasuredFallsBack() { let fallback = BoardMetrics.cardReplicaWidth(bodyPointSize: body) #expect(BoardMetrics.cardReplicaWidth(measured: 0, bodyPointSize: body) == fallback) #expect(BoardMetrics.cardReplicaWidth(measured: -20, bodyPointSize: body) == fallback) #expect(BoardMetrics.cardReplicaWidth(measured: .nan, bodyPointSize: body) == fallback) #expect(BoardMetrics.cardReplicaWidth(measured: .infinity, bodyPointSize: body) == fallback) } @Test("The fallback scales with the body font, like every other figure here") func fallbackScales() { #expect(BoardMetrics.cardReplicaWidth(bodyPointSize: 26) > BoardMetrics.cardReplicaWidth(bodyPointSize: body)) } }