Renamed the RecordingService protocol in the Recording package target as Capturing.
This commit is contained in:
@@ -249,31 +249,31 @@ struct RecordingViewModelTests {
|
||||
|
||||
}
|
||||
|
||||
// MARK: Recorder
|
||||
// MARK: Capturer
|
||||
|
||||
@MainActor
|
||||
@Suite("Recorder")
|
||||
struct Recorder {
|
||||
@Suite("Capturer")
|
||||
struct Capturer {
|
||||
|
||||
@Test func `starts the capture for a new recording`() async throws {
|
||||
let recorder = RecordingServiceMock()
|
||||
let model = Model(recorder: recorder)
|
||||
let capturer = CapturingMock()
|
||||
let model = Model(capturer: capturer)
|
||||
|
||||
model.state = .recording
|
||||
model.updatedState(shouldRestartTimer: true)
|
||||
|
||||
try await Task.sleep(for: .seconds(0.1))
|
||||
|
||||
#expect(recorder.countStart == 1)
|
||||
#expect(recorder.countResume == 0)
|
||||
#expect(capturer.countStart == 1)
|
||||
#expect(capturer.countResume == 0)
|
||||
|
||||
model.state = .notRecording
|
||||
model.updatedState(shouldRestartTimer: false)
|
||||
}
|
||||
|
||||
@Test func `pauses the capture while paused`() async throws {
|
||||
let recorder = RecordingServiceMock()
|
||||
let model = Model(recorder: recorder)
|
||||
let capturer = CapturingMock()
|
||||
let model = Model(capturer: capturer)
|
||||
|
||||
model.state = .recording
|
||||
model.updatedState(shouldRestartTimer: true)
|
||||
@@ -283,12 +283,12 @@ struct RecordingViewModelTests {
|
||||
|
||||
try await Task.sleep(for: .seconds(0.1))
|
||||
|
||||
#expect(recorder.countPause == 1)
|
||||
#expect(capturer.countPause == 1)
|
||||
}
|
||||
|
||||
@Test func `resumes the capture after a pause`() async throws {
|
||||
let recorder = RecordingServiceMock()
|
||||
let model = Model(recorder: recorder)
|
||||
let capturer = CapturingMock()
|
||||
let model = Model(capturer: capturer)
|
||||
|
||||
model.state = .recording
|
||||
model.updatedState(shouldRestartTimer: true)
|
||||
@@ -301,17 +301,17 @@ struct RecordingViewModelTests {
|
||||
|
||||
try await Task.sleep(for: .seconds(0.1))
|
||||
|
||||
#expect(recorder.countStart == 1)
|
||||
#expect(recorder.countResume == 1)
|
||||
#expect(capturer.countStart == 1)
|
||||
#expect(capturer.countResume == 1)
|
||||
|
||||
model.state = .notRecording
|
||||
model.updatedState(shouldRestartTimer: false)
|
||||
}
|
||||
|
||||
@Test func `stops the capture when the input is sent`() async throws {
|
||||
let recorder = RecordingServiceMock()
|
||||
let capturer = CapturingMock()
|
||||
let model = Model(
|
||||
recorder: recorder,
|
||||
capturer: capturer,
|
||||
transcribe: TranscribingMock()
|
||||
)
|
||||
|
||||
@@ -320,15 +320,15 @@ struct RecordingViewModelTests {
|
||||
|
||||
try await Task.sleep(for: .seconds(0.5))
|
||||
|
||||
#expect(recorder.countStop == 1)
|
||||
#expect(capturer.countStop == 1)
|
||||
}
|
||||
|
||||
@Test func `falls back to not recording when the capture fails`() async throws {
|
||||
let recorder = RecordingServiceMock()
|
||||
let capturer = CapturingMock()
|
||||
|
||||
recorder.error = ErrorMock()
|
||||
capturer.error = ErrorMock()
|
||||
|
||||
let model = Model(recorder: recorder)
|
||||
let model = Model(capturer: capturer)
|
||||
|
||||
model.state = .recording
|
||||
model.updatedState(shouldRestartTimer: true)
|
||||
@@ -419,7 +419,7 @@ struct RecordingViewModelTests {
|
||||
|
||||
/// A recording service that counts its invocations and can be configured to fail.
|
||||
@MainActor
|
||||
private final class RecordingServiceMock: RecordingService {
|
||||
private final class CapturingMock: Capturing {
|
||||
|
||||
/// The error the service throws from every method, or `nil` when it should succeed.
|
||||
var error: Error?
|
||||
|
||||
Reference in New Issue
Block a user