1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15+ import Foundation
16+
1517@testable import App
1618
1719import SnapshotTesting
1820import SwiftSoup
19- import XCTVapor
21+ import Testing
2022
2123
22- class PackageReadmeModelTests : SnapshotTestCase {
24+ @ Suite struct PackageReadmeModelTests {
2325
24- func test_Element_extractReadme ( ) throws {
26+ @ Test func Element_extractReadme ( ) throws {
2527 let element = Element . extractReadme ( """
2628 <div id= " readme " >
2729 <article>
2830 <p>README content.</p>
2931 </article>
3032 </div>
3133 """ )
32- XCTAssertEqual ( try element? . html ( ) , " <p>README content.</p> " )
34+ #expect ( try element? . html ( ) == " <p>README content.</p> " )
3335 }
3436
35- func test_URL_rewriteRelative ( ) throws {
37+ @ Test func URL_rewriteRelative ( ) throws {
3638 let triple = ( " owner " , " repo " , " main " )
37- XCTAssertEqual ( URL ( string: " https://example.com " ) ? . rewriteRelative ( to: triple, fileType: . raw) , nil )
38- XCTAssertEqual ( URL ( string: " https://example.com/foo " ) ? . rewriteRelative ( to: triple, fileType: . raw) , nil )
39- XCTAssertEqual ( URL ( string: " /foo " ) ? . rewriteRelative ( to: triple, fileType: . raw) ,
40- " https://github.com/owner/repo/raw/main/foo " )
41- XCTAssertEqual ( URL ( string: " /foo " ) ? . rewriteRelative ( to: triple, fileType: . blob) ,
42- " https://github.com/owner/repo/blob/main/foo " )
43- XCTAssertEqual ( URL ( string: " /foo/bar?query " ) ? . rewriteRelative ( to: triple, fileType: . raw) ,
44- " https://github.com/owner/repo/raw/main/foo/bar?query " )
39+ #expect( URL ( string: " https://example.com " ) ? . rewriteRelative ( to: triple, fileType: . raw) == nil )
40+ #expect( URL ( string: " https://example.com/foo " ) ? . rewriteRelative ( to: triple, fileType: . raw) == nil )
41+ #expect( URL ( string: " /foo " ) ? . rewriteRelative ( to: triple, fileType: . raw) == " https://github.com/owner/repo/raw/main/foo " )
42+ #expect( URL ( string: " /foo " ) ? . rewriteRelative ( to: triple, fileType: . blob) == " https://github.com/owner/repo/blob/main/foo " )
43+ #expect( URL ( string: " /foo/bar?query " ) ? . rewriteRelative ( to: triple, fileType: . raw) == " https://github.com/owner/repo/raw/main/foo/bar?query " )
4544 }
4645
47- func test_Element_rewriteRelativeImages ( ) throws {
46+ @ Test func Element_rewriteRelativeImages ( ) throws {
4847 // setup
4948 let element = Element . extractReadme ( """
5049 <div id= " readme " >
@@ -64,11 +63,11 @@ class PackageReadmeModelTests: SnapshotTestCase {
6463 element? . rewriteRelativeImages ( to: ( " owner " , " repo " , " main " ) )
6564
6665 // validate
67- let html = try XCTUnwrap ( try element? . html ( ) )
66+ let html = try #require ( try element? . html ( ) )
6867 assertSnapshot ( of: html, as: . lines)
6968 }
7069
71- func test_Element_rewriteRelativeLinks ( ) throws {
70+ @ Test func Element_rewriteRelativeLinks ( ) throws {
7271 // setup
7372 let element = Element . extractReadme ( """
7473 <div id= " readme " >
@@ -89,26 +88,26 @@ class PackageReadmeModelTests: SnapshotTestCase {
8988 element? . rewriteRelativeLinks ( to: ( " owner " , " repo " , " main " ) )
9089
9190 // validate
92- let html = try XCTUnwrap ( try element? . html ( ) )
91+ let html = try #require ( try element? . html ( ) )
9392 assertSnapshot ( of: html, as: . lines)
9493 }
9594
96- func test_URL_initWithPotentiallyUnencodedPath ( ) throws {
95+ @ Test func URL_initWithPotentiallyUnencodedPath ( ) throws {
9796 // Relative URLs
98- XCTAssertEqual ( try XCTUnwrap ( URL ( withPotentiallyUnencodedPath: " /root/relative/url " ) ) . absoluteString, " /root/relative/url " )
99- XCTAssertEqual ( try XCTUnwrap ( URL ( withPotentiallyUnencodedPath: " relative/url " ) ) . absoluteString, " relative/url " )
100- XCTAssertEqual ( try XCTUnwrap ( URL ( withPotentiallyUnencodedPath: " /encoded%20spaces " ) ) . absoluteString, " /encoded%20spaces " )
101- XCTAssertEqual ( try XCTUnwrap ( URL ( withPotentiallyUnencodedPath: " /unencoded spaces " ) ) . absoluteString, " /unencoded%20spaces " )
102- XCTAssertEqual ( try XCTUnwrap ( URL ( withPotentiallyUnencodedPath: " /multiple%20%7Bencoded%7D " ) ) . absoluteString, " /multiple%20%7Bencoded%7D " )
103- XCTAssertEqual ( try XCTUnwrap ( URL ( withPotentiallyUnencodedPath: " /multiple {unencoded} " ) ) . absoluteString, " /multiple%20%7Bunencoded%7D " )
97+ #expect ( try #require ( URL ( withPotentiallyUnencodedPath: " /root/relative/url " ) ) . absoluteString == " /root/relative/url " )
98+ #expect ( try #require ( URL ( withPotentiallyUnencodedPath: " relative/url " ) ) . absoluteString == " relative/url " )
99+ #expect ( try #require ( URL ( withPotentiallyUnencodedPath: " /encoded%20spaces " ) ) . absoluteString == " /encoded%20spaces " )
100+ #expect ( try #require ( URL ( withPotentiallyUnencodedPath: " /unencoded spaces " ) ) . absoluteString == " /unencoded%20spaces " )
101+ #expect ( try #require ( URL ( withPotentiallyUnencodedPath: " /multiple%20%7Bencoded%7D " ) ) . absoluteString == " /multiple%20%7Bencoded%7D " )
102+ #expect ( try #require ( URL ( withPotentiallyUnencodedPath: " /multiple {unencoded} " ) ) . absoluteString == " /multiple%20%7Bunencoded%7D " )
104103
105104 // Absolute URLs
106- XCTAssertEqual ( try XCTUnwrap ( URL ( withPotentiallyUnencodedPath: " https://full.host/and/path " ) ) . absoluteString, " https://full.host/and/path " )
107- XCTAssertEqual ( try XCTUnwrap ( URL ( withPotentiallyUnencodedPath: " https://full.host/encoded%20spaces " ) ) . absoluteString, " https://full.host/encoded%20spaces " )
108- XCTAssertEqual ( try XCTUnwrap ( URL ( withPotentiallyUnencodedPath: " https://full.host/unencoded spaces " ) ) . absoluteString, " https://full.host/unencoded%20spaces " )
105+ #expect ( try #require ( URL ( withPotentiallyUnencodedPath: " https://full.host/and/path " ) ) . absoluteString == " https://full.host/and/path " )
106+ #expect ( try #require ( URL ( withPotentiallyUnencodedPath: " https://full.host/encoded%20spaces " ) ) . absoluteString == " https://full.host/encoded%20spaces " )
107+ #expect ( try #require ( URL ( withPotentiallyUnencodedPath: " https://full.host/unencoded spaces " ) ) . absoluteString == " https://full.host/unencoded%20spaces " )
109108 }
110109
111- func test_Element_fixInlineAnchors ( ) throws {
110+ @ Test func Element_fixInlineAnchors ( ) throws {
112111 // setup
113112 let element = Element . extractReadme ( """
114113 <div id= " readme " >
@@ -126,11 +125,11 @@ class PackageReadmeModelTests: SnapshotTestCase {
126125 element? . fixInlineAnchors ( )
127126
128127 // validate
129- let html = try XCTUnwrap ( try element? . html ( ) )
128+ let html = try #require ( try element? . html ( ) )
130129 assertSnapshot ( of: html, as: . lines)
131130 }
132131
133- func test_Element_fixProtectedCachedImages ( ) throws {
132+ @ Test func Element_fixProtectedCachedImages ( ) throws {
134133 // setup
135134 let element = Element . extractReadme ( """
136135 <div id= " readme " >
@@ -150,11 +149,11 @@ class PackageReadmeModelTests: SnapshotTestCase {
150149 element? . fixProtectedCachedImages ( )
151150
152151 // validate
153- let html = try XCTUnwrap ( try element? . html ( ) )
152+ let html = try #require ( try element? . html ( ) )
154153 assertSnapshot ( of: html, as: . lines)
155154 }
156155
157- func test_Element_disableTurboOnLinks ( ) throws {
156+ @ Test func Element_disableTurboOnLinks ( ) throws {
158157 // setup
159158 let element = Element . extractReadme ( """
160159 <div id= " readme " >
@@ -172,7 +171,7 @@ class PackageReadmeModelTests: SnapshotTestCase {
172171 element? . disableTurboOnLinks ( )
173172
174173 // validate
175- let html = try XCTUnwrap ( try element? . html ( ) )
174+ let html = try #require ( try element? . html ( ) )
176175 assertSnapshot ( of: html, as: . lines)
177176 }
178177}
0 commit comments