-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLessonRepositoryTests.swift
More file actions
34 lines (30 loc) · 1.13 KB
/
Copy pathLessonRepositoryTests.swift
File metadata and controls
34 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Foundation
import Testing
@testable import SwiftAtlas
struct LessonRepositoryTests {
@Test
func mapsRemotePayloadsIntoLessonGroups() async throws {
let encoder = JSONEncoder()
let payloads: [String: Data] = [
"/posts": try encoder.encode([
PostDTO(
userId: 1, id: 1, title: "mvvm foundations",
body: "Map transport models into domain language."),
PostDTO(
userId: 1, id: 2, title: "cache policies", body: "Cache first keeps first render fast."),
]),
"/users": try encoder.encode([
UserDTO(
id: 1, name: "Ava Metrics", username: "Ava", email: "ava@example.com",
company: .init(
name: "Architecture", catchPhrase: "Design stable boundaries", bs: "teaching mentor"))
]),
]
let repository = DefaultLessonRepository(
httpClient: FakeHTTPClient(payloads: payloads), cacheStore: InMemoryCacheStore())
let groups = try await repository.fetchLessonGroups(policy: .remoteOnly)
#expect(groups.count == 1)
#expect(groups.first?.title == "Architecture")
#expect(groups.first?.lessons.count == 2)
}
}