diff options
| author | Christian Cleberg <[email protected]> | 2026-04-12 00:55:42 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-12 00:55:42 -0500 |
| commit | 9050405b4f33b2b9b70458fcf3e43b80c940eef7 (patch) | |
| tree | 983c3a07a560258059cfe421beb3ffcf3c18baf4 /HutchTests/DeepLinkTests.swift | |
| parent | 5f6d545eb3455a9e4da5a3cb4460811e3a48d939 (diff) | |
| download | hutch-2.15.0.tar.gz hutch-2.15.0.tar.bz2 hutch-2.15.0.zip | |
add shortcuts widgets and power-user workflowsv2.15.0
Diffstat (limited to 'HutchTests/DeepLinkTests.swift')
| -rw-r--r-- | HutchTests/DeepLinkTests.swift | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/HutchTests/DeepLinkTests.swift b/HutchTests/DeepLinkTests.swift new file mode 100644 index 0000000..12f759b --- /dev/null +++ b/HutchTests/DeepLinkTests.swift @@ -0,0 +1,90 @@ +import Foundation +import Testing +@testable import Hutch + +struct DeepLinkTests { + + @Test + func parsesHomeLink() { + let link = DeepLink(url: URL(string: "hutch://home")!) + #expect(link == .home) + } + + @Test + func parsesNilPathAsHome() { + let link = DeepLink(url: URL(string: "hutch://")!) + #expect(link == .home) + } + + @Test + func parsesRepositoryLink() { + let link = DeepLink(url: URL(string: "hutch://git/~user/repo")!) + #expect(link == .repository(owner: "~user", repo: "repo")) + } + + @Test + func parsesTicketLink() { + let link = DeepLink(url: URL(string: "hutch://todo/~owner/tracker/42")!) + #expect(link == .ticket(owner: "~owner", tracker: "tracker", ticketId: 42)) + } + + @Test + func parsesBuildJobLink() { + let link = DeepLink(url: URL(string: "hutch://builds/12345")!) + #expect(link == .build(jobId: 12345)) + } + + @Test + func parsesBuildsTabLink() { + let link = DeepLink(url: URL(string: "hutch://builds")!) + #expect(link == .buildsTab) + } + + @Test + func parsesRepositoriesTabLink() { + let link = DeepLink(url: URL(string: "hutch://repositories")!) + #expect(link == .repositoriesTab) + } + + @Test + func parsesTrackersTabLink() { + let link = DeepLink(url: URL(string: "hutch://trackers")!) + #expect(link == .trackersTab) + } + + @Test + func parsesSystemStatusLink() { + let link = DeepLink(url: URL(string: "hutch://status")!) + #expect(link == .systemStatus) + } + + @Test + func parsesLookupLink() { + let link = DeepLink(url: URL(string: "hutch://lookup")!) + #expect(link == .lookup) + } + + @Test + func rejectsNonHutchScheme() { + let link = DeepLink(url: URL(string: "https://example.com/home")!) + #expect(link == nil) + } + + @Test + func rejectsUnknownPath() { + let link = DeepLink(url: URL(string: "hutch://unknown")!) + #expect(link == nil) + } + + @Test + func rejectsTicketLinkWithNonNumericId() { + let link = DeepLink(url: URL(string: "hutch://todo/~owner/tracker/abc")!) + #expect(link == nil) + } + + @Test + func rejectsBuildLinkWithNonNumericId() { + let link = DeepLink(url: URL(string: "hutch://builds/abc")!) + #expect(link == nil) + } +} |
