Skip to content

Commit fe66472

Browse files
committed
Convert SearchShowModelTests
1 parent 0ebaab3 commit fe66472

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

Tests/AppTests/SearchShowModelTests.swift

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
@testable import App
1616

17-
import XCTVapor
17+
import Testing
1818

19-
class SearchShowModelTests: XCTestCase {
2019

21-
func test_SearchShow_Model_init() throws {
20+
@Suite struct SearchShowModelTests {
21+
22+
@Test func SearchShow_Model_init() throws {
2223
let results: [Search.Result] = .mock()
2324

2425
// MUT
@@ -31,20 +32,20 @@ class SearchShowModelTests: XCTestCase {
3132
],
3233
results: results), weightedKeywords: [])
3334

34-
XCTAssertEqual(model.page, 1)
35-
XCTAssertEqual(model.query, "query key:value")
36-
XCTAssertEqual(model.term, "query")
35+
#expect(model.page == 1)
36+
#expect(model.query == "query key:value")
37+
#expect(model.term == "query")
3738

38-
XCTAssertEqual(model.filters.count, 1)
39-
XCTAssertEqual(model.filters[0].key, "key")
40-
XCTAssertEqual(model.filters[0].operator, "is")
41-
XCTAssertEqual(model.filters[0].value, "value")
39+
#expect(model.filters.count == 1)
40+
#expect(model.filters[0].key == "key")
41+
#expect(model.filters[0].operator == "is")
42+
#expect(model.filters[0].value == "value")
4243

43-
XCTAssertEqual(model.response.hasMoreResults, false)
44-
XCTAssertEqual(model.response.results.count, 10)
44+
#expect(model.response.hasMoreResults == false)
45+
#expect(model.response.results.count == 10)
4546
}
4647

47-
func test_SearchShow_Model_init_sanitized() throws {
48+
@Test func SearchShow_Model_init_sanitized() throws {
4849
do {
4950
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/1409
5051
let query = #"'>"></script><svg/onload=confirm(42)>"#
@@ -55,13 +56,11 @@ class SearchShowModelTests: XCTestCase {
5556
weightedKeywords: []
5657
)
5758

58-
XCTAssertEqual(
59-
model.query,
60-
"&apos;&gt;&quot;&gt;&lt;/script&gt;&lt;svg/onload=confirm(42)&gt;"
59+
#expect(
60+
model.query == "&apos;&gt;&quot;&gt;&lt;/script&gt;&lt;svg/onload=confirm(42)&gt;"
6161
)
62-
XCTAssertEqual(
63-
model.term,
64-
"&apos;&gt;&quot;&gt;&lt;/script&gt;&lt;svg/onload=confirm(42)&gt;"
62+
#expect(
63+
model.term == "&apos;&gt;&quot;&gt;&lt;/script&gt;&lt;svg/onload=confirm(42)&gt;"
6564
)
6665
}
6766
do {
@@ -74,12 +73,12 @@ class SearchShowModelTests: XCTestCase {
7473
weightedKeywords: []
7574
)
7675

77-
XCTAssertEqual(model.query, "test&apos;two")
78-
XCTAssertEqual(model.term, "test&apos;two")
76+
#expect(model.query == "test&apos;two")
77+
#expect(model.term == "test&apos;two")
7978
}
8079
}
8180

82-
func test_SearchShow_Model_authorResults() throws {
81+
@Test func SearchShow_Model_authorResults() throws {
8382
let results: [Search.Result] = .mock()
8483
let model = SearchShow.Model(query: .init(query: "query", page: 1),
8584
response: .init(hasMoreResults: false,
@@ -91,10 +90,10 @@ class SearchShowModelTests: XCTestCase {
9190
// MUT
9291
let authorResult = model.authorResults.first!
9392

94-
XCTAssertEqual(authorResult.name, "Apple")
93+
#expect(authorResult.name == "Apple")
9594
}
9695

97-
func test_SearchShow_Model_keywordResults() throws {
96+
@Test func SearchShow_Model_keywordResults() throws {
9897
let results: [Search.Result] = .mock()
9998
let model = SearchShow.Model(query: .init(query: "query", page:1 ),
10099
response: .init(hasMoreResults: false,
@@ -106,10 +105,10 @@ class SearchShowModelTests: XCTestCase {
106105
// MUT
107106
let keywordResult = model.keywordResults.first!
108107

109-
XCTAssertEqual(keywordResult.keyword, "keyword1")
108+
#expect(keywordResult.keyword == "keyword1")
110109
}
111110

112-
func test_SearchShow_Model_packageResults() throws {
111+
@Test func SearchShow_Model_packageResults() throws {
113112
let results: [Search.Result] = .mock()
114113
let model = SearchShow.Model(query: .init(query: "query", page: 1),
115114
response: .init(hasMoreResults: false,
@@ -121,15 +120,15 @@ class SearchShowModelTests: XCTestCase {
121120
// MUT
122121
let packageResult = model.packageResults.first!
123122

124-
XCTAssertEqual(packageResult.packageId, .id1)
125-
XCTAssertEqual(packageResult.packageName, "Package One")
126-
XCTAssertEqual(packageResult.packageURL, "https://example.com/package/one")
127-
XCTAssertEqual(packageResult.repositoryName, "one")
128-
XCTAssertEqual(packageResult.repositoryOwner, "package")
129-
XCTAssertEqual(packageResult.summary, "This is a package filled with ones.")
123+
#expect(packageResult.packageId == .id1)
124+
#expect(packageResult.packageName == "Package One")
125+
#expect(packageResult.packageURL == "https://example.com/package/one")
126+
#expect(packageResult.repositoryName == "one")
127+
#expect(packageResult.repositoryOwner == "package")
128+
#expect(packageResult.summary == "This is a package filled with ones.")
130129
}
131130

132-
func test_SearchShow_Model_matchingKeywords() throws {
131+
@Test func SearchShow_Model_matchingKeywords() throws {
133132
let results: [Search.Result] = .mock()
134133
let model = SearchShow.Model(query: .init(query: "query", page: 1),
135134
response: .init(hasMoreResults: false,
@@ -141,7 +140,7 @@ class SearchShowModelTests: XCTestCase {
141140
// MUT
142141
let matchingKeywords = model.matchingKeywords(packageKeywords: ["keyword2", "keyword4", "keyword5"])
143142

144-
XCTAssertEqual(matchingKeywords, ["keyword2", "keyword4"])
143+
#expect(matchingKeywords == ["keyword2", "keyword4"])
145144
}
146145

147146
}

0 commit comments

Comments
 (0)