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)
        }

    }

}
