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

Commit

Permalink
fix: updated fixture. changed some enums to string
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed May 26, 2020
1 parent f7f5453 commit 8313317
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 121 deletions.
32 changes: 1 addition & 31 deletions src/sections/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,38 +103,8 @@ const FeesEstimateIdentifier = Codec.interface({
IsAmazonFulfilled: boolean,
})

enum FeeType {
ReferralFee = 'ReferralFee',
VariableClosingFee = 'VariableClosingFee',
PerItemFee = 'PerItemFee',
FBAFees = 'FBAFees',
FBAPickAndPack = 'FBAPickAndPack',
FBAWeightHandling = 'FBAWeightHandling',
FBAOrderHandling = 'FBAOrderHandling',
FBADeliveryServicesFee = 'FBADeliveryServicesFee',
}

type AvailableFeeTypes =
| 'ReferralFee'
| 'VariableClosingFee'
| 'PerItemFee'
| 'FBAFees'
| 'FBAPickAndPack'
| 'FBAWeightHandling'
| 'FBAOrderHandling'
| 'FBADeliveryServicesFee'

interface FeeDetail {
FeeType: AvailableFeeTypes
FeeAmount: MoneyType
FeePromotion?: MoneyType
TaxAmount?: MoneyType
FinalFee: MoneyType
IncludedFeeDetailList?: FeeDetail
}

