Skip to content

Commit

Permalink
test: add AllCoursesViewModel, PrimaryCoursesViewModel, DatesAndCalen…
Browse files Browse the repository at this point in the history
…darViewModel, CalendarManager tests
  • Loading branch information
IvanStepanok committed Oct 31, 2024
1 parent c4fcc19 commit 0bcb55d
Show file tree
Hide file tree
Showing 21 changed files with 9,765 additions and 2,247 deletions.
509 changes: 458 additions & 51 deletions Authorization/AuthorizationTests/AuthorizationMock.generated.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ final class SignInViewModelTests: XCTestCase {
)
let user = User(id: 1, username: "username", email: "[email protected]", name: "Name", userAvatar: "")

Given(interactor, .ssoLogin(title: .any, willReturn: user))
Given(interactor, .login(ssoToken: .any, willReturn: user))

await viewModel.ssoLogin(title: "Riyadah")

Verify(interactor, 1, .ssoLogin(title: .any))
Verify(interactor, 1, .login(ssoToken: .any))
Verify(router, 1, .showMainOrWhatsNewScreen(sourceScreen: .any))

XCTAssertEqual(viewModel.errorMessage, nil)
Expand Down
1 change: 1 addition & 0 deletions Core/Core/Configuration/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation

//sourcery: AutoMockable
public protocol ConfigProtocol {
var baseURL: URL { get }
var baseSSOURL: URL { get }
Expand Down
8 changes: 8 additions & 0 deletions Core/Core/Domain/Model/CourseForSync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ extension DataLayer.EnrollmentsStatus {
}
}

extension CourseForSync: Equatable {
public static func == (lhs: CourseForSync, rhs: CourseForSync) -> Bool {
return lhs.courseID == rhs.courseID &&
lhs.name == rhs.name &&
lhs.synced == rhs.synced &&
lhs.recentlyActive == rhs.recentlyActive
}
}
1 change: 1 addition & 0 deletions Core/Core/View/Base/CalendarManagerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation

//sourcery: AutoMockable
public protocol CalendarManagerProtocol {
func createCalendarIfNeeded()
func filterCoursesBySelected(fetchedCourses: [CourseForSync]) async -> [CourseForSync]
Expand Down
893 changes: 893 additions & 0 deletions Core/CoreTests/CoreMock.generated.swift

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Core/CoreTests/DownloadManager/DownloadManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ final class DownloadManagerTests: XCTestCase {
// When
try await downloadManager.resumeDownloading()

// Wait a bit for async operations to complete
try? await Task.sleep(nanoseconds: 100_000_000)

// Then
Verify(persistence, 2, .nextBlockForDownloading())
XCTAssertEqual(downloadManager.currentDownloadTask?.id, mockTask.id)
Expand Down
893 changes: 893 additions & 0 deletions Course/CourseTests/CourseMock.generated.swift

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Dashboard/Dashboard.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
214DA1AADABC7BF4FB8EA1D7 /* Pods_App_Dashboard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B008B2F0762EF35CADE3DD4 /* Pods_App_Dashboard.framework */; };
97E7DF0B2B7A3EAF00A2A09B /* CourseEnrollmentsMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E7DF0A2B7A3EAF00A2A09B /* CourseEnrollmentsMock.swift */; };
9AD4A6A1AAF97092CF457FE2 /* Pods_App_Dashboard_DashboardTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22905947A936093AD23D4CF8 /* Pods_App_Dashboard_DashboardTests.framework */; };
CE1735062CD2552A00F9606A /* PrimaryCourseDashboardViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1735052CD2552A00F9606A /* PrimaryCourseDashboardViewModelTests.swift */; };
CE17350A2CD26CB500F9606A /* AllCoursesViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1735092CD26CB500F9606A /* AllCoursesViewModelTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -91,6 +93,8 @@
97E7DF0A2B7A3EAF00A2A09B /* CourseEnrollmentsMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseEnrollmentsMock.swift; sourceTree = "<group>"; };
BBABB135366FFB1DAEFA0D16 /* Pods-App-Dashboard-DashboardTests.debugprod.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Dashboard-DashboardTests.debugprod.xcconfig"; path = "Target Support Files/Pods-App-Dashboard-DashboardTests/Pods-App-Dashboard-DashboardTests.debugprod.xcconfig"; sourceTree = "<group>"; };
CCF4C665AD91B6B96F6A11DF /* Pods-App-Dashboard-DashboardTests.debugdev.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Dashboard-DashboardTests.debugdev.xcconfig"; path = "Target Support Files/Pods-App-Dashboard-DashboardTests/Pods-App-Dashboard-DashboardTests.debugdev.xcconfig"; sourceTree = "<group>"; };
CE1735052CD2552A00F9606A /* PrimaryCourseDashboardViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryCourseDashboardViewModelTests.swift; sourceTree = "<group>"; };
CE1735092CD26CB500F9606A /* AllCoursesViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllCoursesViewModelTests.swift; sourceTree = "<group>"; };
DE6CF4F983BBF52606807F9A /* Pods-App-Dashboard-DashboardTests.debugstage.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Dashboard-DashboardTests.debugstage.xcconfig"; path = "Target Support Files/Pods-App-Dashboard-DashboardTests/Pods-App-Dashboard-DashboardTests.debugstage.xcconfig"; sourceTree = "<group>"; };
E36D702D7E3F9A8B3303AD0A /* Pods-App-Dashboard-DashboardTests.releasedev.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Dashboard-DashboardTests.releasedev.xcconfig"; path = "Target Support Files/Pods-App-Dashboard-DashboardTests/Pods-App-Dashboard-DashboardTests.releasedev.xcconfig"; sourceTree = "<group>"; };
E5B672C28C8F9279BB4E5C9B /* Pods-App-Dashboard.releasestage.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App-Dashboard.releasestage.xcconfig"; path = "Target Support Files/Pods-App-Dashboard/Pods-App-Dashboard.releasestage.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -237,6 +241,8 @@
0766DFD2299AD99B00EBEF6A /* Presentation */ = {
isa = PBXGroup;
children = (
CE1735092CD26CB500F9606A /* AllCoursesViewModelTests.swift */,
CE1735052CD2552A00F9606A /* PrimaryCourseDashboardViewModelTests.swift */,
02A9A90A2978194100B55797 /* DashboardViewModelTests.swift */,
);
path = Presentation;
Expand Down Expand Up @@ -483,7 +489,9 @@
buildActionMask = 2147483647;
files = (
02A9A90B2978194100B55797 /* DashboardViewModelTests.swift in Sources */,
CE17350A2CD26CB500F9606A /* AllCoursesViewModelTests.swift in Sources */,
02A9A92929781A4D00B55797 /* DashboardMock.generated.swift in Sources */,
CE1735062CD2552A00F9606A /* PrimaryCourseDashboardViewModelTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Loading

0 comments on commit 0bcb55d

Please sign in to comment.