import Foundation import Testing @testable import PediFoods @Test("Customer profile decodes persisted favorite store ids") func customerProfileDecodesFavoriteStoreIds() throws { let json = """ { "error": false, "result": { "id": "cust_1", "name": "Daniel", "email": "daniel@example.com", "phoneNumber": "+5511999999999", "favorites": ["store_a", "store_b"], "address_book": [] } } """ let envelope = try JSONDecoder().decode(ApiEnvelope.self, from: Data(json.utf8)) #expect(envelope.result?.favorites == ["store_a", "store_b"]) } @Test("Favorite mutation decodes updated favorites array") func favoriteMutationDecodesUpdatedFavoritesArray() throws { let json = """ { "error": false, "result": { "favorites": ["store_a"], "store": { "id": "store_a", "name": "CPS Drinks", "category": "Doces & Bolos", "rating": 4.8, "totalReviews": 12, "isOpen": true, "statusLabel": "Aberto" } } } """ let envelope = try JSONDecoder().decode(ApiEnvelope.self, from: Data(json.utf8)) #expect(envelope.result?.favorites == ["store_a"]) #expect(envelope.result?.store?.id == "store_a") #expect(envelope.result?.store?.name == "CPS Drinks") }