Skip to content

Commit

Permalink
chore: trying to fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
forgotvas committed Jan 29, 2025
1 parent 819b480 commit 3381c16
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import XCTest

@testable import Course

@MainActor
final class CourseDownloadHelperTests: XCTestCase {
var downloadManagerMock: DownloadManagerProtocolMock!
var helper: CourseDownloadHelper!
Expand All @@ -21,9 +22,10 @@ final class CourseDownloadHelperTests: XCTestCase {
var sequential: CourseSequential!
var task: DownloadDataTask!
var value: CourseDownloadValue!
var timeout: TimeInterval = 60

override func setUpWithError() throws {
try super.setUpWithError()
override func setUp() {
super.setUp()
downloadManagerMock = DownloadManagerProtocolMock()
block = CourseBlock(
blockId: "",
Expand Down Expand Up @@ -119,8 +121,8 @@ final class CourseDownloadHelperTests: XCTestCase {
helper = CourseDownloadHelper(courseStructure: courseStructure, manager: downloadManagerMock)
}

override func tearDownWithError() throws {
try super.tearDownWithError()
override func tearDown() {
super.tearDown()
cancellables.removeAll()
cancellables = []
}
Expand All @@ -140,7 +142,7 @@ final class CourseDownloadHelperTests: XCTestCase {
helper.refreshValue()

// then
wait(for: [expectation], timeout: 5)
wait(for: [expectation], timeout: timeout)
Verify(downloadManagerMock, .once, .getDownloadTasks())
Verify(downloadManagerMock, .once, .getCurrentDownloadTask())
XCTAssertEqual(valueReceived, value)
Expand All @@ -161,7 +163,7 @@ final class CourseDownloadHelperTests: XCTestCase {
await helper.refreshValue()

// then
await fulfillment(of: [expectation], timeout: 5)
await fulfillment(of: [expectation], timeout: timeout)
Verify(downloadManagerMock, .once, .getDownloadTasks())
Verify(downloadManagerMock, .once, .getCurrentDownloadTask())
XCTAssertEqual(valueReceived, value)
Expand Down Expand Up @@ -212,7 +214,7 @@ final class CourseDownloadHelperTests: XCTestCase {
downloadPublisher.send(.clearedAll) //9
downloadPublisher.send(.progress(task)) //Helper shouldn't send event for that
// then
await fulfillment(of: expectations, timeout: 5)
await fulfillment(of: expectations, timeout: timeout)

Check failure on line 217 in Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift

View workflow job for this annotation

GitHub Actions / Tests

testPublisher_whenReceivedNotProgressEvent_ShouldSendValue, Asynchronous wait failed: Exceeded timeout of 60 seconds, with unfulfilled expectations: "wait for added event", "wait for started event", "wait for paused event", "wait for canceled event", "wait for courseCanceled event", "wait for allCanceled event", "wait for finished event", "wait for deletedFile event", "wait for clearedAll event".

Check failure on line 217 in Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift

View workflow job for this annotation

GitHub Actions / Tests

testPublisher_whenReceivedNotProgressEvent_ShouldSendValue, Asynchronous wait failed: Exceeded timeout of 60 seconds, with unfulfilled expectations: "wait for courseCanceled event", "wait for allCanceled event", "wait for finished event", "wait for deletedFile event", "wait for clearedAll event".
Verify(downloadManagerMock, 9, .getDownloadTasks())

Check failure on line 218 in Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift

View workflow job for this annotation

GitHub Actions / Tests

testPublisher_whenReceivedNotProgressEvent_ShouldSendValue, XCTAssertTrue failed - Expected: exactly 9 invocations of `.getDownloadTasks()`, but was: 0.
Verify(downloadManagerMock, 9, .getCurrentDownloadTask())

Check failure on line 219 in Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift

View workflow job for this annotation

GitHub Actions / Tests

testPublisher_whenReceivedNotProgressEvent_ShouldSendValue, XCTAssertTrue failed - Expected: exactly 9 invocations of `.getCurrentDownloadTask()`, but was: 0.
XCTAssertEqual(receivedCount, 9)

Check failure on line 220 in Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift

View workflow job for this annotation

GitHub Actions / Tests

testPublisher_whenReceivedNotProgressEvent_ShouldSendValue, XCTAssertEqual failed: ("0") is not equal to ("9")

Check failure on line 220 in Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift

View workflow job for this annotation

GitHub Actions / Tests

testPublisher_whenReceivedNotProgressEvent_ShouldSendValue, XCTAssertEqual failed: ("4") is not equal to ("9")
Expand All @@ -236,7 +238,7 @@ final class CourseDownloadHelperTests: XCTestCase {
// when
downloadPublisher.send(.progress(task))
// then
await fulfillment(of: [expectation], timeout: 5)
await fulfillment(of: [expectation], timeout: timeout)
value.currentDownloadTask = task
XCTAssertEqual(helper.value, value)
XCTAssertEqual(valueReceived, task)
Expand Down

0 comments on commit 3381c16

Please sign in to comment.