diff options
Diffstat (limited to 'DomainDigTests/AppInfoTests.swift')
| -rw-r--r-- | DomainDigTests/AppInfoTests.swift | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/DomainDigTests/AppInfoTests.swift b/DomainDigTests/AppInfoTests.swift new file mode 100644 index 0000000..5b574f7 --- /dev/null +++ b/DomainDigTests/AppInfoTests.swift @@ -0,0 +1,45 @@ +import XCTest +@testable import DomainDig + +/// Tests for the App Info surface's deterministic logic: the mailto builder, the +/// version display format, and that the bundled release notes ship and parse. +final class AppInfoTests: XCTestCase { + + func testMailURLEncodesSubjectAndBody() throws { + let url = try XCTUnwrap(AppInfoView.mailURL( + to: "[email protected]", + subject: "DomainDig Issue Report", + body: "line one\nline two" + )) + + XCTAssertEqual(url.scheme, "mailto") + let string = url.absoluteString + XCTAssertTrue(string.hasPrefix("mailto:[email protected]?")) + XCTAssertTrue(string.contains("subject=DomainDig%20Issue%20Report")) + XCTAssertTrue(string.contains("body=line%20one%0Aline%20two")) + } + + func testMailURLOmitsEmptyQueryItems() throws { + let url = try XCTUnwrap(AppInfoView.mailURL(to: "[email protected]", subject: "", body: "")) + XCTAssertEqual(url.absoluteString, "mailto:[email protected]") + } + + func testVersionDisplayPairsMarketingVersionAndBuild() { + XCTAssertEqual(AppInfo.versionDisplay, "\(AppInfo.marketingVersion) (build \(AppInfo.buildNumber))") + } + + func testDiagnosticsReportContainsVersionOSAndModelOnly() { + let report = AppInfo.diagnosticsReport + XCTAssertTrue(report.contains(AppInfo.marketingVersion)) + XCTAssertTrue(report.contains(AppInfo.systemVersion)) + XCTAssertTrue(report.contains(AppInfo.deviceModel)) + // Three lines, nothing more — no identifiers beyond version/OS/model. + XCTAssertEqual(report.split(separator: "\n").count, 3) + } + + func testBundledReleaseNotesShipAndParse() throws { + let notes = try XCTUnwrap(ReleaseNotes.bundled(), "ReleaseNotes.json must be bundled and decodable") + XCTAssertFalse(notes.version.isEmpty) + XCTAssertFalse(notes.highlights.isEmpty) + } +} |
