Files
todos/UnitTests/Tests/View Models/ContentViewModelTests.swift
T
javier bbd7ec264b Todo repository protocol (#8)
This PR contains the work done to decouple the direct use of the `ModelContext` from `SwiftData` from the view model that uses it. In addition, the project transitioned to use Swift 6 and strict concurrency which brought some issues with the unit tests, so they were amended as well.

Reviewed-on: rock-n-code/todos-app#8
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
2026-02-11 18:22:26 +00:00

36 lines
695 B
Swift

import Testing
@testable import Todos
@MainActor
@Suite("ContentView view model tests")
struct ContentViewModelTests {
// MARK: Initialization Tests
@Test("View model initializes with default values")
func initialization() {
// GIVEN
// WHEN
let viewModel = ContentView.ViewModel()
// THEN
#expect(viewModel.newTaskShown == false)
}
// MARK: - Functions Tests
@Test("showNewTask sets showNewTaskView to true")
func newTaskShown() {
// GIVEN
let viewModel = ContentView.ViewModel()
// WHEN
viewModel.showNewTask()
// THEN
#expect(viewModel.newTaskShown == true)
}
}