From 088c4c757ea09ed026a8a43b3ecf976882c582f7 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 4 Jul 2026 15:37:36 +0200 Subject: [PATCH] Added the "id" parameter to the initializer of the Transcription model in the Recording package target. --- .../Recording/Models/Transcription.swift | 11 ++++-- .../Recording/Models/TranscriptionTests.swift | 39 +++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/Packages/Features/Sources/Recording/Models/Transcription.swift b/Packages/Features/Sources/Recording/Models/Transcription.swift index 86cda99..7c2a23c 100644 --- a/Packages/Features/Sources/Recording/Models/Transcription.swift +++ b/Packages/Features/Sources/Recording/Models/Transcription.swift @@ -6,18 +6,23 @@ public struct Transcription: Equatable, Identifiable, Sendable { // MARK: Properties /// The unique identifier of the transcription. - public let id: UUID = .init() + public let id: UUID /// The transcribed text of the processed recording. public let text: String - + // MARK: Initializers /// 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( + id: UUID = .init(), text: String ) { + self.id = id self.text = text } diff --git a/Packages/Features/Tests/Recording/Models/TranscriptionTests.swift b/Packages/Features/Tests/Recording/Models/TranscriptionTests.swift index 19113f1..3f8ed1f 100644 --- a/Packages/Features/Tests/Recording/Models/TranscriptionTests.swift +++ b/Packages/Features/Tests/Recording/Models/TranscriptionTests.swift @@ -23,6 +23,16 @@ struct TranscriptionTests { #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 @@ -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 @Suite("Identifiable")