Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit 8a16e3e

Browse files
committed
update tests for listFinancialEvents and getMyFeesEstimate
1 parent e1d5cc2 commit 8a16e3e

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

test/test-api.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('API', function runAPITests() {
5353
};
5454
const results = await MWS.listOrders(params);
5555
expect(results).to.have.lengthOf.above(0);
56-
orderIds = Object.keys(results).map(order => results[order].AmazonOrderId);
56+
orderIds = Object.keys(results).map((order) => results[order].AmazonOrderId);
5757
expect(orderIds).to.have.lengthOf.above(0);
5858
orderId = orderIds[0];
5959
return true;
@@ -88,7 +88,7 @@ describe('API', function runAPITests() {
8888
startDate.setDate(startDate.getDate() - 7);
8989
const result = await MWS.listFinancialEvents({ PostedAfter: startDate });
9090
expect(result).to.be.an('object');
91-
expect(result).to.have.keys(
91+
expect(result).to.include.keys(
9292
'ProductAdsPaymentEventList', 'RentalTransactionEventList',
9393
'PayWithAmazonEventList', 'ServiceFeeEventList',
9494
'CouponPaymentEventList', 'ServiceProviderCreditEventList',
@@ -100,6 +100,8 @@ describe('API', function runAPITests() {
100100
'AffordabilityExpenseEventList', 'AffordabilityExpenseReversalEventList',
101101
'NetworkComminglingTransactionEventList',
102102
);
103+
// another possible key is RemovalShipmentEventList, but only comes up if you have
104+
// removal orders in your recent queue
103105
return result;
104106
});
105107
});
@@ -382,6 +384,9 @@ describe('API', function runAPITests() {
382384
expect(prices2.listingPrice).to.deep.equal(test2.listingPrice);
383385
expect(prices2.shipping).to.deep.equal(test2.shipping);
384386
});
387+
// TODO: this test used to test for a ServerError condition, where data was not
388+
// available.
389+
// now the exact same call is providing a ClientError instead. ?!
385390
it('getMyFeesEstimate error handling', async function testFeesErrors() {
386391
const feeTest = {
387392
marketplaceId: 'ATVPDKIKX0DER',
@@ -399,16 +404,21 @@ describe('API', function runAPITests() {
399404
};
400405
const res = await MWS.getMyFeesEstimate([feeTest]);
401406
const test = res[`FBA.${feeTest.idValue}`];
407+
console.warn('* res=', res);
402408
expect(test.totalFees).to.equal(undefined);
403409
expect(test.time).to.equal(undefined);
404410
expect(test.detail).to.equal(undefined);
405411
expect(test.identifier).to.be.an('Object');
406412
expect(test.identifier.isAmazonFulfilled).to.equal(true);
407-
expect(test.status).to.equal('ServerError');
413+
// expect(test.status).to.equal('ServerError');
414+
expect(test.status).to.equal('ClientError');
408415
expect(test.error).to.be.an('Object').that.includes.all.keys('code', 'message', 'type');
409-
expect(test.error.code).to.equal('DataNotAvailable');
410-
expect(test.error.message).to.equal('Item shipping weight is not available.');
411-
expect(test.error.type).to.equal('Receiver');
416+
// expect(test.error.code).to.equal('DataNotAvailable');
417+
expect(test.error.code).to.equal('InvalidParameterValue');
418+
// expect(test.error.message).to.equal('Item shipping weight is not available.');
419+
expect(test.error.message).to.equal('There is an client-side error. Please verify your inputs.');
420+
expect(test.error.type).to.equal('Sender');
421+
// expect(test.error.type).to.equal('Receiver');
412422
return res;
413423
});
414424
});

0 commit comments

Comments
 (0)