Files
2026-10-30 13:21:45 +01:00

58 lines
2.7 KiB
Swift

import HelderCore
import Testing
@Suite struct ColumnLayoutTests {
@Test func roomyWindowUsesTheDesignRatios() {
let w = ColumnLayout.fluid(windowWidth: 1760, focus: .terminal)
#expect(w == ColumnWidths(explorer: 289, agent: 480))
}
@Test func tightWindowFollowsFocus() {
#expect(ColumnLayout.fluid(windowWidth: 1200, focus: .terminal).agent == 600)
#expect(ColumnLayout.fluid(windowWidth: 1200, focus: .editor).agent == 240)
}
@Test func fittingKeepsTheEditorMinimum() {
let fitted = ColumnLayout.fitted(ColumnWidths(explorer: 400, agent: 600), windowWidth: 1000, visible: .all)
#expect(fitted.explorer + fitted.agent <= 1000 - 2 - ColumnLayout.minEditorWidth)
}
@Test func aHiddenColumnIsNeitherCountedNorScaled() {
let widths = ColumnWidths(explorer: 400, agent: 900)
let visible = ColumnVisibility(explorer: false)
let fitted = ColumnLayout.fitted(widths, windowWidth: 1000, visible: visible)
#expect(fitted.explorer == 400)
#expect(fitted.agent <= 1000 - 1 - ColumnLayout.minEditorWidth)
#expect(fitted.agent >= 1000 - 2 - ColumnLayout.minEditorWidth)
}
@Test func withTheEditorHiddenTheAgentIsTheFlexColumn() {
let widths = ColumnWidths(explorer: 900, agent: 900)
let fitted = ColumnLayout.fitted(widths, windowWidth: 1000, visible: ColumnVisibility(editor: false))
#expect(fitted.agent == 900)
#expect(fitted.explorer <= 1000 - 1 - ColumnLayout.minEditorWidth)
}
@Test func withoutAFlexColumnTheFixedOnesOnlyHaveToFitTheWindow() {
let widths = ColumnWidths(explorer: 400, agent: 480)
let visible = ColumnVisibility(editor: false, agent: false)
#expect(ColumnLayout.fitted(widths, windowWidth: 1000, visible: visible) == widths)
let narrow = ColumnLayout.fitted(widths, windowWidth: 300, visible: visible)
#expect(narrow.explorer <= 300)
#expect(narrow.agent == 480)
}
@Test func splittersSitOnlyBetweenVisibleColumns() {
#expect(ColumnVisibility.all.splitterCount == 2)
#expect(ColumnVisibility(editor: false).splitterCount == 1)
#expect(ColumnVisibility(explorer: false, editor: false, agent: false).splitterCount == 0)
}
@Test func theAgentLimitCountsOnlyVisibleColumns() {
let widths = ColumnWidths(explorer: 300, agent: 480)
#expect(ColumnLayout.maxAgentWidth(windowWidth: 1600, widths: widths, visible: .all) == 1600 - 2 - 300 - ColumnLayout.minEditorWidth)
#expect(ColumnLayout.maxAgentWidth(windowWidth: 1600, widths: widths, visible: ColumnVisibility(explorer: false))
== 1600 - 1 - ColumnLayout.minEditorWidth)
}
}