Implemented the Transcription model in the Recording package target.

This commit is contained in:
2026-07-04 10:53:33 +02:00
parent d7dc32d7f7
commit 8b46c4e7d1
4 changed files with 103 additions and 12 deletions
@@ -0,0 +1,68 @@
import Foundation
import Testing
@testable import Recording
@Suite("Transcription model")
struct TranscriptionTests {
// MARK: Initializers
@Suite("Initializers")
struct Initializers {
@Test(arguments: [
"",
"This is a transcription.",
" ",
"Multiline\ntranscribed\ntext."
])
func `initializer stores the given text`(text: String) {
let transcription = Transcription(text: text)
#expect(transcription.text == text)
}
}
// MARK: Computed properties
@Suite("Computed properties")
struct ComputedProperties {
@Test(arguments: zip(
["", "This is a transcription.", " "],
[true, false, false]
))
func `is empty only when the text has no characters`(
for text: String,
expected: Bool
) {
let transcription = Transcription(text: text)
#expect(transcription.isEmpty == expected)
}
}
// MARK: Identifiable
@Suite("Identifiable")
struct IdentifiableConformance {
@Test func `identifier is stable across accesses`() {
let transcription = Transcription(text: "This is a transcription.")
#expect(transcription.id == transcription.id)
}
@Test func `identifiers differ between transcriptions`() {
let first = Transcription(text: "This is a transcription.")
let second = Transcription(text: "This is a transcription.")
#expect(first.id != second.id)
}
}
}