Some checks failed
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.
29 lines
1.1 KiB
Swift
29 lines
1.1 KiB
Swift
import XCTest
|
|
@testable import IDPGlobal
|
|
|
|
final class PairingPayloadParserTests: XCTestCase {
|
|
func testParsesStructuredPairingPayload() throws {
|
|
let payload = "idp.global://pair?token=swiftapp-demo-berlin&origin=code.foss.global&device=Safari%20on%20Berlin%20MBP"
|
|
|
|
let context = try PairingPayloadParser.parse(payload)
|
|
|
|
XCTAssertEqual(context.deviceName, "Safari on Berlin MBP")
|
|
XCTAssertEqual(context.originHost, "code.foss.global")
|
|
XCTAssertEqual(context.tokenPreview, "berlin")
|
|
}
|
|
|
|
func testParsesManualFallbackPayload() throws {
|
|
let context = try PairingPayloadParser.parse("manual pair token 1234567890")
|
|
|
|
XCTAssertEqual(context.deviceName, "Manual Session")
|
|
XCTAssertEqual(context.originHost, "code.foss.global")
|
|
XCTAssertEqual(context.tokenPreview, "567890")
|
|
}
|
|
|
|
func testRejectsInvalidPayload() {
|
|
XCTAssertThrowsError(try PairingPayloadParser.parse("https://example.com")) { error in
|
|
XCTAssertEqual(error as? AppError, .invalidPairingPayload)
|
|
}
|
|
}
|
|
}
|