2026-07-05 13:34:16 +02:00
|
|
|
import Foundation
|
|
|
|
|
import Testing
|
|
|
|
|
|
|
|
|
|
@testable import Notifying
|
|
|
|
|
|
|
|
|
|
@Suite("AppNotification model")
|
|
|
|
|
struct AppNotificationTests {
|
|
|
|
|
|
|
|
|
|
// MARK: Initializers
|
|
|
|
|
|
|
|
|
|
@Suite("Initializers")
|
|
|
|
|
struct Initializers {
|
|
|
|
|
|
|
|
|
|
@Test(arguments: zip(
|
|
|
|
|
[AppNotification.Kind.error, .info, .warning],
|
|
|
|
|
["An error occurred.", "Something happened.", "Something needs attention."]
|
|
|
|
|
))
|
|
|
|
|
func `initializer stores the given kind, message, and symbol`(
|
|
|
|
|
kind: AppNotification.Kind,
|
|
|
|
|
message: String
|
|
|
|
|
) {
|
|
|
|
|
let notification = AppNotification(
|
|
|
|
|
kind: kind,
|
|
|
|
|
message: message,
|
|
|
|
|
symbol: "bell"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#expect(notification.kind == kind)
|
|
|
|
|
#expect(notification.message == message)
|
|
|
|
|
#expect(notification.symbol == "bell")
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 16:21:30 +02:00
|
|
|
@Test
|
|
|
|
|
func `initializer stores the given identifier`() {
|
2026-07-05 13:34:16 +02:00
|
|
|
let id = UUID()
|
|
|
|
|
let notification = AppNotification(
|
|
|
|
|
id: id,
|
|
|
|
|
kind: .info,
|
|
|
|
|
message: "Something happened.",
|
|
|
|
|
symbol: "bell"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#expect(notification.id == id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Equatable
|
|
|
|
|
|
|
|
|
|
@Suite("Equatable")
|
|
|
|
|
struct EquatableConformance {
|
|
|
|
|
|
2026-07-05 16:21:30 +02:00
|
|
|
@Test
|
|
|
|
|
func `notifications with the same identifier and values are equal`() {
|
2026-07-05 13:34:16 +02:00
|
|
|
let id = UUID()
|
|
|
|
|
|
|
|
|
|
let first = AppNotification(
|
|
|
|
|
id: id,
|
|
|
|
|
kind: .info,
|
|
|
|
|
message: "Something happened.",
|
|
|
|
|
symbol: "bell"
|
|
|
|
|
)
|
|
|
|
|
let second = AppNotification(
|
|
|
|
|
id: id,
|
|
|
|
|
kind: .info,
|
|
|
|
|
message: "Something happened.",
|
|
|
|
|
symbol: "bell"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#expect(first == second)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 16:21:30 +02:00
|
|
|
@Test
|
|
|
|
|
func `notifications with generated identifiers are never equal`() {
|
2026-07-05 13:34:16 +02:00
|
|
|
let first = AppNotification(
|
|
|
|
|
kind: .info,
|
|
|
|
|
message: "Something happened.",
|
|
|
|
|
symbol: "bell"
|
|
|
|
|
)
|
|
|
|
|
let second = AppNotification(
|
|
|
|
|
kind: .info,
|
|
|
|
|
message: "Something happened.",
|
|
|
|
|
symbol: "bell"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#expect(first != second)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|