Added the "id" parameter to the initializer of the Transcription model in the Recording package target.
This commit is contained in:
@@ -6,7 +6,7 @@ public struct Transcription: Equatable, Identifiable, Sendable {
|
|||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
|
|
||||||
/// The unique identifier of the transcription.
|
/// The unique identifier of the transcription.
|
||||||
public let id: UUID = .init()
|
public let id: UUID
|
||||||
|
|
||||||
/// The transcribed text of the processed recording.
|
/// The transcribed text of the processed recording.
|
||||||
public let text: String
|
public let text: String
|
||||||
@@ -14,10 +14,15 @@ public struct Transcription: Equatable, Identifiable, Sendable {
|
|||||||
// MARK: Initializers
|
// MARK: Initializers
|
||||||
|
|
||||||
/// Creates a transcription with a given text.
|
/// Creates a transcription with a given text.
|
||||||
/// - Parameter text: The transcribed text of the processed recording.
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - id: The unique identifier of the transcription. Defaults to a newly generated identifier.
|
||||||
|
/// - text: The transcribed text of the processed recording.
|
||||||
public init(
|
public init(
|
||||||
|
id: UUID = .init(),
|
||||||
text: String
|
text: String
|
||||||
) {
|
) {
|
||||||
|
self.id = id
|
||||||
self.text = text
|
self.text = text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,16 @@ struct TranscriptionTests {
|
|||||||
#expect(transcription.text == text)
|
#expect(transcription.text == text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func `initializer stores the given identifier`() {
|
||||||
|
let id = UUID()
|
||||||
|
let transcription = Transcription(
|
||||||
|
id: id,
|
||||||
|
text: "This is a transcription."
|
||||||
|
)
|
||||||
|
|
||||||
|
#expect(transcription.id == id)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Computed properties
|
// MARK: Computed properties
|
||||||
@@ -45,6 +55,35 @@ struct TranscriptionTests {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Equatable
|
||||||
|
|
||||||
|
@Suite("Equatable")
|
||||||
|
struct EquatableConformance {
|
||||||
|
|
||||||
|
@Test func `transcriptions with the same identifier and text are equal`() {
|
||||||
|
let id = UUID()
|
||||||
|
|
||||||
|
let first = Transcription(
|
||||||
|
id: id,
|
||||||
|
text: "This is a transcription."
|
||||||
|
)
|
||||||
|
let second = Transcription(
|
||||||
|
id: id,
|
||||||
|
text: "This is a transcription."
|
||||||
|
)
|
||||||
|
|
||||||
|
#expect(first == second)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func `transcriptions with generated identifiers are never equal`() {
|
||||||
|
let first = Transcription(text: "This is a transcription.")
|
||||||
|
let second = Transcription(text: "This is a transcription.")
|
||||||
|
|
||||||
|
#expect(first != second)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Identifiable
|
// MARK: Identifiable
|
||||||
|
|
||||||
@Suite("Identifiable")
|
@Suite("Identifiable")
|
||||||
|
|||||||
Reference in New Issue
Block a user