Skip to content

Commit

Permalink
🚨Add tests for the Setup feature
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkulman committed Jul 28, 2024
1 parent d0faaa4 commit 8683329
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sources/Features/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ let package = Package(
],
plugins: [.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")]
),
.testTarget(
name: "SetupTests",
dependencies: ["Setup"],
path: "Tests/Features/Setup"
),
.target(
name: "Feed",
dependencies: [
Expand Down
37 changes: 37 additions & 0 deletions sources/Features/Tests/Features/Setup/SetupViewModelTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// File.swift
//
//
// Created by Igor Kulman on 28.07.2024.
//

@testable import Setup
import Foundation
import XCTest

final class SetupViewModelTests: XCTestCase {
func testLoadedData() {
let viewModel = SetupViewModel(settings: .mock(selected: nil), onFinished: {})
XCTAssertFalse(viewModel.sources.isEmpty)
}

func testSelectingASource() {
let viewModel = SetupViewModel(settings: .mock(selected: nil), onFinished: {})
XCTAssertFalse(viewModel.isValid)

viewModel.select(source: .mock)
XCTAssertTrue(viewModel.isValid)
}

func testNavigation() {
var finished: Bool = false
let viewModel = SetupViewModel(settings: .mock(selected: nil)) {
finished = true
}
XCTAssertFalse(finished)

viewModel.select(source: .mock)
viewModel.onNext()
XCTAssertTrue(finished)
}
}
7 changes: 7 additions & 0 deletions sources/SwiftUISampleApp.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"identifier" : "FeedTests",
"name" : "FeedTests"
}
},
{
"target" : {
"containerPath" : "container:Features",
"identifier" : "SetupTests",
"name" : "SetupTests"
}
}
],
"version" : 1
Expand Down

0 comments on commit 8683329

Please sign in to comment.