blob: 5b574f7064370a58e98fc32fc16305a4eafa6e3d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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)
}
}
|