Implemented the TodoGroup enumeration in the app target.
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import Testing
|
||||
|
||||
@testable import Todos
|
||||
|
||||
@Suite("TodoGroup enumeration tests")
|
||||
struct TodoGroupTests {
|
||||
|
||||
// MARK: Computed tests
|
||||
|
||||
@Test(
|
||||
"group color match expected values",
|
||||
arguments: zip(
|
||||
TodoGroup.allCases,
|
||||
[Color.blue, .green, .red, .gray]
|
||||
)
|
||||
)
|
||||
func color(
|
||||
for group: TodoGroup,
|
||||
expects expectation: Color
|
||||
) {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let color = group.color
|
||||
|
||||
// THEN
|
||||
#expect(color == expectation)
|
||||
}
|
||||
|
||||
@Test(
|
||||
"group icon names match expected values",
|
||||
arguments: zip(
|
||||
TodoGroup.allCases,
|
||||
["calendar.badge.clock", "calendar", "calendar.badge.exclamationmark", "checkmark.circle.fill"]
|
||||
)
|
||||
)
|
||||
func iconName(
|
||||
for group: TodoGroup,
|
||||
expects expectation: String
|
||||
) {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let iconName = group.iconName
|
||||
|
||||
// THEN
|
||||
#expect(iconName == expectation)
|
||||
}
|
||||
|
||||
@Test(
|
||||
"group titles match expected values",
|
||||
arguments: zip(
|
||||
TodoGroup.allCases,
|
||||
["today", "upcoming", "overdue", "completed"]
|
||||
)
|
||||
)
|
||||
func title(
|
||||
for group: TodoGroup,
|
||||
expects expectation: String
|
||||
) {
|
||||
// GIVEN
|
||||
let key = "enumeration.todo-group.title." + expectation
|
||||
|
||||
// WHEN
|
||||
let title = group.title
|
||||
|
||||
// THEN
|
||||
#expect(title == .init(key))
|
||||
}
|
||||
|
||||
// MARK: Case Iteration Tests
|
||||
|
||||
@Test("all cases contains all cases, in correct order")
|
||||
func allCases() {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let allCases = TodoGroup.allCases
|
||||
|
||||
// THEN
|
||||
#expect(allCases.count == 4)
|
||||
#expect(allCases[0] == .today)
|
||||
#expect(allCases[1] == .upcoming)
|
||||
#expect(allCases[2] == .overdue)
|
||||
#expect(allCases[3] == .completed)
|
||||
}
|
||||
|
||||
// MARK: Identifiable Tests
|
||||
|
||||
@Test("id returns an identity of a case", arguments: TodoGroup.allCases)
|
||||
func id(for group: TodoGroup) {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let id = group.id
|
||||
|
||||
// THEN
|
||||
#expect(id == group)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user