import HelderCore import Testing @Suite struct ColumnLayoutTests { @Test func roomyWindowUsesTheDesignRatios() { let w = ColumnLayout.fluid(windowWidth: 1760, focus: .terminal) #expect(w == ColumnWidths(sourceControl: 236, 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(sourceControl: 400, explorer: 400, agent: 400), windowWidth: 1000, visible: .all) #expect(fitted.sourceControl + fitted.explorer + fitted.agent <= 1000 - 3 - ColumnLayout.minEditorWidth) } @Test func aHiddenColumnIsNeitherCountedNorScaled() { let widths = ColumnWidths(sourceControl: 400, explorer: 400, agent: 400) let visible = ColumnVisibility(sourceControl: false) let fitted = ColumnLayout.fitted(widths, windowWidth: 1000, visible: visible) #expect(fitted.sourceControl == 400) #expect(fitted.explorer + fitted.agent <= 1000 - 2 - ColumnLayout.minEditorWidth) } @Test func withTheEditorHiddenTheAgentIsTheFlexColumn() { let widths = ColumnWidths(sourceControl: 400, explorer: 400, agent: 900) let fitted = ColumnLayout.fitted(widths, windowWidth: 1000, visible: ColumnVisibility(editor: false)) #expect(fitted.agent == 900) #expect(fitted.sourceControl + fitted.explorer <= 1000 - 2 - ColumnLayout.minEditorWidth) } @Test func withoutAFlexColumnTheFixedOnesOnlyHaveToFitTheWindow() { let widths = ColumnWidths(sourceControl: 300, explorer: 300, agent: 480) let visible = ColumnVisibility(editor: false, agent: false) #expect(ColumnLayout.fitted(widths, windowWidth: 1000, visible: visible) == widths) let narrow = ColumnLayout.fitted(widths, windowWidth: 501, visible: visible) #expect(narrow.sourceControl + narrow.explorer <= 500) #expect(narrow.agent == 480) } @Test func fittingWithOnlyTheAgentBesideTheEditor() { let widths = ColumnWidths(sourceControl: 300, explorer: 300, agent: 900) let fitted = ColumnLayout.fitted(widths, windowWidth: 1000, visible: ColumnVisibility(sourceControl: false, explorer: false)) #expect(fitted.sourceControl == 300) #expect(fitted.agent <= 1000 - 1 - ColumnLayout.minEditorWidth) #expect(fitted.agent >= 1000 - 2 - ColumnLayout.minEditorWidth) } @Test func splittersSitOnlyBetweenVisibleColumns() { #expect(ColumnVisibility.all.splitterCount == 3) #expect(ColumnVisibility(sourceControl: false, editor: false).splitterCount == 1) #expect(ColumnVisibility(sourceControl: false, explorer: false, editor: false, agent: false).splitterCount == 0) } @Test func theAgentLimitCountsOnlyVisibleColumns() { let widths = ColumnWidths(sourceControl: 300, explorer: 300, agent: 480) #expect(ColumnLayout.maxAgentWidth(windowWidth: 1600, widths: widths, visible: .all) == 1600 - 3 - 600 - ColumnLayout.minEditorWidth) #expect(ColumnLayout.maxAgentWidth(windowWidth: 1600, widths: widths, visible: ColumnVisibility(explorer: false)) == 1600 - 2 - 300 - ColumnLayout.minEditorWidth) } }