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

Commit

Permalink
test: add test for mwsDate
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jul 2, 2020
1 parent 7df0580 commit 96613d6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/unit/__snapshots__/merchant-fulfillment.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Array [
"AmazonOrderId": "903-1713775-3598252",
"CreatedDate": 2015-09-23T20:11:12.908Z,
"Insurance": Object {
"Amount": 10,
"CurrencyCode": "USD",
},
"ItemList": Array [
Expand Down Expand Up @@ -68,6 +69,7 @@ Array [
"EarliestEstimatedDeliveryDate": 2015-09-24T10:30:00.000Z,
"LatestEstimatedDeliveryDate": 2015-09-24T10:30:00.000Z,
"Rate": Object {
"Amount": 27.81,
"CurrencyCode": "USD",
},
"ShipDate": 2015-09-23T20:10:56.829Z,
Expand All @@ -78,6 +80,7 @@ Array [
"ShippingServiceOptions": Object {
"CarrierWillPickUp": false,
"DeclaredValue": Object {
"Amount": 10,
"CurrencyCode": "USD",
},
"DeliveryExperience": "DELIVERY_CONFIRMATION",
Expand Down Expand Up @@ -336,6 +339,7 @@ Array [
},
"ValueAsBoolean": true,
"ValueAsCurrency": Object {
"Amount": 100,
"CurrencyCode": "String",
},
"ValueAsDimension": Object {},
Expand Down Expand Up @@ -386,6 +390,7 @@ Array [
},
"ValueAsBoolean": true,
"ValueAsCurrency": Object {
"Amount": 100,
"CurrencyCode": "String",
},
"ValueAsDimension": Object {},
Expand Down Expand Up @@ -433,6 +438,7 @@ Array [
"EarliestEstimatedDeliveryDate": 2019-08-27T18:00:00.000Z,
"LatestEstimatedDeliveryDate": 2019-08-27T18:00:00.000Z,
"Rate": Object {
"Amount": 90,
"CurrencyCode": "CNY",
},
"RequiresAdditionalSellerInputs": true,
Expand Down Expand Up @@ -492,6 +498,7 @@ Array [
"EarliestEstimatedDeliveryDate": 2018-10-17T18:00:00.000Z,
"LatestEstimatedDeliveryDate": 2018-10-17T18:00:00.000Z,
"Rate": Object {
"Amount": 16.83,
"CurrencyCode": "USD",
},
"RequiresAdditionalSellerInputs": false,
Expand Down Expand Up @@ -571,6 +578,7 @@ Array [
"EarliestEstimatedDeliveryDate": 1969-07-21T02:56:03.000Z,
"LatestEstimatedDeliveryDate": 1969-07-21T02:56:03.000Z,
"Rate": Object {
"Amount": 100,
"CurrencyCode": "String",
},
"RequiresAdditionalSellerInputs": true,
Expand All @@ -581,6 +589,7 @@ Array [
"ShippingServiceOptions": Object {
"CarrierWillPickUp": true,
"DeclaredValue": Object {
"Amount": 100,
"CurrencyCode": "String",
},
"DeliveryExperience": "DeliveryConfirmationWithAdultSignature",
Expand Down
25 changes: 25 additions & 0 deletions test/unit/codec.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { mwsDate } from '../../src/parsing'

describe('sellers', () => {
describe('mwsDate', () => {
/**
* Adding this test because for some reason git actions fails on dates
* https://github.com/ScaleLeap/amazon-mws-api-sdk/pull/113/checks?check_run_id=830331398
*/
it('parses dates correctly', async () => {
expect.assertions(1)

const shipDate = '10/16/2018 07:41:12'
const fromSnapshot = '2018-10-15T23:41:12.000Z' // this is the output of the snapshot
// const notFromSnapshot = '2018-10-16T07:41:12.000Z' // the output from the test running in git
const output = mwsDate.decode(shipDate).caseOf({
Right: (x) => x.toISOString(),
Left: () => {
console.log()
},
})

expect(output).toStrictEqual(fromSnapshot)
})
})
})

0 comments on commit 96613d6

Please sign in to comment.