const FeeDetail = Codec.interface({
FeeType: oneOf(Object.values(FeeType).map((x) => exactly(x))),
FeeType: string,
FeeAmount: MoneyType,
FeePromotion: optional(MoneyType),
TaxAmount: optional(MoneyType),
Expand Down
183 changes: 112 additions & 71 deletions test/unit/__fixtures__/products_get_my_fees_estimate.xml
Original file line number Diff line number Diff line change
@@ -1,76 +1,117 @@
<GetMyFeesEstimateResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<GetMyFeesEstimateResult>
<FeesEstimateResultList>
<FeesEstimateResult>
<Status>Success</Status>
<FeesEstimateIdentifier>
<MarketplaceId>String</MarketplaceId>
<SellerId>String</SellerId>
<IdType>SKU</IdType>
<IdValue>String</IdValue>
<IsAmazonFulfilled>true</IsAmazonFulfilled>
<PriceToEstimateFees>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>100</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>100</Amount>
</Shipping>
<Points>
<PointsNumber>1</PointsNumber>
<PointsMonetaryValue>
<GetMyFeesEstimateResult>
<FeesEstimateResultList>
<FeesEstimateResult>
<Status>Success</Status>
<FeesEstimateIdentifier>
<MarketplaceId>ATVPDKIKX0DER</MarketplaceId>
<IdValue>B0002GTTRC</IdValue>
<IdType>ASIN</IdType>
<IsAmazonFulfilled>true</IsAmazonFulfilled>
<PriceToEstimateFees>
<ListingPrice>
<CurrencyCode>USD</CurrencyCode>
<Amount>58.00</Amount>
</ListingPrice>
<Shipping>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.00</Amount>
</Shipping>
<Points>
<PointsNumber>0</PointsNumber>
<PointsMonetaryValue>
<CurrencyCode>USD</CurrencyCode>
<Amount>100</Amount>
</PointsMonetaryValue>
</Points>
</PriceToEstimateFees>
<SellerInputIdentifier>String</SellerInputIdentifier>
</FeesEstimateIdentifier>
<FeesEstimate>
<TimeOfFeesEstimation>1969-07-21T02:56:03Z</TimeOfFeesEstimation>
<TotalFeesEstimate>
<CurrencyCode>USD</CurrencyCode>
<Amount>100</Amount>
</TotalFeesEstimate>
<FeeDetailList>
<FeeDetail>
<FeeType>ReferralFee</FeeType>
<FeeAmount>
<CurrencyCode>USD</CurrencyCode>
<Amount>100</Amount>
</FeeAmount>
<FeePromotion>
<CurrencyCode>USD</CurrencyCode>
<Amount>100</Amount>
</FeePromotion>
<TaxAmount>
<CurrencyCode>USD</CurrencyCode>
<Amount>100</Amount>
</TaxAmount>
<FinalFee>
<CurrencyCode>USD</CurrencyCode>
<Amount>100</Amount>
</FinalFee>
<IncludedFeeDetailList>

</IncludedFeeDetailList>
</FeeDetail>
</FeeDetailList>
</FeesEstimate>
<Error>
<Type>String</Type>
<Code>String</Code>
<Message>String</Message>
<Detail>
<Any><any-xml></any-xml></Any>
</Detail>
</Error>
</FeesEstimateResult>
</FeesEstimateResultList>
</GetMyFeesEstimateResult>
<ResponseMetadata>
<RequestId>String</RequestId>
</ResponseMetadata>
</Points>
</PriceToEstimateFees>
<SellerInputIdentifier>IDDDDDDDD</SellerInputIdentifier>
</FeesEstimateIdentifier>
<FeesEstimate>
<TimeOfFeesEstimation>2015-07-19T23:15:11.859Z</TimeOfFeesEstimation>
<TotalFeesEstimate>
<CurrencyCode>USD</CurrencyCode>
<Amount>10.00</Amount>
</TotalFeesEstimate>
<FeeDetailList>
<FeeDetail>
<FeeType>ReferralFee</FeeType>
<FeeAmount>
<CurrencyCode>USD</CurrencyCode>
<Amount>8.70</Amount>
</FeeAmount>
<FeePromotion>
<CurrencyCode>USD</CurrencyCode>
<Amount>1.00</Amount>
</FeePromotion>
<FinalFee>
<CurrencyCode>USD</CurrencyCode>
<Amount>7.70</Amount>
</FinalFee>
</FeeDetail>
<FeeDetail>
<FeeType>VariableClosingFee</FeeType>
<FeeAmount>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.00</Amount>
</FeeAmount>
<FinalFee>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.0</Amount>
</FinalFee>
</FeeDetail>
<FeeDetail>
<FeeType>FulfillmentFees</FeeType>
<FeeAmount>
<CurrencyCode>USD</CurrencyCode>
<Amount>2.30</Amount>
</FeeAmount>
<FinalFee>
<CurrencyCode>USD</CurrencyCode>
<Amount>2.30</Amount>
</FinalFee>
<IncludedFeeList>
<FeeDetail>
<FeeType>OrderHandlingFee</FeeType>
<FeeAmount>
<CurrencyCode>USD</CurrencyCode>
<Amount>1.00</Amount>
</FeeAmount>
<FinalFee>
<CurrencyCode>USD</CurrencyCode>
<Amount>1.00</Amount>
</FinalFee>
</FeeDetail>
<FeeDetail>
<FeeType>PickAndPackFee</FeeType>
<FeeAmount>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.30</Amount>
</FeeAmount>
<FinalFee>
<CurrencyCode>USD</CurrencyCode>
<Amount>0.30</Amount>
</FinalFee>
</FeeDetail>
<FeeDetail>
<FeeType>WeightHandlingFee</FeeType>
<FeeAmount>
<CurrencyCode>USD</CurrencyCode>
<Amount>1.00</Amount>
</FeeAmount>
<FinalFee>
<CurrencyCode>USD</CurrencyCode>
<Amount>1.00</Amount>
</FinalFee>
</FeeDetail>
</IncludedFeeList>
</FeeDetail>
</FeeDetailList>
</FeesEstimate>
</FeesEstimateResult>
</FeesEstimateResultList>
</GetMyFeesEstimateResult>
<ResponseMetadata>
<RequestId>21534f03-e7e3-4d9a-9bea-0e15add3326d</RequestId>
</ResponseMetadata>
</GetMyFeesEstimateResponse>
60 changes: 41 additions & 19 deletions test/unit/__snapshots__/products.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,84 @@ Array [
Object {
"FeesEstimateResultList": Array [
Object {
"Error": Object {
"Code": "String",
"Message": "String",
"Type": "String",
},
"Error": undefined,
"FeesEstimate": Object {
"FeeDetailList": Array [
Object {
"FeeAmount": Object {
"Amount": 100,
"Amount": 8.7,
"CurrencyCode": "USD",
},
"FeePromotion": Object {
"Amount": 100,
"Amount": 1,
"CurrencyCode": "USD",
},
"FeeType": "ReferralFee",
"FinalFee": Object {
"Amount": 100,
"Amount": 7.7,
"CurrencyCode": "USD",
},
"TaxAmount": Object {
"Amount": 100,
"IncludedFeeDetailList": undefined,
"TaxAmount": undefined,
},
Object {
"FeeAmount": Object {
"Amount": 0,
"CurrencyCode": "USD",
},
"FeePromotion": undefined,
"FeeType": "VariableClosingFee",
"FinalFee": Object {
"Amount": 0,
"CurrencyCode": "USD",
},
"IncludedFeeDetailList": undefined,
"TaxAmount": undefined,
},
Object {
"FeeAmount": Object {
"Amount": 2.3,
"CurrencyCode": "USD",
},
"FeePromotion": undefined,
"FeeType": "FulfillmentFees",
"FinalFee": Object {
"Amount": 2.3,
"CurrencyCode": "USD",
},
"IncludedFeeDetailList": undefined,
"TaxAmount": undefined,
},
],
"TimeOfFeesEstimation": 1969-07-21T02:56:03.000Z,
"TimeOfFeesEstimation": 2015-07-19T23:15:11.859Z,
"TotalFeesEstimate": Object {
"Amount": 100,
"Amount": 10,
"CurrencyCode": "USD",
},
},
"FeesEstimateIdentifier": Object {
"IdType": "SKU",
"IdValue": "String",
"IdType": "ASIN",
"IdValue": "B0002GTTRC",
"IsAmazonFulfilled": true,
"MarketplaceId": "String",
"MarketplaceId": "ATVPDKIKX0DER",
"PriceToEstimateFees": Object {
"ListingPrice": Object {
"Amount": 100,
"Amount": 58,
"CurrencyCode": "USD",
},
"Points": Object {
"PointsMonetaryValue": Object {
"Amount": 100,
"CurrencyCode": "USD",
},
"PointsNumber": 1,
"PointsNumber": 0,
},
"Shipping": Object {
"Amount": 100,
"Amount": 0,
"CurrencyCode": "USD",
},
},
"SellerInputIdentifier": "String",
"SellerInputIdentifier": "IDDDDDDDD",
},
"Status": "Success",
},
Expand Down

0 comments on commit 8313317

Please sign in to comment.