Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
test: add unit test for getFbaOutboundShipmentDetail
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jul 7, 2020
1 parent 89af12c commit 51bc669
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/sections/shipment-invoicing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { getServiceStatusByResource } from './shared'
/**
* The first API version is what's written in the docs directory name
* but the second one is what's used in the request examples
* Keeping both for now as reference, and encountered an issue in integrations
* early on (something about incorrect address) that resolved itself for some reason
*/
const SHIPMENT_INVOICING_API_VERSION = '2018-11-01'
// const SHIPMENT_INVOICING_API_VERSION = '2018-09-01'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<GetFBAOutboundShipmentDetailResponse xmlns="http://mws.amazonservices.com/schema/ShipmentInvoicing/2018-09-01">
<GetFBAOutboundShipmentDetailResult>
<ShipmentDetail>
<PurchaseDate>2018-04-16T14:44:38Z</PurchaseDate>
<WarehouseId>XXXX</WarehouseId>
<AmazonOrderId>701-0000000-0000000</AmazonOrderId>
<AmazonShipmentId>DrLqQwqvb</AmazonShipmentId>
<BuyerTaxInfo>
<TaxClassifications>
<TaxClassification>
<Name>CPF</Name>
<Value>99999999999</Value>
</TaxClassification>
</TaxClassifications>
</BuyerTaxInfo>
<PaymentMethodDetails>
<PaymentMethodDetail>CreditCard</PaymentMethodDetail>
</PaymentMethodDetails>
<BuyerCounty>Centro</BuyerCounty>
<BuyerName>Fulano da Silva</BuyerName>
<MarketplaceId>A2Q3Y263D00KWC</MarketplaceId>
<ShippingAddress>
<City>SAO PAULO</City>
<PostalCode>00000-000</PostalCode>
<StateOrRegion>SP</StateOrRegion>
<Phone>11912345678</Phone>
<CountryCode>BR</CountryCode>
<Name>Beltrano da Silva</Name>
<AddressLine1>Rua da Consolação, 700</AddressLine1>
<AddressLine2>Apto 32</AddressLine2>
</ShippingAddress>
<ShipmentItems>
<ShipmentItem>
<QuantityOrdered>2</QuantityOrdered>
<Title>iPhone X Apple Cinza Espacial, 64 GB e Câmera 12 MP</Title>
<PromotionDiscount>
<CurrencyCode>BRL</CurrencyCode>
<Amount>0.00</Amount>
</PromotionDiscount>
<ASIN>B078HVJB69</ASIN>
<SellerSKU>XY-1A0O-B1CD</SellerSKU>
<OrderItemId>19441439621890</OrderItemId>
<ShippingPrice>
<CurrencyCode>BRL</CurrencyCode>
<Amount>30.00</Amount>
</ShippingPrice>
<GiftWrapPrice>
<CurrencyCode>BRL</CurrencyCode>
<Amount>0.00</Amount>
</GiftWrapPrice>
<ItemPrice>
<CurrencyCode>BRL</CurrencyCode>
<Amount>5099.99</Amount>
</ItemPrice>
<ShippingDiscount>
<CurrencyCode>BRL</CurrencyCode>
<Amount>0.00</Amount>
</ShippingDiscount>
<SerialNumbers>
<SerialNumber>1234567890</SerialNumber>
<SerialNumber>1234567687</SerialNumber>
</SerialNumbers>
</ShipmentItem>
</ShipmentItems>
</ShipmentDetail>
</GetFBAOutboundShipmentDetailResult>
<ResponseMetadata>
<RequestId>88faca76-b600-46d2-b53c-0c8c4533e43a</RequestId>
</ResponseMetadata>
</GetFBAOutboundShipmentDetailResponse>
31 changes: 30 additions & 1 deletion test/unit/shipment-invoicing.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
import { ParsingError } from '../../src'
import { mockMwsFail, mockMwsServiceStatus, parsingError } from '../utils'
import { createMockHttpClient, mockMwsFail, mockMwsServiceStatus, parsingError } from '../utils'

describe('shipmentInvoicing', () => {
describe('getFbaOutboundShipmentDetail', () => {
const parameters = {
MarketplaceId: '',
AmazonShipmenId: '',
}

it('returns the shipment detail if succesful', async () => {
expect.assertions(1)

const mockGetFbaOutboundShipmentDetail = createMockHttpClient(
'shipment_invoicing_get_fba_outbound_shipment_detail',
)

expect(
await mockGetFbaOutboundShipmentDetail.shipmentInvoicing.getFbaOutboundShipmentDetail(
parameters,
),
).toMatchSnapshot()
})

it('throws a parsing error when the status response is not valid', async () => {
expect.assertions(1)

await expect(() =>
mockMwsFail.shipmentInvoicing.getFbaOutboundShipmentDetail(parameters),
).rejects.toStrictEqual(new ParsingError(parsingError))
})
})

describe('getServiceStatus', () => {
it('returns a parsed model when the status response is valid', async () => {
expect.assertions(1)
Expand Down

0 comments on commit 51bc669

Please sign in to comment.