mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add deferred spinner for voice messages (#2018)
* Add delayedLoaderPlaybackState * Add more tests * Fix Xcode 14 build error * Refactor delayedLoaderPlaybackState -> playerButtonPlaybackState * Fix runtime issue
This commit is contained in:
@@ -69,6 +69,46 @@ class AudioPlayerStateTests: XCTestCase {
|
||||
XCTAssertFalse(audioPlayerState.showProgressIndicator)
|
||||
}
|
||||
|
||||
func testDelayedState() async throws {
|
||||
audioPlayerState.attachAudioPlayer(audioPlayerMock)
|
||||
|
||||
XCTAssert(audioPlayerState.isAttached)
|
||||
XCTAssertEqual(audioPlayerState.playbackState, .loading)
|
||||
XCTAssertEqual(audioPlayerState.playerButtonPlaybackState, .stopped)
|
||||
|
||||
let deferred = deferFulfillment(audioPlayerState.$playerButtonPlaybackState) { output in
|
||||
switch output {
|
||||
case .loading:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
try await deferred.fulfill()
|
||||
|
||||
XCTAssertEqual(audioPlayerState.playerButtonPlaybackState, .loading)
|
||||
}
|
||||
|
||||
func testOtherActionsAreNotDelayed() async throws {
|
||||
audioPlayerState.attachAudioPlayer(audioPlayerMock)
|
||||
XCTAssertEqual(audioPlayerState.playbackState, .loading)
|
||||
XCTAssertEqual(audioPlayerState.playerButtonPlaybackState, .stopped)
|
||||
|
||||
let deferred = deferFulfillment(audioPlayerState.$playerButtonPlaybackState) { output in
|
||||
switch output {
|
||||
case .playing:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
audioPlayerActionsSubject.send(.didStartPlaying)
|
||||
try await deferred.fulfill()
|
||||
XCTAssertEqual(audioPlayerState.playbackState, .playing)
|
||||
XCTAssertEqual(audioPlayerState.playerButtonPlaybackState, .playing)
|
||||
}
|
||||
|
||||
func testReportError() async throws {
|
||||
XCTAssertEqual(audioPlayerState.playbackState, .stopped)
|
||||
audioPlayerState.reportError(AudioPlayerError.genericError)
|
||||
|
||||
Reference in New Issue
Block a user