import Foundation
import Testing
import ForgejoKit
@testable import Forji

@MainActor
struct CommentSheetTests {

    @Test func onSubmitClosureIsInvoked() async throws {
        var submittedBody: String?
        let sheet = CommentSheet(users: []) { body in
            submittedBody = body
        }
        #expect(sheet.users.isEmpty)
        try await sheet.onSubmit("  hello world  ")
        #expect(submittedBody == "  hello world  ")
    }

    @Test func usersPassedThrough() {
        let user = User(
            id: 1,
            login: "testuser",
            fullName: "Test User",
            email: "test@example.com",
            avatarUrl: "https://example.com/avatar.png"
        )
        let sheet = CommentSheet(users: [user]) { _ in }
        #expect(sheet.users.count == 1)
        #expect(sheet.users.first?.login == "testuser")
    }

    @Test func emptyUsersForIssues() {
        let sheet = CommentSheet(users: []) { _ in }
        #expect(sheet.users.isEmpty)
    }
}
