Skip to content

Commit 3f37406

Browse files
committed
Convert BlogActionsModelTests
1 parent 9757990 commit 3f37406

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

Tests/AppTests/BlogActionsModelTests.swift

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import XCTest
15+
import Foundation
1616

1717
@testable import App
1818

1919
import Dependencies
20+
import Testing
2021

2122

22-
class BlogActionsModelTests: AppTestCase {
23+
@Suite struct BlogActionsModelTests {
2324

24-
func test_init_loadSummaries() async throws {
25+
@Test func init_loadSummaries() async throws {
2526
try withDependencies {
2627
$0.fileManager.contents = { @Sendable _ in
2728
"""
@@ -45,19 +46,21 @@ class BlogActionsModelTests: AppTestCase {
4546
// MUT
4647
let summaries = try BlogActions.Model().summaries
4748

48-
XCTAssertEqual(summaries.count, 2)
49-
XCTAssertEqual(summaries.map(\.slug), ["post-2", "post-1"])
50-
XCTAssertEqual(summaries.map(\.published), [false, true])
49+
#expect(summaries.count == 2)
50+
#expect(summaries.map(\.slug) == ["post-2", "post-1"])
51+
#expect(summaries.map(\.published) == [false, true])
5152

52-
let firstSummary = try XCTUnwrap(summaries).first
53+
let firstSummary = try #require(summaries).first
5354

5455
// Note that we are testing that the first item in this list is the *last* item in the source YAML
5556
// as the init should reverse the order of posts so that they display in reverse chronological order
56-
XCTAssertEqual(firstSummary, BlogActions.Model.PostSummary(slug: "post-2",
57-
title: "Blog post title two",
58-
summary: "Summary of blog post two",
59-
publishedAt: DateFormatter.yearMonthDayDateFormatter.date(from: "2024-01-02")!,
60-
published: false))
57+
#expect(firstSummary == BlogActions.Model.PostSummary(
58+
slug: "post-2",
59+
title: "Blog post title two",
60+
summary: "Summary of blog post two",
61+
publishedAt: DateFormatter.yearMonthDayDateFormatter.date(from: "2024-01-02")!,
62+
published: false)
63+
)
6164
}
6265

6366
try withDependencies { // Ensure prod shows only published summaries
@@ -67,13 +70,13 @@ class BlogActionsModelTests: AppTestCase {
6770
let summaries = try BlogActions.Model().summaries
6871

6972
// validate
70-
XCTAssertEqual(summaries.map(\.slug), ["post-1"])
71-
XCTAssertEqual(summaries.map(\.published), [true])
73+
#expect(summaries.map(\.slug) == ["post-1"])
74+
#expect(summaries.map(\.published) == [true])
7275
}
7376
}
7477
}
7578

76-
func test_postSummary_postMarkdown_load() async throws {
79+
@Test func postSummary_postMarkdown_load() async throws {
7780
withDependencies {
7881
$0.fileManager.contents = { @Sendable _ in
7982
"""
@@ -86,21 +89,21 @@ class BlogActionsModelTests: AppTestCase {
8689
// MUT
8790
let markdown = summary.postMarkdown
8891

89-
XCTAssertEqual(markdown, "<p>This is some Markdown with <a href=\"https://example.com\">a link</a> and some <em>formatting</em>.</p>")
92+
#expect(markdown == "<p>This is some Markdown with <a href=\"https://example.com\">a link</a> and some <em>formatting</em>.</p>")
9093
}
9194
}
9295

93-
func test_decode_posts_yml() async throws {
96+
@Test func decode_posts_yml() async throws {
9497
// setup
9598
try withDependencies {
9699
$0.fileManager.contents = FileManagerClient.liveValue.contents(atPath:)
97100
$0.timeZone = .utc
98101
} operation: {
99102
// MUT
100103
let summaries = try BlogActions.Model.allSummaries()
101-
104+
102105
// validate
103-
XCTAssert(summaries.count > 0)
106+
#expect(summaries.count > 0)
104107
}
105108
}
106109

0 commit comments

Comments
 (0)