Files
OpenAppLock/OpenAppLockTests/RuleConfigurationTests.swift
Brendan Chen d005ed4fb1 docs: remove references to the source app and recording
Prepare for open-sourcing: scrub the prior-art attribution from the spec,
agent guide, and code comments so the project documents its own behavior.

- Reword RULES_FEATURE_SPEC.md to describe OpenAppLock's rules feature
  directly (drop the screen-recording source line and "as observed"/
  "not demoed"/"as shown" framing)
- Replace "the reference app/UI/style/defaults" comments and test names
  with direct descriptions of the behavior
- No behavior change; comments, docs, and @Test display names only

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 22:23:14 -04:00

45 lines
1.6 KiB
Swift

//
// RuleConfigurationTests.swift
// OpenAppLockTests
//
import Foundation
import Testing
@testable import OpenAppLock
@MainActor
@Suite("RuleConfiguration sum type")
struct RuleConfigurationTests {
@Test("Each case reports its kind")
func kindDerivation() {
#expect(RuleConfiguration.schedule(ScheduleConfig()).kind == .schedule)
#expect(RuleConfiguration.timeLimit(TimeLimitConfig()).kind == .timeLimit)
#expect(RuleConfiguration.openLimit(OpenLimitConfig()).kind == .openLimit)
}
@Test("Defaults match the documented new-rule defaults")
func defaults() {
let schedule = RuleConfiguration.default(for: .schedule).scheduleConfig
#expect(schedule?.startMinutes == 9 * 60)
#expect(schedule?.endMinutes == 17 * 60)
#expect(schedule?.selectionMode == .block)
#expect(schedule?.blockAdultContent == false)
#expect(RuleConfiguration.default(for: .timeLimit).timeLimitConfig?.dailyLimitMinutes == 45)
#expect(RuleConfiguration.default(for: .openLimit).openLimitConfig?.maxOpens == 5)
}
@Test("Typed projections only unwrap the matching case")
func projections() {
let schedule = RuleConfiguration.schedule(ScheduleConfig(blockAdultContent: true))
#expect(schedule.scheduleConfig?.blockAdultContent == true)
#expect(schedule.timeLimitConfig == nil)
#expect(schedule.openLimitConfig == nil)
let openLimit = RuleConfiguration.openLimit(OpenLimitConfig(maxOpens: 7))
#expect(openLimit.openLimitConfig?.maxOpens == 7)
#expect(openLimit.scheduleConfig == nil)
}
}