From 3381c16acd5bfceea9c9b2028fc2be9ff47ec99d Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Wed, 29 Jan 2025 16:42:31 +0300 Subject: [PATCH] chore: trying to fix unit tests --- .../Container/CourseDownloadHelperTests.swift | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift b/Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift index 98abc77e0..f097482d4 100644 --- a/Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift +++ b/Course/CourseTests/Presentation/Container/CourseDownloadHelperTests.swift @@ -12,6 +12,7 @@ import XCTest @testable import Course +@MainActor final class CourseDownloadHelperTests: XCTestCase { var downloadManagerMock: DownloadManagerProtocolMock! var helper: CourseDownloadHelper! @@ -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: "", @@ -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 = [] } @@ -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) @@ -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) @@ -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) Verify(downloadManagerMock, 9, .getDownloadTasks()) Verify(downloadManagerMock, 9, .getCurrentDownloadTask()) XCTAssertEqual(receivedCount, 9) @@ -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)