SwiftUI + SwiftData + iCloud, Apple Speech transcription (German), audio recording, summarization service protocol (LLM-ready), localization scaffolding (EN/DE/ES/FR), basic tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
76 lines
2.1 KiB
Swift
76 lines
2.1 KiB
Swift
import Testing
|
|
@testable import VoiceDiary
|
|
|
|
@Suite("DiaryEntry Tests")
|
|
struct DiaryEntryTests {
|
|
@Test("Entry date is normalized to start of day")
|
|
func dateNormalization() {
|
|
let now = Date.now
|
|
let entry = DiaryEntry(date: now)
|
|
let startOfDay = Calendar.current.startOfDay(for: now)
|
|
#expect(entry.date == startOfDay)
|
|
}
|
|
|
|
@Test("Combined transcript joins memo transcripts")
|
|
func combinedTranscript() {
|
|
let entry = DiaryEntry(date: .now)
|
|
|
|
let memo1 = VoiceMemo(audioFileName: "test1.m4a", duration: 10)
|
|
memo1.transcript = "First memo."
|
|
|
|
let memo2 = VoiceMemo(audioFileName: "test2.m4a", duration: 20)
|
|
memo2.transcript = "Second memo."
|
|
|
|
entry.memos = [memo1, memo2]
|
|
|
|
#expect(entry.combinedTranscript.contains("First memo."))
|
|
#expect(entry.combinedTranscript.contains("Second memo."))
|
|
}
|
|
|
|
@Test("Entry without memos has empty transcript")
|
|
func emptyTranscript() {
|
|
let entry = DiaryEntry(date: .now)
|
|
#expect(entry.combinedTranscript.isEmpty)
|
|
}
|
|
|
|
@Test("hasMemos returns correct state")
|
|
func hasMemos() {
|
|
let entry = DiaryEntry(date: .now)
|
|
#expect(!entry.hasMemos)
|
|
|
|
entry.memos.append(VoiceMemo(audioFileName: "test.m4a", duration: 5))
|
|
#expect(entry.hasMemos)
|
|
}
|
|
}
|
|
|
|
@Suite("VoiceMemo Tests")
|
|
struct VoiceMemoTests {
|
|
@Test("Formatted duration displays correctly")
|
|
func formattedDuration() {
|
|
let memo = VoiceMemo(audioFileName: "test.m4a", duration: 125)
|
|
#expect(memo.formattedDuration == "2:05")
|
|
}
|
|
|
|
@Test("Audio URL is constructed correctly")
|
|
func audioURL() {
|
|
let memo = VoiceMemo(audioFileName: "test-memo.m4a", duration: 10)
|
|
#expect(memo.audioURL.lastPathComponent == "test-memo.m4a")
|
|
#expect(memo.audioURL.pathComponents.contains("VoiceMemos"))
|
|
}
|
|
}
|
|
|
|
@Suite("LocalSummarizationProvider Tests")
|
|
struct SummarizationTests {
|
|
@Test("Placeholder summarization produces markdown")
|
|
func basicSummarization() async throws {
|
|
let provider = LocalSummarizationProvider()
|
|
let result = try await provider.summarize(
|
|
transcript: "Heute war ein guter Tag. Ich habe viel geschafft.",
|
|
date: Date.now
|
|
)
|
|
#expect(result.contains("# "))
|
|
#expect(result.contains("Erlebnisse des Tages"))
|
|
#expect(result.contains("Heute war ein guter Tag"))
|
|
}
|
|
}
|