Test: Remove 78 worthless tests (property readback, tautologies, redundancies)

This commit is contained in:
phranck
2026-02-01 04:20:46 +01:00
parent 07ad15320c
commit 32f06bcd98
13 changed files with 0 additions and 736 deletions
@@ -10,32 +10,6 @@ import Testing
@testable import TUIkit
// MARK: - Constants Tests
@Suite("ANSIRenderer Constants Tests")
struct ANSIRendererConstantsTests {
@Test("escape is ESC character")
func escapeChar() {
#expect(ANSIRenderer.escape == "\u{1B}")
}
@Test("csi is ESC[")
func csiSequence() {
#expect(ANSIRenderer.csi == "\u{1B}[")
}
@Test("reset is ESC[0m")
func resetCode() {
#expect(ANSIRenderer.reset == "\u{1B}[0m")
}
@Test("dim is ESC[2m")
func dimCode() {
#expect(ANSIRenderer.dim == "\u{1B}[2m")
}
}
// MARK: - Style Rendering Tests
@Suite("ANSIRenderer Style Rendering Tests")
-70
View File
@@ -14,23 +14,6 @@ import Testing
@Suite("Appearance Tests")
struct AppearanceTests {
// MARK: - Appearance ID Tests
@Test("Predefined appearance IDs exist")
func predefinedAppearanceIds() {
#expect(Appearance.ID.line.rawValue == "line")
#expect(Appearance.ID.rounded.rawValue == "rounded")
#expect(Appearance.ID.doubleLine.rawValue == "doubleLine")
#expect(Appearance.ID.heavy.rawValue == "heavy")
#expect(Appearance.ID.block.rawValue == "block")
}
@Test("Appearance IDs are hashable")
func appearanceIdHashable() {
let ids: Set<Appearance.ID> = [.line, .rounded, .doubleLine, .heavy, .block]
#expect(ids.count == 5)
}
// MARK: - Appearance Struct Tests
@Test("Appearance name is derived from ID")
@@ -43,15 +26,6 @@ struct AppearanceTests {
#expect(Appearance.block.name == "Block")
}
@Test("Predefined appearances have correct border styles")
func predefinedAppearances() {
#expect(Appearance.line.borderStyle == .line)
#expect(Appearance.rounded.borderStyle == .rounded)
#expect(Appearance.doubleLine.borderStyle == .doubleLine)
#expect(Appearance.heavy.borderStyle == .heavy)
#expect(Appearance.block.borderStyle == .block)
}
@Test("Default appearance is rounded")
func defaultAppearance() {
#expect(Appearance.default.rawId == .rounded)
@@ -106,50 +80,6 @@ struct AppearanceTests {
// MARK: - Cyclable Conformance
@Test("Appearance conforms to Cyclable with string id")
func cyclableConformance() {
let appearance = Appearance.rounded
let cyclable: any Cyclable = appearance
#expect(cyclable.id == "rounded")
#expect(cyclable.name == "Rounded")
}
}
// MARK: - Appearance Manager Tests (ThemeManager)
@Suite("Appearance Manager Tests")
struct AppearanceManagerTests {
/// Creates a ThemeManager for appearances (test helper).
private func makeAppearanceManager(items: [Appearance] = AppearanceRegistry.all) -> ThemeManager {
ThemeManager(items: items)
}
@Test("ThemeManager for appearances can be instantiated")
func managerCreation() {
let manager = makeAppearanceManager()
#expect(manager.items.count == 5)
}
@Test("ThemeManager for appearances starts with first appearance (line)")
func managerStartsWithLine() {
let manager = makeAppearanceManager()
#expect(manager.currentAppearance?.rawId == .line)
}
@Test("ThemeManager for appearances currentName returns capitalized name")
func managerCurrentName() {
let manager = makeAppearanceManager()
#expect(manager.currentName == "Line")
}
@Test("ThemeManager for appearances can be created with custom items")
func managerCustomAppearances() {
let custom: [Appearance] = [.rounded, .heavy]
let manager = makeAppearanceManager(items: custom)
#expect(manager.items.count == 2)
#expect(manager.currentAppearance?.rawId == .rounded)
}
}
// MARK: - Appearance Environment Tests
@@ -14,11 +14,6 @@ import Testing
@Suite("BorderRenderer Standard Style Tests")
struct BorderRendererStandardTests {
@Test("borderWidthOverhead is 2")
func widthOverhead() {
#expect(BorderRenderer.borderWidthOverhead == 2)
}
@Test("standardTopBorder uses correct corner characters")
func topBorderCorners() {
let result = BorderRenderer.standardTopBorder(
-72
View File
@@ -24,69 +24,6 @@ private func createTestContext(width: Int = 80, height: Int = 24) -> RenderConte
)
}
// MARK: - Button Style Tests
@Suite("Button Style Tests")
struct ButtonStyleTests {
@Test("Default button style uses appearance default")
func defaultStyle() {
let style = ButtonStyle.default
// nil means "use appearance.borderStyle at render time"
#expect(style.borderStyle == nil)
#expect(style.horizontalPadding == 2)
#expect(style.isBold == false)
}
@Test("Primary button style")
func primaryStyle() {
let style = ButtonStyle.primary
#expect(style.foregroundColor == .cyan)
#expect(style.borderColor == .cyan)
#expect(style.isBold == true)
}
@Test("Destructive button style")
func destructiveStyle() {
let style = ButtonStyle.destructive
#expect(style.foregroundColor == .red)
#expect(style.borderColor == .red)
}
@Test("Success button style")
func successStyle() {
let style = ButtonStyle.success
#expect(style.foregroundColor == .green)
#expect(style.borderColor == .green)
}
@Test("Plain button style has no border")
func plainStyle() {
let style = ButtonStyle.plain
// Plain uses BorderStyle.none (invisible border) to explicitly disable borders
#expect(style.borderStyle == BorderStyle.none)
#expect(style.horizontalPadding == 0)
}
@Test("Custom button style")
func customStyle() {
let style = ButtonStyle(
foregroundColor: Color.yellow,
backgroundColor: Color.blue,
borderStyle: .line,
borderColor: Color.magenta,
isBold: true,
horizontalPadding: 4
)
#expect(style.foregroundColor == .yellow)
#expect(style.backgroundColor == .blue)
#expect(style.borderStyle == .line)
#expect(style.borderColor == .magenta)
#expect(style.isBold == true)
#expect(style.horizontalPadding == 4)
}
}
// MARK: - Button Tests
@Suite("Button Tests", .serialized)
@@ -175,15 +112,6 @@ struct ButtonTests {
#expect(!allContent.contains(""), "Focused bold button should not have ▸ indicator")
}
@Test("Button default focused style uses theme colors")
func buttonDefaultFocusedStyle() {
let button = Button("Test") {}
// Default focused style should use theme colors (nil = resolved at render time)
#expect(button.focusedStyle.foregroundColor == nil)
#expect(button.focusedStyle.borderColor == nil)
#expect(button.focusedStyle.isBold == true)
}
}
// MARK: - Button Handler Tests
@@ -75,17 +75,6 @@ struct BoxTests {
@Suite("Card Tests")
struct CardTests {
@Test("Card can be created with footer")
func cardWithFooter() {
let card = Card(title: "Info") {
Text("Body")
} footer: {
Text("Footer")
}
#expect(card.title == "Info")
#expect(card.footer != nil)
}
@Test("Card renders with border")
func cardRenders() {
let card = Card(title: "Test") {
@@ -136,17 +125,6 @@ struct CardTests {
@Suite("Panel Tests")
struct PanelTests {
@Test("Panel can be created with footer")
func panelWithFooter() {
let panel = Panel("Info") {
Text("Content")
} footer: {
Text("Done")
}
#expect(panel.title == "Info")
#expect(panel.footer != nil)
}
@Test("Panel renders with border and title")
func panelRenders() {
let panel = Panel("Test Panel") {
@@ -178,34 +156,6 @@ struct PanelTests {
#expect(bufferWith.height > bufferWithout.height)
}
@Test("Panel default padding is horizontal only")
func panelDefaultPadding() {
let panel = Panel("Test") {
Text("Content")
}
#expect(panel.config.padding.leading == 1)
#expect(panel.config.padding.trailing == 1)
#expect(panel.config.padding.top == 0)
#expect(panel.config.padding.bottom == 0)
}
}
// MARK: - ContainerConfig Tests
@Suite("ContainerConfig Tests")
struct ContainerConfigTests {
@Test("Default config has expected values")
func defaultConfig() {
let config = ContainerConfig.default
#expect(config.borderStyle == nil)
#expect(config.borderColor == nil)
#expect(config.titleColor == nil)
#expect(config.padding.leading == 1)
#expect(config.padding.trailing == 1)
#expect(config.showFooterSeparator == true)
}
}
// MARK: - ContainerView Tests
@@ -237,32 +187,6 @@ struct ForEachTests {
let name: String
}
@Test("ForEach can be created with Identifiable data")
func forEachIdentifiable() {
let items = [TestItem(id: "1", name: "One"), TestItem(id: "2", name: "Two")]
let forEach = ForEach(items) { item in
Text(item.name)
}
#expect(forEach.data.count == 2)
}
@Test("ForEach can be created with explicit ID key path")
func forEachExplicitId() {
let names = ["Anna", "Bob", "Clara"]
let forEach = ForEach(names, id: \.self) { name in
Text(name)
}
#expect(forEach.data.count == 3)
}
@Test("ForEach can be created with Range")
func forEachRange() {
let forEach = ForEach(0..<5) { index in
Text("Item \(index)")
}
#expect(forEach.data.count == 5)
}
@Test("ForEach generates correct number of views")
func forEachViewGeneration() {
let items = [TestItem(id: "a", name: "Alpha"), TestItem(id: "b", name: "Beta")]
-15
View File
@@ -51,21 +51,6 @@ struct KeyEnumTests {
@Suite("KeyEvent Creation Tests")
struct KeyEventCreationTests {
@Test("KeyEvent default modifiers are false")
func defaultModifiers() {
let event = KeyEvent(key: .enter)
#expect(event.ctrl == false)
#expect(event.alt == false)
#expect(event.shift == false)
}
@Test("KeyEvent with ctrl modifier")
func ctrlModifier() {
let event = KeyEvent(key: .character("c"), ctrl: true)
#expect(event.ctrl == true)
#expect(event.alt == false)
}
@Test("KeyEvent character init detects uppercase as shift")
func characterInitShift() {
let upper = KeyEvent(character: "A")
@@ -1,35 +0,0 @@
//
// KeyPressModifierTests.swift
// TUIkit
//
// Tests for KeyPressModifier.
//
import Testing
@testable import TUIkit
@Suite("KeyPressModifier Tests")
struct KeyPressModifierTests {
@Test("onKeyPress with key set creates KeyPressModifier")
func onKeyPressKeySet() {
let modifier = KeyPressModifier(
content: Text("Hello"),
keys: [.enter, .tab],
handler: { _ in true }
)
#expect(modifier.keys?.count == 2)
}
@Test("onKeyPress single key creates modifier with that key")
func onKeyPressSingleKey() {
let modifier = KeyPressModifier(
content: Text("Hello"),
keys: [.enter],
handler: { _ in true }
)
#expect(modifier.keys?.count == 1)
#expect(modifier.keys?.contains(.enter) == true)
}
}
-72
View File
@@ -21,15 +21,6 @@ private func testContext(width: Int = 40, height: Int = 24) -> RenderContext {
@Suite("EdgeInsets Tests")
struct EdgeInsetsTests {
@Test("EdgeInsets individual values")
func edgeInsetsIndividual() {
let insets = EdgeInsets(top: 1, leading: 2, bottom: 3, trailing: 4)
#expect(insets.top == 1)
#expect(insets.leading == 2)
#expect(insets.bottom == 3)
#expect(insets.trailing == 4)
}
@Test("EdgeInsets uniform value")
func edgeInsetsUniform() {
let insets = EdgeInsets(all: 3)
@@ -48,15 +39,6 @@ struct EdgeInsetsTests {
#expect(insets.trailing == 2)
}
@Test("EdgeInsets default values are zero")
func edgeInsetsDefaults() {
let insets = EdgeInsets()
#expect(insets.top == 0)
#expect(insets.leading == 0)
#expect(insets.bottom == 0)
#expect(insets.trailing == 0)
}
@Test("EdgeInsets is Equatable")
func edgeInsetsEquatable() {
let insetsA = EdgeInsets(all: 2)
@@ -70,14 +52,6 @@ struct EdgeInsetsTests {
@Suite("Edge Tests")
struct EdgeTests {
@Test("Individual edges exist")
func individualEdges() {
#expect(Edge.top.rawValue == 1)
#expect(Edge.leading.rawValue == 2)
#expect(Edge.bottom.rawValue == 4)
#expect(Edge.trailing.rawValue == 8)
}
@Test("Edge.all contains all edges")
func edgeAll() {
#expect(Edge.all.contains(.top))
@@ -194,11 +168,6 @@ struct PaddingModifierTests {
@Suite("FrameModifier Tests")
struct FrameModifierTests {
@Test("FrameDimension.infinity and .max are equal")
func frameDimensionInfinity() {
#expect(FrameDimension.infinity == .max)
}
@Test("FlexibleFrameView with maxWidth infinity fills available width")
func frameMaxWidthInfinity() {
let frame = FlexibleFrameView(
@@ -455,42 +424,6 @@ struct BorderModifierTests {
@Suite("BorderStyle Tests")
struct BorderStyleTests {
@Test("Predefined styles exist")
func predefinedStyles() {
// Just verify they all exist and have distinct characters
#expect(BorderStyle.line.topLeft == "")
#expect(BorderStyle.doubleLine.topLeft == "")
#expect(BorderStyle.rounded.topLeft == "")
#expect(BorderStyle.heavy.topLeft == "")
#expect(BorderStyle.block.topLeft == "")
#expect(BorderStyle.ascii.topLeft == "+")
#expect(BorderStyle.none.topLeft == " ")
}
@Test("Line style has T-junctions")
func lineStyleTJunctions() {
#expect(BorderStyle.line.leftT == "")
#expect(BorderStyle.line.rightT == "")
}
@Test("DoubleLine style has T-junctions")
func doubleLineTJunctions() {
#expect(BorderStyle.doubleLine.leftT == "")
#expect(BorderStyle.doubleLine.rightT == "")
}
@Test("Heavy style has T-junctions")
func heavyTJunctions() {
#expect(BorderStyle.heavy.leftT == "")
#expect(BorderStyle.heavy.rightT == "")
}
@Test("BorderStyle is Equatable")
func borderStyleEquatable() {
#expect(BorderStyle.line == BorderStyle.line)
#expect(BorderStyle.line != BorderStyle.doubleLine)
}
@Test("Custom border style defaults T-junctions to vertical")
func customBorderStyleDefaultTJunctions() {
let custom = BorderStyle(
@@ -505,11 +438,6 @@ struct BorderStyleTests {
#expect(custom.rightT == "F")
}
@Test("Block style constants exist")
func blockStyleConstants() {
#expect(BorderStyle.blockBottomHorizontal == "")
#expect(BorderStyle.blockFooterSeparator == "")
}
}
// MARK: - BackgroundModifier Tests
@@ -12,11 +12,6 @@ import Testing
@Suite("NavigationTitleKey Tests")
struct NavigationTitleKeyTests {
@Test("Default value is empty string")
func defaultValue() {
#expect(NavigationTitleKey.defaultValue == "")
}
@Test("NavigationTitleKey uses last-value reduce")
func lastValueReduce() {
var value = NavigationTitleKey.defaultValue
@@ -30,13 +30,6 @@ private func relativeLuminance(of color: Color) -> Double? {
@Suite("Green Palette Tests")
struct GreenPaletteTests {
@Test("Green palette has correct identity")
func greenIdentity() {
let palette = GreenPalette()
#expect(palette.id == "green")
#expect(palette.name == "Green")
}
@Test("Green palette block surfaces get progressively brighter")
func greenBlockSurfaceLuminanceOrder() throws {
let palette = GreenPalette()
@@ -61,73 +54,15 @@ struct GreenPaletteTests {
#expect(fgSecLum > fgTerLum, "foregroundSecondary should be brighter than foregroundTertiary")
}
@Test("Green palette has all semantic colors")
func greenSemanticColors() {
let palette = GreenPalette()
#expect(palette.success != palette.error)
#expect(palette.warning != palette.info)
}
}
// MARK: - Amber Palette Tests
@Suite("Amber Palette Tests")
struct AmberPaletteTests {
@Test("Amber palette has correct identity")
func amberIdentity() {
let palette = AmberPalette()
#expect(palette.id == "amber")
#expect(palette.name == "Amber")
}
@Test("Amber palette colors differ from green palette")
func amberDiffersFromGreen() {
let amber = AmberPalette()
let green = GreenPalette()
#expect(amber.foreground != green.foreground)
#expect(amber.accent != green.accent)
}
}
// MARK: - White Palette Tests
@Suite("White Palette Tests")
struct WhitePaletteTests {
@Test("White palette has correct identity")
func whiteIdentity() {
let palette = WhitePalette()
#expect(palette.id == "white")
#expect(palette.name == "White")
}
}
// MARK: - Red Palette Tests
@Suite("Red Palette Tests")
struct RedPaletteTests {
@Test("Red palette has correct identity")
func redIdentity() {
let palette = RedPalette()
#expect(palette.id == "red")
#expect(palette.name == "Red")
}
}
// MARK: - Violet Palette Tests
@Suite("Violet Palette Tests")
struct VioletPaletteTests {
@Test("Violet palette has correct identity")
func violetIdentity() {
let palette = VioletPalette()
#expect(palette.id == "violet")
#expect(palette.name == "Violet")
}
@Test("Violet palette block surfaces get progressively brighter")
func violetBlockSurfaceLuminanceOrder() throws {
let palette = VioletPalette()
@@ -141,13 +76,6 @@ struct VioletPaletteTests {
#expect(elevatedLum > headerLum, "elevatedBackground should be brighter than surfaceHeaderBackground")
}
@Test("Violet palette colors differ from green palette")
func violetDiffersFromGreen() {
let violet = VioletPalette()
let green = GreenPalette()
#expect(violet.foreground != green.foreground)
#expect(violet.accent != green.accent)
}
}
// MARK: - Blue Palette Tests
@@ -155,13 +83,6 @@ struct VioletPaletteTests {
@Suite("Blue Palette Tests")
struct BluePaletteTests {
@Test("Blue palette has correct identity")
func blueIdentity() {
let palette = BluePalette()
#expect(palette.id == "blue")
#expect(palette.name == "Blue")
}
@Test("Blue palette block surfaces get progressively brighter")
func blueBlockSurfaceLuminanceOrder() throws {
let palette = BluePalette()
@@ -175,11 +96,4 @@ struct BluePaletteTests {
#expect(elevatedLum > headerLum, "elevatedBackground should be brighter than surfaceHeaderBackground")
}
@Test("Blue palette colors differ from violet palette")
func blueDiffersFromViolet() {
let blue = BluePalette()
let violet = VioletPalette()
#expect(blue.foreground != violet.foreground)
#expect(blue.accent != violet.accent)
}
}
@@ -28,13 +28,6 @@ struct StatePropertyWrapperTests {
AppState.active.didRender()
}
@Test("State projectedValue returns a Binding")
func stateProjectedValue() {
let state = State(wrappedValue: 42)
let binding = state.projectedValue
#expect(binding.wrappedValue == 42)
}
@Test("Binding from State updates original")
func stateBindingUpdates() {
let state = State(wrappedValue: 0)
@@ -43,12 +36,4 @@ struct StatePropertyWrapperTests {
#expect(state.wrappedValue == 77)
}
@Test("State with optional type")
func stateOptional() {
let state = State<String?>(wrappedValue: nil)
#expect(state.wrappedValue == nil)
state.wrappedValue = "now set"
#expect(state.wrappedValue == "now set")
AppState.active.didRender()
}
}
-175
View File
@@ -1,4 +1,3 @@
// swiftlint:disable file_length
//
// StatusBarTests.swift
// TUIkit
@@ -15,80 +14,6 @@ import Testing
@Suite("Shortcut Constants Tests")
struct ShortcutTests {
@Test("Special key symbols are correct")
func specialKeys() {
#expect(Shortcut.escape == "")
#expect(Shortcut.enter == "")
#expect(Shortcut.returnKey == "")
#expect(Shortcut.tab == "")
#expect(Shortcut.shiftTab == "")
#expect(Shortcut.backspace == "")
#expect(Shortcut.delete == "")
#expect(Shortcut.space == "")
}
@Test("Arrow key symbols are correct")
func arrowKeys() {
#expect(Shortcut.arrowUp == "")
#expect(Shortcut.arrowDown == "")
#expect(Shortcut.arrowLeft == "")
#expect(Shortcut.arrowRight == "")
}
@Test("Arrow key combinations are correct")
func arrowCombinations() {
#expect(Shortcut.arrowsUpDown == "↑↓")
#expect(Shortcut.arrowsLeftRight == "←→")
#expect(Shortcut.arrowsAll == "↑↓←→")
#expect(Shortcut.arrowsVertical == "")
#expect(Shortcut.arrowsHorizontal == "")
}
@Test("Modifier key symbols are correct")
func modifierKeys() {
#expect(Shortcut.command == "")
#expect(Shortcut.option == "")
#expect(Shortcut.control == "")
#expect(Shortcut.shift == "")
#expect(Shortcut.capsLock == "")
}
@Test("Navigation key symbols are correct")
func navigationKeys() {
#expect(Shortcut.home == "")
#expect(Shortcut.end == "")
#expect(Shortcut.pageUp == "")
#expect(Shortcut.pageDown == "")
}
@Test("Action symbols are correct")
func actionSymbols() {
#expect(Shortcut.plus == "+")
#expect(Shortcut.minus == "")
#expect(Shortcut.checkmark == "")
#expect(Shortcut.cross == "")
#expect(Shortcut.search == "?")
#expect(Shortcut.help == "?")
#expect(Shortcut.save == "S")
}
@Test("Common shortcuts are correct")
func commonShortcuts() {
#expect(Shortcut.quit == "q")
#expect(Shortcut.yes == "y")
#expect(Shortcut.no == "n")
#expect(Shortcut.cancel == "c")
#expect(Shortcut.ok == "o")
}
@Test("Selection indicators are correct")
func selectionIndicators() {
#expect(Shortcut.selectionRight == "")
#expect(Shortcut.selectionLeft == "")
#expect(Shortcut.bullet == "")
#expect(Shortcut.squareBullet == "")
}
@Test("Combine helper joins shortcuts")
func combineHelper() {
let result = Shortcut.combine(Shortcut.control, "c")
@@ -122,15 +47,6 @@ struct ShortcutTests {
@Suite("Status Bar Item Tests")
struct StatusBarItemTests {
@Test("StatusBarItem can be created")
func itemCreation() {
let item = StatusBarItem(shortcut: "q", label: "quit")
#expect(item.shortcut == "q")
#expect(item.label == "quit")
#expect(item.id == "q-quit")
}
@Test("StatusBarItem with action")
func itemWithAction() {
// Use a class to track execution since the closure is @Sendable
@@ -525,63 +441,6 @@ struct StatusBarStateTests {
@Suite("StatusBar Tests")
struct StatusBarTests {
@Test("StatusBar can be created with items")
func statusBarCreation() {
let statusBar = StatusBar(items: [
StatusBarItem(shortcut: "q", label: "quit"),
StatusBarItem(shortcut: "h", label: "help"),
])
#expect(statusBar.userItems.count == 2)
#expect(statusBar.style == .compact)
#expect(statusBar.alignment == .justified)
#expect(statusBar.highlightColor == .cyan)
}
@Test("StatusBar with style")
func statusBarWithStyle() {
let statusBar = StatusBar(
items: [StatusBarItem(shortcut: "x", label: "test")],
style: .bordered
)
#expect(statusBar.style == .bordered)
}
@Test("StatusBar with custom colors")
func statusBarWithColors() {
let statusBar = StatusBar(
items: [],
highlightColor: .yellow,
labelColor: .green
)
#expect(statusBar.highlightColor == .yellow)
#expect(statusBar.labelColor == .green)
}
@Test("StatusBar with builder")
func statusBarWithBuilder() {
let statusBar = StatusBar {
StatusBarItem(shortcut: "a", label: "alpha")
StatusBarItem(shortcut: "b", label: "beta")
}
#expect(statusBar.userItems.count == 2)
}
@Test("StatusBar compact height")
func compactHeight() {
let statusBar = StatusBar(items: [], style: .compact)
#expect(statusBar.height == 1)
}
@Test("StatusBar bordered height")
func borderedHeight() {
let statusBar = StatusBar(items: [], style: .bordered)
#expect(statusBar.height == 3)
}
@Test("StatusBar renders compact style")
func rendersCompact() {
let statusBar = StatusBar(
@@ -647,15 +506,6 @@ struct StatusBarTests {
#expect(content.contains("beta"))
}
@Test("StatusBar default alignment is justified")
func defaultAlignmentIsJustified() {
let statusBar = StatusBar(items: [
StatusBarItem(shortcut: "q", label: "quit")
])
#expect(statusBar.alignment == .justified)
}
@Test("StatusBar with leading alignment")
func leadingAlignment() {
let statusBar = StatusBar(
@@ -804,15 +654,6 @@ struct StatusBarItemBuilderTests {
#expect(result.count == 1)
}
@Test("Builder works with StatusBar initializer")
func builderWorksWithStatusBar() {
let statusBar = StatusBar {
StatusBarItem(shortcut: "x", label: "test")
StatusBarItem(shortcut: "y", label: "test2")
}
#expect(statusBar.userItems.count == 2)
}
}
// MARK: - StatusBarItems Modifier Tests
@@ -1006,22 +847,6 @@ struct SystemStatusBarItemsTests {
#expect(qItems[0].label == "custom-quit")
}
@Test("System item order constants are correct")
func systemItemOrderConstants() {
// System items should have high order values (900+)
#expect(StatusBarItemOrder.quit.value == 900)
#expect(StatusBarItemOrder.appearance.value == 910)
#expect(StatusBarItemOrder.theme.value == 920)
// User items should have lower order values
#expect(StatusBarItemOrder.default.value == 500)
#expect(StatusBarItemOrder.early.value == 100)
#expect(StatusBarItemOrder.late.value == 800)
// User items < system items
#expect(StatusBarItemOrder.late < StatusBarItemOrder.quit)
}
@Test("Items are sorted by order")
func itemsSortedByOrder() {
let state = StatusBarState()
-84
View File
@@ -9,90 +9,6 @@ import Testing
@testable import TUIkit
@Suite("View Protocol Tests")
struct ViewTests {
@Test("Text view with style")
func textViewWithStyle() {
let text = Text("Bold").bold().foregroundColor(.red)
#expect(text.style.isBold == true)
#expect(text.style.foregroundColor == .red)
}
@Test("Spacer can be created")
func spacerCreation() {
let spacer = Spacer()
#expect(spacer.minLength == nil)
let spacerWithLength = Spacer(minLength: 5)
#expect(spacerWithLength.minLength == 5)
}
@Test("Divider uses default character")
func dividerDefaultCharacter() {
let divider = Divider()
#expect(divider.character == "")
}
@Test("Divider with custom character")
func dividerCustomCharacter() {
let divider = Divider(character: "=")
#expect(divider.character == "=")
}
}
@Suite("ViewBuilder Tests")
struct ViewBuilderTests {
@Test("VStack can contain views")
func vstackWithViews() {
let stack = VStack {
Text("Line 1")
Text("Line 2")
}
#expect(stack.alignment == .leading)
#expect(stack.spacing == 0)
}
@Test("HStack can contain views")
func hstackWithViews() {
let stack = HStack {
Text("Left")
Text("Right")
}
#expect(stack.alignment == .center)
#expect(stack.spacing == 1)
}
@Test("VStack with alignment and spacing")
func vstackWithOptions() {
let stack = VStack(alignment: .center, spacing: 2) {
Text("Centered")
}
#expect(stack.alignment == .center)
#expect(stack.spacing == 2)
}
}
@Suite("Alignment Tests")
struct AlignmentTests {
@Test("Preset alignments are correct")
func presetAlignments() {
#expect(Alignment.topLeading.horizontal == .leading)
#expect(Alignment.topLeading.vertical == .top)
#expect(Alignment.center.horizontal == .center)
#expect(Alignment.center.vertical == .center)
#expect(Alignment.bottomTrailing.horizontal == .trailing)
#expect(Alignment.bottomTrailing.vertical == .bottom)
}
}
@Suite("AnyView Tests")
struct AnyViewTests {