import SwiftUI import Testing @testable import PediFoods @MainActor private func makeCheckoutView() -> CheckoutView { var appState = AppState() let appStateBinding = Binding(get: { appState }, set: { appState = $0 }) var selectedTab = MainTab.cart let tabBinding = Binding(get: { selectedTab }, set: { selectedTab = $0 }) return CheckoutView(appState: appStateBinding, selectedTab: tabBinding) } @Test("formatCurrency formats a Double as Brazilian Real with a comma decimal separator") @MainActor func formatCurrencyUsesCommaDecimalSeparator() { let view = makeCheckoutView() #expect(view.formatCurrency(29.9) == "R$ 29,90") #expect(view.formatCurrency(0) == "R$ 0,00") #expect(view.formatCurrency(1234.5) == "R$ 1234,50") } @Test("CheckoutPayloadValidationError provides a distinct Portuguese message per case") func checkoutPayloadValidationErrorMessages() { #expect(CheckoutView.CheckoutPayloadValidationError.emptyCart.errorDescription == "Carrinho vazio.") #expect(CheckoutView.CheckoutPayloadValidationError.missingCustomerName.errorDescription == "Nome do cliente não informado.") #expect(CheckoutView.CheckoutPayloadValidationError.missingCustomerEmail.errorDescription == "Email do cliente não informado.") #expect(CheckoutView.CheckoutPayloadValidationError.missingCustomerPhone.errorDescription == "Telefone do cliente não informado.") #expect(CheckoutView.CheckoutPayloadValidationError.missingAddressStreet.errorDescription == "Rua do endereço não informada.") #expect(CheckoutView.CheckoutPayloadValidationError.missingAddressNumber.errorDescription == "Número do endereço não informado.") #expect(CheckoutView.CheckoutPayloadValidationError.missingAddressNeighborhood.errorDescription == "Bairro do endereço não informado.") }