TheNoiseClock/TheNoiseClockTests/TheNoiseClockTests.swift
Matt Bruce d2c6a09e47 more refactoring by codex
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
2026-02-08 10:48:39 -06:00

49 lines
1.2 KiB
Swift

//
// TheNoiseClockTests.swift
// TheNoiseClockTests
//
// Created by Matt Bruce on 9/7/25.
//
import Testing
@testable import The_Noise_Clock
import Foundation
@MainActor
struct TheNoiseClockTests {
@Test
func defaultAlarmSoundIsMP3() {
#expect(AppConstants.SystemSounds.defaultSound.hasSuffix(".mp3"))
}
@Test
func nextOccurrenceIsInFuture() {
let oneMinuteAgo = Calendar.current.date(byAdding: .minute, value: -1, to: Date()) ?? Date()
let next = oneMinuteAgo.nextOccurrence()
#expect(next > Date())
#expect(next.timeIntervalSinceNow < 26 * 60 * 60)
}
@Test
func clockStyleCodableRoundTripPreservesSettings() throws {
let style = ClockStyle()
style.showSeconds = true
style.showDate = false
style.keepAwake = true
style.fontFamily = .avenir
style.digitAnimationStyle = .glitch
let data = try JSONEncoder().encode(style)
let decoded = try JSONDecoder().decode(ClockStyle.self, from: data)
#expect(decoded.showSeconds)
#expect(decoded.showDate == false)
#expect(decoded.keepAwake)
#expect(decoded.fontFamily == .avenir)
#expect(decoded.digitAnimationStyle == .glitch)
}
}