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

Commit

Permalink
fix: update linting rules and fix code (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
tusbar committed Sep 5, 2022
1 parent 1870ad0 commit 6d6095b
Show file tree
Hide file tree
Showing 196 changed files with 939 additions and 914 deletions.
12 changes: 5 additions & 7 deletions __tests__/lib/client/error.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const nock = require('nock')
const got = require('got')

const {inspectError} = require('../../__helpers__/inspect')
const nock = require('nock')

const MWSClient = require('../../../lib/client')
const MWSError = require('../../../lib/client/error')

const {parseStr} = require('../../../lib/client/parsers/base')
const {parseString} = require('../../../lib/client/parsers/base')
const {inspectError} = require('../../__helpers__/inspect')

describe('lib.client.error', () => {
const client = new MWSClient({
Expand Down Expand Up @@ -145,8 +143,8 @@ describe('lib.client.error', () => {
resource: 'Sellers',
action: 'GetSomething',
parseErrorResponse: (key, node) => ({
foo: parseStr(`${key}/sellers:Foo`, node),
bar: parseStr(`${key}/sellers:Bar`, node),
foo: parseString(`${key}/sellers:Foo`, node),
bar: parseString(`${key}/sellers:Bar`, node),
}),
})

Expand Down
2 changes: 1 addition & 1 deletion __tests__/lib/client/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const process = require('process')

const nock = require('nock')
const MockDate = require('mockdate')
const nock = require('nock')

const MWSClient = require('../../../lib/client')

Expand Down
2 changes: 1 addition & 1 deletion __tests__/lib/client/models/finances.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const nock = require('nock')
const MockDate = require('mockdate')
const nock = require('nock')

const MWSClient = require('../../../..')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const nock = require('nock')
const MockDate = require('mockdate')
const nock = require('nock')

const MWSClient = require('../../../..')

Expand Down
2 changes: 1 addition & 1 deletion __tests__/lib/client/models/fulfillment-inventory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const nock = require('nock')
const MockDate = require('mockdate')
const nock = require('nock')

const MWSClient = require('../../../..')

Expand Down
2 changes: 1 addition & 1 deletion __tests__/lib/client/models/orders.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const nock = require('nock')
const MockDate = require('mockdate')
const nock = require('nock')

const MWSClient = require('../../../..')
const {arrayToObject} = require('../../../../lib/client/utils')
Expand Down
2 changes: 1 addition & 1 deletion __tests__/lib/client/models/products.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const nock = require('nock')
const MockDate = require('mockdate')
const nock = require('nock')

const MWSClient = require('../../../..')

Expand Down
2 changes: 1 addition & 1 deletion __tests__/lib/client/models/reports.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {Buffer} = require('buffer')

const nock = require('nock')
const MockDate = require('mockdate')
const nock = require('nock')

const MWSClient = require('../../../..')

Expand Down
17 changes: 10 additions & 7 deletions __tests__/lib/client/parsers/base/attributes.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const parseXml = require('../../../../../lib/client/parsers')

const {
parseAttributeStr,
parseAttributeString,
parseAttributeNumber,
parseAttributeDecimal,
parseAttributeDate,
} = require('../../../../../lib/client/parsers/base/attributes')

describe('lib.client.parsers.base.attributes', () => {
describe('parseAttributeStr', () => {
describe('parseAttributeString', () => {
it('should return null when trying to access attributes on a non-existing node', () => {
const value = parseAttributeNumber('/NotHere', parseXml('<Foo bar="" />'), 'bar')

Expand All @@ -17,7 +16,7 @@ describe('lib.client.parsers.base.attributes', () => {

it('should throw when trying accessing attributes from multiple nodes', () => {
expect(() =>
parseAttributeStr(
parseAttributeString(
'/Wrapper/Foo',
parseXml(`
<Wrapper>
Expand All @@ -31,19 +30,23 @@ describe('lib.client.parsers.base.attributes', () => {
})

it('should return null if the attribute does not exist', () => {
const value = parseAttributeStr('.', parseXml('<Foo bar="a" />'), 'notHere')
const value = parseAttributeString('.', parseXml('<Foo bar="a" />'), 'notHere')

expect(value).toBeNull()
})

it('should return an empty string if the attribute is empty', () => {
const value = parseAttributeStr('.', parseXml('<Foo bar="" />'), 'bar')
const value = parseAttributeString('.', parseXml('<Foo bar="" />'), 'bar')

expect(value).toBe('')
})

it('should trim the attribute', () => {
const value = parseAttributeStr('.', parseXml('<Foo bar=" with spaces around " />'), 'bar')
const value = parseAttributeString(
'.',
parseXml('<Foo bar=" with spaces around " />'),
'bar',
)

expect(value).toBe('with spaces around')
})
Expand Down
4 changes: 2 additions & 2 deletions __tests__/lib/client/parsers/finances/get-service-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ describe('lib.client.parsers.base.get-service-status-response', () => {
</GetServiceStatusResponse>`,
)

const res = parseGetServiceStatusResponse('/finances:GetServiceStatusResponse', doc)
const response = parseGetServiceStatusResponse('/finances:GetServiceStatusResponse', doc)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ describe('lib.client.parsers.finances.list-financial-event-groups-response', ()
</ListFinancialEventGroupsResponse>`,
)

const res = parseListFinancialEventGroupsResponse(
const response = parseListFinancialEventGroupsResponse(
'/finances:ListFinancialEventGroupsResponse',
doc,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})

it('should parse the ListFinancialEventGroupsByNextTokenResponse example response from MWS doc', () => {
Expand Down Expand Up @@ -96,12 +96,12 @@ describe('lib.client.parsers.finances.list-financial-event-groups-response', ()
</ListFinancialEventGroupsByNextTokenResponse>`,
)

const res = parseListFinancialEventGroupsResponse(
const response = parseListFinancialEventGroupsResponse(
'/finances:ListFinancialEventGroupsByNextTokenResponse',
doc,
true,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ describe('lib.client.parsers.finances.list-financial-event-groups-response', ()
</ListFinancialEventsResponse>`,
)

const res = parseListFinancialEventsResponse('/finances:ListFinancialEventsResponse', doc)
const response = parseListFinancialEventsResponse('/finances:ListFinancialEventsResponse', doc)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})

it('should parse a ListFinancialEvents example with service fees', () => {
Expand Down Expand Up @@ -497,9 +497,9 @@ describe('lib.client.parsers.finances.list-financial-event-groups-response', ()
</ListFinancialEventsResponse>`,
)

const res = parseListFinancialEventsResponse('/finances:ListFinancialEventsResponse', doc)
const response = parseListFinancialEventsResponse('/finances:ListFinancialEventsResponse', doc)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})

it('should parse the ListFinancialEventsByNextToken example response from MWS doc', () => {
Expand Down Expand Up @@ -674,12 +674,12 @@ describe('lib.client.parsers.finances.list-financial-event-groups-response', ()
</ListFinancialEventsByNextTokenResponse>`,
)

const res = parseListFinancialEventsResponse(
const response = parseListFinancialEventsResponse(
'/finances:ListFinancialEventsByNextTokenResponse',
doc,
true,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ describe('lib.client.parsers.fulfillment-inbound-shipment.get-bill-of-lading-res
</GetBillOfLadingResponse>`,
)

const res = parseGetBillOfLadingResponse(
const response = parseGetBillOfLadingResponse(
'/fulfillmentInboundShipment:GetBillOfLadingResponse',
doc,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ describe('lib.client.parsers.base.get-service-status-response', () => {
</GetServiceStatusResponse>`,
)

const res = parseGetServiceStatusResponse(
const response = parseGetServiceStatusResponse(
'/fulfillmentInboundShipment:GetServiceStatusResponse',
doc,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ describe('lib.client.parsers.fulfillment-inbound-shipment.list-inbound-shipment-
</ListInboundShipmentItemsResponse>`,
)

const res = parseListInboundShipmentItemsResponse(
const response = parseListInboundShipmentItemsResponse(
'/fulfillmentInboundShipment:ListInboundShipmentItemsResponse',
doc,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ describe('lib.client.parsers.fulfillment-inbound-shipment.list-inbound-shipments
</ListInboundShipmentsResponse>`,
)

const res = parseListInboundShipmentsResponse(
const response = parseListInboundShipmentsResponse(
'/fulfillmentInboundShipment:ListInboundShipmentsResponse',
doc,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ describe('lib.client.parsers.base.get-service-status-response', () => {
</GetServiceStatusResponse>`,
)

const res = parseGetServiceStatusResponse('/fulfillmentInventory:GetServiceStatusResponse', doc)
const response = parseGetServiceStatusResponse(
'/fulfillmentInventory:GetServiceStatusResponse',
doc,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ describe('lib.client.parsers.fulfillment-inventory.list-inventory-supply-respons
</ListInventorySupplyResponse>`,
)

const res = parseListInventorySupplyResponse(
const response = parseListInventorySupplyResponse(
'/fulfillmentInventory:ListInventorySupplyResponse',
doc,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})

it('should parse a ListInventorySupplyResponse with a MarketplaceId', () => {
Expand Down Expand Up @@ -103,12 +103,12 @@ describe('lib.client.parsers.fulfillment-inventory.list-inventory-supply-respons
</ListInventorySupplyResponse>`,
)

const res = parseListInventorySupplyResponse(
const response = parseListInventorySupplyResponse(
'/fulfillmentInventory:ListInventorySupplyResponse',
doc,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})

it('should parse the ListInventorySupplyByNextToken example response from MWS doc', () => {
Expand Down Expand Up @@ -147,13 +147,13 @@ describe('lib.client.parsers.fulfillment-inventory.list-inventory-supply-respons
</ListInventorySupplyByNextTokenResponse>`,
)

const res = parseListInventorySupplyResponse(
const response = parseListInventorySupplyResponse(
'/fulfillmentInventory:ListInventorySupplyByNextTokenResponse',
doc,
true,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})

it('should parse a ListInventorySupplyByNextToken with a MarketplaceId', () => {
Expand Down Expand Up @@ -214,12 +214,12 @@ describe('lib.client.parsers.fulfillment-inventory.list-inventory-supply-respons
</ListInventorySupplyByNextTokenResponse>`,
)

const res = parseListInventorySupplyResponse(
const response = parseListInventorySupplyResponse(
'/fulfillmentInventory:ListInventorySupplyByNextTokenResponse',
doc,
true,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
4 changes: 2 additions & 2 deletions __tests__/lib/client/parsers/orders/get-order-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('lib.client.parsers.orders.get-order-response', () => {
</GetOrderResponse>`,
)

const res = parseGetOrderResponse('/orders:GetOrderResponse', doc)
const response = parseGetOrderResponse('/orders:GetOrderResponse', doc)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
4 changes: 2 additions & 2 deletions __tests__/lib/client/parsers/orders/get-service-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ describe('lib.client.parsers.base.get-service-status-response', () => {
</GetServiceStatusResponse>`,
)

const res = parseGetServiceStatusResponse('/orders:GetServiceStatusResponse', doc)
const response = parseGetServiceStatusResponse('/orders:GetServiceStatusResponse', doc)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})
12 changes: 8 additions & 4 deletions __tests__/lib/client/parsers/orders/list-order-items-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ describe('lib.client.parsers.orders.list-order-items-response', () => {
</ListOrderItemsResponse>`,
)

const res = parseListOrderItemsResponse('/orders:ListOrderItemsResponse', doc)
const response = parseListOrderItemsResponse('/orders:ListOrderItemsResponse', doc)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})

it('should parse the ListOrderItemsByNextTokenResponse example response from MWS doc', () => {
Expand Down Expand Up @@ -167,8 +167,12 @@ describe('lib.client.parsers.orders.list-order-items-response', () => {
</ListOrderItemsByNextTokenResponse>`,
)

const res = parseListOrderItemsResponse('/orders:ListOrderItemsByNextTokenResponse', doc, true)
const response = parseListOrderItemsResponse(
'/orders:ListOrderItemsByNextTokenResponse',
doc,
true,
)

expect(res).toMatchSnapshot()
expect(response).toMatchSnapshot()
})
})

0 comments on commit 6d6095b

Please sign in to comment.