@@ -12,12 +12,14 @@ struct VoiceMemosTests {
1212 @Test
1313 func recordAndPlayback( ) async throws {
1414 let didFinish = AsyncThrowingStream . makeStream ( of: Bool . self)
15- let clock = TestClock ( )
15+ // NB: We would prefer to use a test clock here, but due to testing async still being unreliable
16+ // in Swift, we will use a real clock and sleep, instead.
17+ // let clock = TestClock()
1618 let store = TestStore ( initialState: VoiceMemos . State ( ) ) {
1719 VoiceMemos ( )
1820 } withDependencies: {
1921 $0. audioPlayer. play = { @Sendable _ in
20- try await clock . sleep ( for: . milliseconds( 2_500 ) )
22+ try await Task . sleep ( for: . milliseconds( 2_500 ) )
2123 return true
2224 }
2325 $0. audioRecorder. currentTime = { 2.5 }
@@ -30,7 +32,7 @@ struct VoiceMemosTests {
3032 didFinish. continuation. finish ( )
3133 }
3234 $0. date = . constant( Date ( timeIntervalSinceReferenceDate: 0 ) )
33- $0. continuousClock = clock
35+ $0. continuousClock = ContinuousClock ( )
3436 $0. temporaryDirectory = { URL ( fileURLWithPath: " /tmp " ) }
3537 $0. uuid = . constant( deadbeefID)
3638 }
@@ -68,7 +70,7 @@ struct VoiceMemosTests {
6870 $0. voiceMemos [ id: deadbeefURL] ? . mode = . playing( progress: 0 )
6971 }
7072 await store. receive ( \. voiceMemos [ id: deadbeefURL] . delegate. playbackStarted)
71- await clock . run ( )
73+ try await Task . sleep ( nanoseconds : 3_000_000_000 )
7274
7375 await store. receive ( \. voiceMemos [ id: deadbeefURL] . timerUpdated) {
7476 $0. voiceMemos [ id: deadbeefURL] ? . mode = . playing( progress: 0.2 )
@@ -82,6 +84,9 @@ struct VoiceMemosTests {
8284 await store. receive ( \. voiceMemos [ id: deadbeefURL] . timerUpdated) {
8385 $0. voiceMemos [ id: deadbeefURL] ? . mode = . playing( progress: 0.8 )
8486 }
87+ await store. receive ( \. voiceMemos [ id: deadbeefURL] . timerUpdated) {
88+ $0. voiceMemos [ id: deadbeefURL] ? . mode = . playing( progress: 1.0 )
89+ }
8590 await store. receive ( \. voiceMemos [ id: deadbeefURL] . audioPlayerClient. success) {
8691 $0. voiceMemos [ id: deadbeefURL] ? . mode = . notPlaying
8792 }
0 commit comments