2024-01-01 08:48:53 +00:00
|
|
|
@testable import Env
|
|
|
|
import Network
|
2024-02-14 11:48:14 +00:00
|
|
|
import SwiftUI
|
|
|
|
import XCTest
|
2024-06-12 05:42:02 +00:00
|
|
|
import Testing
|
2024-01-01 08:48:53 +00:00
|
|
|
|
2024-06-12 05:42:02 +00:00
|
|
|
@Test
|
2024-01-01 08:48:53 +00:00
|
|
|
@MainActor
|
2024-06-12 05:42:02 +00:00
|
|
|
func testRouterThreadsURL() {
|
|
|
|
let router = RouterPath()
|
|
|
|
let url = URL(string: "https://www.threads.net/@dimillian")!
|
|
|
|
_ = router.handle(url: url)
|
|
|
|
#expect(router.path.isEmpty)
|
|
|
|
}
|
2024-02-14 11:48:14 +00:00
|
|
|
|
2024-06-12 05:42:02 +00:00
|
|
|
@Test
|
|
|
|
@MainActor
|
|
|
|
func testRouterTagsURL() {
|
|
|
|
let router = RouterPath()
|
|
|
|
let url = URL(string: "https://mastodon.social/tags/test")!
|
|
|
|
_ = router.handle(url: url)
|
|
|
|
#expect(router.path.first == .hashTag(tag: "test", account: nil))
|
|
|
|
}
|
2024-02-14 11:48:14 +00:00
|
|
|
|
2024-06-12 05:42:02 +00:00
|
|
|
@Test
|
|
|
|
@MainActor
|
|
|
|
func testRouterLocalStatusURL() {
|
|
|
|
let router = RouterPath()
|
|
|
|
let client = Client(server: "mastodon.social",
|
|
|
|
oauthToken: .init(accessToken: "", tokenType: "", scope: "", createdAt: 0))
|
|
|
|
client.addConnections(["mastodon.social"])
|
|
|
|
router.client = client
|
|
|
|
let url = URL(string: "https://mastodon.social/status/1010384")!
|
|
|
|
_ = router.handle(url: url)
|
|
|
|
#expect(router.path.first == .statusDetail(id: "1010384"))
|
|
|
|
}
|
2024-02-14 11:48:14 +00:00
|
|
|
|
2024-06-12 05:42:02 +00:00
|
|
|
@Test
|
|
|
|
@MainActor
|
|
|
|
func testRouterRemoteStatusURL() {
|
|
|
|
let router = RouterPath()
|
|
|
|
let client = Client(server: "mastodon.social",
|
|
|
|
oauthToken: .init(accessToken: "", tokenType: "", scope: "", createdAt: 0))
|
|
|
|
client.addConnections(["mastodon.social", "mastodon.online"])
|
|
|
|
router.client = client
|
|
|
|
let url = URL(string: "https://mastodon.online/status/1010384")!
|
|
|
|
_ = router.handle(url: url)
|
|
|
|
#expect(router.path.first == .remoteStatusDetail(url: url))
|
|
|
|
}
|
2024-02-14 11:48:14 +00:00
|
|
|
|
2024-06-12 05:42:02 +00:00
|
|
|
@Test
|
|
|
|
@MainActor
|
|
|
|
func testRouteRandomURL() {
|
|
|
|
let router = RouterPath()
|
|
|
|
let url = URL(string: "https://theweb.com/test/test/one")!
|
|
|
|
_ = router.handle(url: url)
|
|
|
|
#expect(router.path.isEmpty)
|
2024-01-01 08:48:53 +00:00
|
|
|
}
|