From dabc987a6a0ec5d7c60387bcc6a38b36bf6b52af Mon Sep 17 00:00:00 2001 From: ThibaultBee <37510686+ThibaultBee@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:20:12 +0200 Subject: [PATCH] fix(test): fix tests on extensions --- .../IntegrationTests/AVPlayerExtensionsTests.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Tests/ApiVideoPlayerTests/IntegrationTests/AVPlayerExtensionsTests.swift b/Tests/ApiVideoPlayerTests/IntegrationTests/AVPlayerExtensionsTests.swift index ff70514e..438fa66c 100644 --- a/Tests/ApiVideoPlayerTests/IntegrationTests/AVPlayerExtensionsTests.swift +++ b/Tests/ApiVideoPlayerTests/IntegrationTests/AVPlayerExtensionsTests.swift @@ -10,12 +10,13 @@ final class AVPlayerExtensions: XCTestCase { _ = observer.readyExpectation let avPlayer = AVPlayer(playerItem: nil) + avPlayer.addObserver(observer, forKeyPath: "status", options: .new, context: nil) avPlayer.replaceCurrentItem(withHls: VideoOptions(videoId: VideoId.validVideoId, videoType: .vod)) - avPlayer.currentItem?.addObserver(observer, forKeyPath: "status", options: .new, context: nil) + avPlayer.play() waitForExpectations(timeout: 10, handler: nil) - avPlayer.currentItem?.removeObserver(observer, forKeyPath: "status") + avPlayer.removeObserver(observer, forKeyPath: "status") } func testValidMP4VideoIdPlay() throws { @@ -23,12 +24,13 @@ final class AVPlayerExtensions: XCTestCase { _ = observer.readyExpectation let avPlayer = AVPlayer(playerItem: nil) + avPlayer.addObserver(observer, forKeyPath: "status", options: .new, context: nil) avPlayer.replaceCurrentItem(withMp4: VideoOptions(videoId: VideoId.validVideoId, videoType: .vod)) - avPlayer.currentItem?.addObserver(observer, forKeyPath: "status", options: .new, context: nil) + avPlayer.play() waitForExpectations(timeout: 10, handler: nil) - avPlayer.currentItem?.removeObserver(observer, forKeyPath: "status") + avPlayer.removeObserver(observer, forKeyPath: "status") } }