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

Commit

Permalink
refactor: getReportListByNextToken to be the same
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado authored and moltar committed Jun 28, 2020
1 parent 36ced8c commit dc0ac45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
8 changes: 2 additions & 6 deletions src/sections/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@ const GetReportListResponse = Codec.interface({
}),
})

export interface GetReportListByNextTokenParameters {
NextToken: NextToken<'GetReportList'>
}

const GetReportListByNextTokenResponse = Codec.interface({
GetReportListByNextTokenResponse: Codec.interface({
GetReportListByNextTokenResult: GetReportListResult,
Expand Down Expand Up @@ -460,14 +456,14 @@ export class Reports {
}

async getReportListByNextToken(
parameters: GetReportListByNextTokenParameters,
nextToken: NextToken<'GetReportList'>,
): Promise<[GetReportListResult, RequestMeta]> {
const [response, meta] = await this.httpClient.request('POST', {
resource: Resource.Reports,
version: REPORTS_API_VERSION,
action: 'GetReportListByNextToken',
parameters: {
NextToken: parameters.NextToken.token,
NextToken: nextToken.token,
},
})

Expand Down
14 changes: 4 additions & 10 deletions test/unit/reports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,22 @@ describe('reports', () => {

describe('getReportListByNextToken', () => {
const mockNextToken = new NextToken('GetReportList', '123')
const parameters = {
NextToken: mockNextToken,
}

it('returns report info and next token if succesful', async () => {
expect.assertions(1)

const mockGetReportListByNextToken = createMockHttpClient('reports_get_report_list_nt')

expect(
await mockGetReportListByNextToken.reports.getReportListByNextToken(parameters),
await mockGetReportListByNextToken.reports.getReportListByNextToken(mockNextToken),
).toMatchSnapshot()
})

it('throws a parsing error when the response isn t valid', async () => {
expect.assertions(1)

await expect(() =>
mockMwsFail.reports.getReportListByNextToken(parameters),
mockMwsFail.reports.getReportListByNextToken(mockNextToken),
).rejects.toStrictEqual(new ParsingError(parsingError))
})
})
Expand Down Expand Up @@ -245,9 +242,6 @@ describe('reports', () => {

describe('getReportRequestListByNextToken', () => {
const mockNextToken = new NextToken('GetReportRequestList', '123')
const parameters = {
NextToken: mockNextToken,
}

it('returns report request info if succesful', async () => {
expect.assertions(1)
Expand All @@ -258,7 +252,7 @@ describe('reports', () => {

expect(
await mockGetReportRequestListByNextToken.reports.getReportRequestListByNextToken(
parameters,
mockNextToken,
),
).toMatchSnapshot()
})
Expand All @@ -267,7 +261,7 @@ describe('reports', () => {
expect.assertions(1)

await expect(() =>
mockMwsFail.reports.getReportRequestListByNextToken(parameters),
mockMwsFail.reports.getReportRequestListByNextToken(mockNextToken),
).rejects.toStrictEqual(new ParsingError(parsingError))
})
})
Expand Down

0 comments on commit dc0ac45

Please sign in to comment.