67 lines
1.9 KiB
Swift
67 lines
1.9 KiB
Swift
//
|
|
// AndromidaTests.swift
|
|
// AndromidaTests
|
|
//
|
|
// Created by Matt Bruce on 1/25/26.
|
|
//
|
|
|
|
import Testing
|
|
import SwiftData
|
|
import Foundation
|
|
@testable import Rituals
|
|
|
|
struct AndromidaTests {
|
|
|
|
@Test func example() async throws {
|
|
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
|
}
|
|
|
|
@MainActor
|
|
@Test func modelContextCanInsertBareRitual() throws {
|
|
let schema = Schema([Ritual.self, RitualArc.self, ArcHabit.self])
|
|
let config = ModelConfiguration(
|
|
schema: schema,
|
|
isStoredInMemoryOnly: true,
|
|
cloudKitDatabase: .none
|
|
)
|
|
let container = try ModelContainer(for: schema, configurations: [config])
|
|
let context = container.mainContext
|
|
|
|
let ritual = Ritual(title: "Bare", theme: "Test", arcs: [])
|
|
context.insert(ritual)
|
|
try context.save()
|
|
|
|
let rituals = try context.fetch(FetchDescriptor<Ritual>())
|
|
#expect(rituals.count == 1)
|
|
}
|
|
|
|
@MainActor
|
|
@Test func storeCanCreateQuickRitual() throws {
|
|
let schema = Schema([Ritual.self, RitualArc.self, ArcHabit.self])
|
|
let config = ModelConfiguration(
|
|
schema: schema,
|
|
isStoredInMemoryOnly: true,
|
|
cloudKitDatabase: .none
|
|
)
|
|
let container = try ModelContainer(for: schema, configurations: [config])
|
|
let store = RitualStore(
|
|
modelContext: container.mainContext,
|
|
seedService: EmptySeedService(),
|
|
settingsStore: TestFeedbackSettings()
|
|
)
|
|
|
|
store.createQuickRitual()
|
|
#expect(store.rituals.count == 1)
|
|
}
|
|
|
|
}
|
|
|
|
private struct EmptySeedService: RitualSeedProviding {
|
|
func makeSeedRituals(startDate: Date) -> [Ritual] { [] }
|
|
}
|
|
|
|
private struct TestFeedbackSettings: RitualFeedbackSettingsProviding {
|
|
var hapticsEnabled: Bool = false
|
|
var soundEnabled: Bool = false
|
|
}
|