Files
swiftapp/swift/Tests/PairingPayloadParserTests.swift
Jürgen Kunz a6939453f8
Some checks failed
CI / test (push) Has been cancelled
Adopt root-level tsswift app layout
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.
2026-04-19 01:21:43 +02:00

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)
}
}
}