Updated the ContentView view in the app target to support navigation split view and to show floating new task button on both sidebar and details views when required.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import SwiftUI
|
||||
import Testing
|
||||
|
||||
@testable import Todos
|
||||
@@ -16,11 +17,37 @@ struct ContentViewModelTests {
|
||||
|
||||
// THEN
|
||||
#expect(viewModel.newTaskShown == false)
|
||||
#expect(viewModel.group == nil)
|
||||
}
|
||||
|
||||
// MARK: - Computed Property Tests
|
||||
|
||||
@Test(
|
||||
"showNewTaskButtonInDetails returns expected value for every group",
|
||||
arguments: zip(
|
||||
[TodoGroup.today, .upcoming, .overdue, .completed, nil],
|
||||
[true, true, true, false, false]
|
||||
)
|
||||
)
|
||||
func showNewTaskButtonInDetails(
|
||||
for group: TodoGroup?,
|
||||
expects expectation: Bool
|
||||
) {
|
||||
// GIVEN
|
||||
let viewModel = ContentView.ViewModel()
|
||||
|
||||
viewModel.group = group
|
||||
|
||||
// WHEN
|
||||
let shouldNewTaskButton = viewModel.showNewTaskButtonInDetails
|
||||
|
||||
// THEN
|
||||
#expect(shouldNewTaskButton == expectation)
|
||||
}
|
||||
|
||||
// MARK: - Functions Tests
|
||||
|
||||
@Test("showNewTask sets showNewTaskView to true")
|
||||
@Test("showNewTask sets newTaskShown to true")
|
||||
func newTaskShown() {
|
||||
// GIVEN
|
||||
let viewModel = ContentView.ViewModel()
|
||||
@@ -32,4 +59,25 @@ struct ContentViewModelTests {
|
||||
#expect(viewModel.newTaskShown == true)
|
||||
}
|
||||
|
||||
@Test(
|
||||
"showNewTaskButtonInSidebar returns expected value for every horizontal size class",
|
||||
arguments: zip(
|
||||
[UserInterfaceSizeClass.compact, .regular, nil],
|
||||
[true, false, false]
|
||||
)
|
||||
)
|
||||
func showNewTaskButtonInSidebar(
|
||||
for horizontalSizeClass: UserInterfaceSizeClass?,
|
||||
expects expectation: Bool
|
||||
) {
|
||||
// GIVEN
|
||||
let viewModel = ContentView.ViewModel()
|
||||
|
||||
// WHEN
|
||||
let shouldNewTaskButton = viewModel.showNewTaskButtonInSidebar(when: horizontalSizeClass)
|
||||
|
||||
// THEN
|
||||
#expect(shouldNewTaskButton == expectation)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user