Files
OSGKeyboard/OSGKeyboardTests/KeyboardTranslationConfigProtectionTests.swift
T
Rocky 498f407585 feat(account): add managed credits and cloud gateway
Introduce optional Apple account-backed credits with scoped gateway access while preserving local and BYOK paths. Refresh assistant behavior, tests, privacy disclosures, docs, and the website for the 2.0 experience.
2026-08-20 11:43:21 +08:00

37 lines
1.2 KiB
Swift

// KeyboardTranslationConfigProtectionTests.swift
// OSGKeyboardTests
@testable import OSGKeyboardShared
import XCTest
final class KeyboardTranslationConfigProtectionTests: XCTestCase {
func testGraceWindowProtectsUntilDeadline() {
let now = Date(timeIntervalSince1970: 1_700_000_000)
let deadline = KeyboardTranslationConfigProtection.protectionDeadline(now: now)
XCTAssertEqual(
deadline.timeIntervalSince(now),
KeyboardTranslationConfigProtection.chipWriteGraceSeconds,
accuracy: 0.001
)
XCTAssertTrue(
KeyboardTranslationConfigProtection.shouldProtect(until: deadline, now: now)
)
XCTAssertTrue(
KeyboardTranslationConfigProtection.shouldProtect(
until: deadline,
now: now.addingTimeInterval(2.4)
)
)
XCTAssertFalse(
KeyboardTranslationConfigProtection.shouldProtect(
until: deadline,
now: deadline
)
)
XCTAssertFalse(
KeyboardTranslationConfigProtection.shouldProtect(until: nil, now: now)
)
}
}