krz/domain-dig
an ios app for DNS & SSL analysis
clone: git clone https://gitbay.org/krz/domain-dig.git
v5.0.1: DomainDigTests/AppInfoTests.swift · raw
1import XCTest
2@testable import DomainDig
3
4/// Tests for the App Info surface's deterministic logic: the mailto builder, the
5/// version display format, and that the bundled release notes ship and parse.
6final class AppInfoTests: XCTestCase {
7
8 func testMailURLEncodesSubjectAndBody() throws {
9 let url = try XCTUnwrap(AppInfoView.mailURL(
10 to: "hello@zerolabs.sh",
11 subject: "DomainDig Issue Report",
12 body: "line one\nline two"
13 ))
14
15 XCTAssertEqual(url.scheme, "mailto")
16 let string = url.absoluteString
17 XCTAssertTrue(string.hasPrefix("mailto:hello@zerolabs.sh?"))
18 XCTAssertTrue(string.contains("subject=DomainDig%20Issue%20Report"))
19 XCTAssertTrue(string.contains("body=line%20one%0Aline%20two"))
20 }
21
22 func testMailURLOmitsEmptyQueryItems() throws {
23 let url = try XCTUnwrap(AppInfoView.mailURL(to: "hello@zerolabs.sh", subject: "", body: ""))
24 XCTAssertEqual(url.absoluteString, "mailto:hello@zerolabs.sh")
25 }
26
27 func testVersionDisplayPairsMarketingVersionAndBuild() {
28 XCTAssertEqual(AppInfo.versionDisplay, "\(AppInfo.marketingVersion) (build \(AppInfo.buildNumber))")
29 }
30
31 func testDiagnosticsReportContainsVersionOSAndModelOnly() {
32 let report = AppInfo.diagnosticsReport
33 XCTAssertTrue(report.contains(AppInfo.marketingVersion))
34 XCTAssertTrue(report.contains(AppInfo.systemVersion))
35 XCTAssertTrue(report.contains(AppInfo.deviceModel))
36 // Three lines, nothing more — no identifiers beyond version/OS/model.
37 XCTAssertEqual(report.split(separator: "\n").count, 3)
38 }
39
40 func testBundledReleaseNotesShipAndParse() throws {
41 let notes = try XCTUnwrap(ReleaseNotes.bundled(), "ReleaseNotes.json must be bundled and decodable")
42 XCTAssertFalse(notes.version.isEmpty)
43 XCTAssertFalse(notes.highlights.isEmpty)
44 }
45}