a6939453f8
CI / test (push) Has been cancelled
Move the app payload under swift/ while keeping git, package.json, and .smartconfig.json at the repo root. This standardizes the Swift app setup so build, test, run, and watch workflows match the other repos.
24 lines
1.1 KiB
Swift
24 lines
1.1 KiB
Swift
import XCTest
|
|
@testable import IDPGlobal
|
|
|
|
final class OneTimePasscodeGeneratorTests: XCTestCase {
|
|
func testCodeStaysStableWithinWindow() {
|
|
let firstDate = Date(timeIntervalSince1970: 60)
|
|
let secondDate = Date(timeIntervalSince1970: 89)
|
|
let nextWindowDate = Date(timeIntervalSince1970: 90)
|
|
|
|
let firstCode = OneTimePasscodeGenerator.code(for: "pairing-payload", at: firstDate)
|
|
let secondCode = OneTimePasscodeGenerator.code(for: "pairing-payload", at: secondDate)
|
|
let nextWindowCode = OneTimePasscodeGenerator.code(for: "pairing-payload", at: nextWindowDate)
|
|
|
|
XCTAssertEqual(firstCode, secondCode)
|
|
XCTAssertNotEqual(firstCode, nextWindowCode)
|
|
}
|
|
|
|
func testRenewalCountdownResetsAtBoundary() {
|
|
XCTAssertEqual(OneTimePasscodeGenerator.renewalCountdown(at: Date(timeIntervalSince1970: 90)), 30)
|
|
XCTAssertEqual(OneTimePasscodeGenerator.renewalCountdown(at: Date(timeIntervalSince1970: 119)), 1)
|
|
XCTAssertEqual(OneTimePasscodeGenerator.renewalCountdown(at: Date(timeIntervalSince1970: 120)), 30)
|
|
}
|
|
}
|