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

Commit

Permalink
fix: id type used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jun 4, 2020
1 parent c03b8c7 commit 222f26d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/sections/products/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
*/

export type ItemCondition = 'Any' | 'New' | 'Used' | 'Collectible' | 'Refurbished' | 'Club'
type GetMatchingProductIdType = 'ASIN' | 'GCID' | 'SellerSKU' | 'UPC' | 'EAN' | 'ISBN' | 'JAN'
type FeeEstimateIdType = 'ASIN' | 'SellerSKU'
export type GetMatchingProductIdType =
| 'ASIN'
| 'GCID'
| 'SellerSKU'
| 'UPC'
| 'EAN'
| 'ISBN'
| 'JAN'
export type FeeEstimateIdType = 'ASIN' | 'SellerSKU'
export interface MoneyType {
Amount: number | undefined
CurrencyCode: string
Expand Down
16 changes: 9 additions & 7 deletions test/unit/products.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { amazonMarketplaces, HttpClient, ParsingError } from '../../src'
import { MWS } from '../../src/mws'
import { ItemCondition } from '../../src/sections/products/type'
import { GetMatchingProductIdType, ItemCondition } from '../../src/sections/products/type'
import { getFixture } from '../utils'

const httpConfig = {
Expand Down Expand Up @@ -422,23 +422,25 @@ describe('products', () => {
})

describe('getMatchingProductForId', () => {
const parameters = {
MarketplaceId: '',
IdType: 'ASIN' as GetMatchingProductIdType,
IdList: [],
}

it('returns a matching product when the response is valid', async () => {
expect.assertions(1)

expect(
await mockGetMatchingProductForId.products.getMatchingProductForId({
MarketplaceId: '',
IdType: '',
IdList: [],
}),
await mockGetMatchingProductForId.products.getMatchingProductForId(parameters),
).toMatchSnapshot()
})

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

await expect(() =>
mockMwsFail.products.getMatchingProductForId({ MarketplaceId: '', IdType: '', IdList: [] }),
mockMwsFail.products.getMatchingProductForId(parameters),
).rejects.toStrictEqual(new ParsingError(parsingError))
})
})
Expand Down

0 comments on commit 222f26d

Please sign in to comment.