I'm trying to learn how to use MVVM architecture with TDD to solve some of the problems with not being able to unit test Views in SwiftUI.
I have an Alarm struct which takes a date:
import Foundation
struct Alarm {
var time: Date
}
And I have a basic
class AlarmPickerViewModel: ObservableObject {
@Published var alarm: Alarm
init(alarm: Alarm) {
self.alarm = alarm
}
}
I'm struggling to work out how to write a unit test that fails if the AlarmPickerViewModel
isn't a subclass of ObservableObject
and the alarm property isn't @Published
.
I've looked at this question on the site but it doesn't seem to help me.
Any pointers on where I'm going wrong please?