Skip to content

Commit f696518

Browse files
Fix up tests
1 parent 7e4ed39 commit f696518

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

Tests/AppTests/API+PackageController+GetRoute+ModelTests.swift

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
4242
swiftVersionBuildInfo: nil,
4343
platformBuildInfo: nil,
4444
weightedKeywords: [],
45-
swift6Readiness: nil)
45+
swift6Readiness: nil,
46+
forkedFromURL: nil)
4647

4748
// validate
4849
XCTAssertNotNil(m)
@@ -64,7 +65,9 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
6465
swiftVersionBuildInfo: nil,
6566
platformBuildInfo: nil,
6667
weightedKeywords: [],
67-
swift6Readiness: nil))
68+
swift6Readiness: nil,
69+
forkedFromURL: nil
70+
))
6871

6972
// validate
7073
XCTAssertEqual(model.packageIdentity, "swift-bar")
@@ -86,7 +89,9 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
8689
swiftVersionBuildInfo: nil,
8790
platformBuildInfo: nil,
8891
weightedKeywords: [],
89-
swift6Readiness: nil))
92+
swift6Readiness: nil,
93+
forkedFromURL: nil
94+
))
9095

9196
// validate
9297
XCTAssertEqual(model.documentationTarget, .internal(docVersion: .reference("main"), archive: "archive1"))
@@ -112,7 +117,9 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
112117
swiftVersionBuildInfo: nil,
113118
platformBuildInfo: nil,
114119
weightedKeywords: [],
115-
swift6Readiness: nil))
120+
swift6Readiness: nil,
121+
forkedFromURL: nil
122+
))
116123

117124
// validate
118125
XCTAssertEqual(model.documentationTarget, .external(url: "https://example.com/package/documentation"))
@@ -144,6 +151,13 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
144151
let renderedHistory = model.historyListItem().render(indentedBy: .spaces(2))
145152
assertSnapshot(of: renderedHistory, as: .lines)
146153
}
154+
155+
func test_forked_from() throws {
156+
var model = API.PackageController.GetRoute.Model.mock
157+
model.forkedFromURL = "https://github.com/owner/repository.git"
158+
let renderedForkedFrom = model.forkedListItem().render(indentedBy: .spaces(2))
159+
assertSnapshot(of: renderedForkedFrom, as: .lines)
160+
}
147161

148162
func test_binary_targets() throws {
149163
var model = API.PackageController.GetRoute.Model.mock
@@ -329,6 +343,13 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
329343
.fromSPIManifest("By Author One, Author Two, and more!")
330344
XCTAssertEqual(model.authorsListItem().render(), "<li class=\"authors\">By Author One, Author Two, and more!</li>")
331345
}
346+
347+
func test_forkedFrom_formatting() throws {
348+
var model = API.PackageController.GetRoute.Model.mock
349+
model.forkedFromURL = "https://github.com/owner/repository.git"
350+
let renderedForkedFrom = model.forkedListItem().render()
351+
XCTAssertEqual(renderedForkedFrom, "<li class=\"forked\">Forked from <a href=\"https://github.com/owner/repository.git\">repository</a>.</li>")
352+
}
332353

333354
func test_BuildInfo_init() throws {
334355
// ensure nil propagation when all versions' values are nil

Tests/AppTests/Mocks/API.PackageController.GetRoute.Model+mock.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ extension API.PackageController.GetRoute.Model {
125125
defaultBranchReference: .branch("main"),
126126
releaseReference: .tag(5, 2, 0),
127127
preReleaseReference: .tag(5, 3, 0, "beta.1"),
128-
swift6Readiness: nil
128+
swift6Readiness: nil,
129+
forkedFromURL: nil
129130
)
130131
}
131132
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<li class="forked">Forked from
2+
<a href="https://github.com/owner/repository.git">repository</a>.
3+
</li>

0 commit comments

Comments
 (0)