Skip to content

Commit b448d4d

Browse files
committed
test: SettingsFeature 테스트 추가
1 parent 17dff34 commit b448d4d

2 files changed

Lines changed: 438 additions & 0 deletions

File tree

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
//
2+
// SettingsFeatureTestDoubles.swift
3+
// DevLogPresentationTests
4+
//
5+
// Created by opfic on 6/12/26.
6+
//
7+
8+
import Combine
9+
import DevLogCore
10+
import DevLogDomain
11+
12+
final class DeleteAuthUseCaseSpy: DeleteAuthUseCase {
13+
var error: Error?
14+
private(set) var executeCallCount = 0
15+
16+
func execute() async throws {
17+
executeCallCount += 1
18+
19+
if let error {
20+
throw error
21+
}
22+
}
23+
}
24+
25+
final class SignOutUseCaseSpy: SignOutUseCase {
26+
var error: Error?
27+
var shouldSuspend = false
28+
private(set) var executeCallCount = 0
29+
private var continuation: CheckedContinuation<Void, Never>?
30+
private var shouldResume = false
31+
32+
func execute() async throws {
33+
executeCallCount += 1
34+
35+
if shouldSuspend {
36+
await withCheckedContinuation { continuation in
37+
if shouldResume {
38+
shouldResume = false
39+
continuation.resume()
40+
} else {
41+
self.continuation = continuation
42+
}
43+
}
44+
}
45+
46+
if let error {
47+
throw error
48+
}
49+
}
50+
51+
func resume() {
52+
guard let continuation else {
53+
shouldResume = true
54+
return
55+
}
56+
57+
self.continuation = nil
58+
continuation.resume()
59+
}
60+
}
61+
62+
final class ObserveSystemThemeUseCaseSpy: ObserveSystemThemeUseCase {
63+
let subject = PassthroughSubject<SystemTheme, Never>()
64+
65+
func observe() -> AnyPublisher<SystemTheme, Never> {
66+
subject.eraseToAnyPublisher()
67+
}
68+
}
69+
70+
final class UpdateSystemThemeUseCaseSpy: UpdateSystemThemeUseCase {
71+
private(set) var themes = [SystemTheme]()
72+
73+
func execute(_ theme: SystemTheme) {
74+
themes.append(theme)
75+
}
76+
}
77+
78+
final class FetchWebPageImageDirSizeUseCaseSpy: FetchWebPageImageDirSizeUseCase {
79+
var dirSize: Int64
80+
private(set) var executeCallCount = 0
81+
82+
init(dirSize: Int64 = 0) {
83+
self.dirSize = dirSize
84+
}
85+
86+
func execute() async -> Int64 {
87+
executeCallCount += 1
88+
return dirSize
89+
}
90+
}
91+
92+
final class ClearWebPageImageDirectoryUseCaseSpy: ClearWebPageImageDirectoryUseCase {
93+
var error: Error?
94+
private(set) var executeCallCount = 0
95+
96+
func execute() async throws {
97+
executeCallCount += 1
98+
99+
if let error {
100+
throw error
101+
}
102+
}
103+
}
104+
105+
enum SettingsTestError: Error {
106+
case failure
107+
}

0 commit comments

Comments
 (0)