@@ -6,13 +6,12 @@ import XCTest
6
6
@testable import VoiceMemos
7
7
8
8
class VoiceMemosTests : XCTestCase {
9
- let mainRunLoop = RunLoop . test
9
+ let mainRunLoop = TestScheduler ( )
10
10
11
11
func testRecordMemoHappyPath( ) {
12
12
let audioRecorderSubject = Signal <
13
13
AudioRecorderClient . Action , AudioRecorderClient . Failure
14
14
> . pipe ( )
15
- let scheduler = TestScheduler ( )
16
15
17
16
var environment = VoiceMemosEnvironment . failing
18
17
environment. audioRecorder. currentTime = { _ in Effect ( value: 2.5 ) }
@@ -26,7 +25,7 @@ class VoiceMemosTests: XCTestCase {
26
25
audioRecorderSubject. input. sendCompleted ( )
27
26
}
28
27
}
29
- environment. mainQueue = scheduler
28
+ environment. mainRunLoop = mainRunLoop
30
29
environment. temporaryDirectory = { URL ( fileURLWithPath: " /tmp " ) }
31
30
environment. uuid = { UUID ( uuidString: " DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF " ) ! }
32
31
@@ -41,7 +40,7 @@ class VoiceMemosTests: XCTestCase {
41
40
store. receive ( . recordPermissionResponse( true ) ) {
42
41
$0. audioRecorderPermission = . allowed
43
42
$0. currentRecording = . init(
44
- date: Date ( timeIntervalSince1970 : 0 ) ,
43
+ date: Date ( timeIntervalSinceReferenceDate : 0 ) ,
45
44
mode: . recording,
46
45
url: URL ( string: " file:///tmp/DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF.m4a " ) !
47
46
)
@@ -65,7 +64,7 @@ class VoiceMemosTests: XCTestCase {
65
64
$0. currentRecording = nil
66
65
$0. voiceMemos = [
67
66
VoiceMemo (
68
- date: Date ( timeIntervalSince1970 : 0 ) ,
67
+ date: Date ( timeIntervalSinceReferenceDate : 0 ) ,
69
68
duration: 2.5 ,
70
69
mode: . notPlaying,
71
70
title: " " ,
@@ -142,13 +141,12 @@ class VoiceMemosTests: XCTestCase {
142
141
}
143
142
144
143
func testPlayMemoHappyPath( ) {
145
- let scheduler = TestScheduler ( )
146
144
var environment = VoiceMemosEnvironment . failing
147
145
environment. audioPlayer. play = { _, _ in
148
146
Effect ( value: . didFinishPlaying( successfully: true ) )
149
- . delay ( 1.1 , on: scheduler )
147
+ . delay ( 1.1 , on: self . mainRunLoop )
150
148
}
151
- environment. mainQueue = scheduler
149
+ environment. mainRunLoop = mainRunLoop
152
150
153
151
let url = URL ( string: " https://www.pointfree.co/functions " ) !
154
152
let store = TestStore (
@@ -170,15 +168,15 @@ class VoiceMemosTests: XCTestCase {
170
168
store. send ( . voiceMemo( id: url, action: . playButtonTapped) ) {
171
169
$0. voiceMemos [ id: url] ? . mode = VoiceMemo . Mode. playing ( progress: 0 )
172
170
}
173
- self . mainRunLoop. advance ( by: 0.5 )
171
+ mainRunLoop. advance ( by: 0.5 )
174
172
store. receive ( VoiceMemosAction . voiceMemo ( id: url, action: VoiceMemoAction . timerUpdated ( 0.5 ) ) ) {
175
173
$0. voiceMemos [ id: url] ? . mode = . playing( progress: 0.5 )
176
174
}
177
- self . mainRunLoop. advance ( by: 0.5 )
175
+ mainRunLoop. advance ( by: 0.5 )
178
176
store. receive ( VoiceMemosAction . voiceMemo ( id: url, action: VoiceMemoAction . timerUpdated ( 1 ) ) ) {
179
177
$0. voiceMemos [ id: url] ? . mode = . playing( progress: 1 )
180
178
}
181
- scheduler . advance ( by: 0.1 )
179
+ mainRunLoop . advance ( by: 0.1 )
182
180
store. receive (
183
181
. voiceMemo(
184
182
id: url,
0 commit comments