Files
TUIkit/Tests/TUIkitTests/PulseTimerTests.swift
T
phranck 82544e0e02 Refactor: Add Swift 6 @MainActor to View hierarchy
Add @MainActor to View, ViewModifier, Renderable, App, Scene protocols and all builders (ViewBuilder, SceneBuilder, ChildInfoProvider). Update renderToBuffer(), makeChildInfo(), resolveChildInfos() for main-actor isolation. Mark generic Equatable conformances with @preconcurrency. Update all 45 test suites with @MainActor annotation.
2026-02-07 02:50:41 +01:00

50 lines
1.1 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 🖥️ TUIKit — Terminal UI Kit for Swift
// PulseTimerTests.swift
//
// Created by LAYERED.work
// License: MIT
import Testing
@testable import TUIkit
@MainActor
@Suite("PulseTimer Tests")
struct PulseTimerTests {
@Test("Initial phase is zero")
func initialPhaseZero() {
let appState = AppState()
let timer = PulseTimer(renderNotifier: appState)
#expect(timer.phase == 0)
}
@Test("Phase stays within 0-1 range")
func phaseRange() {
let appState = AppState()
let timer = PulseTimer(renderNotifier: appState)
// Phase is computed from sin(), which for our mapping gives 0–1
let phase = timer.phase
#expect(phase >= 0 && phase <= 1)
}
@Test("Start and stop are balanced")
func startStopBalanced() {
let appState = AppState()
let timer = PulseTimer(renderNotifier: appState)
// Should not crash when stopped without starting
timer.stop()
// Start then stop
timer.start()
timer.stop()
// Double start should be a no-op
timer.start()
timer.start()
timer.stop()
}
}