This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5143ac4
commit c7f36ab
Showing
6 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { HttpClient, Resource } from '../http' | ||
import { getServiceStatusByResource } from './shared' | ||
|
||
const SELLERS_API_VERSION = '2018-11-01' | ||
|
||
export class ShipmentInvoicing { | ||
constructor(private httpClient: HttpClient) {} | ||
|
||
async getServiceStatus() { | ||
return getServiceStatusByResource( | ||
this.httpClient, | ||
Resource.ShipmentInvoicing, | ||
SELLERS_API_VERSION, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ShipmentInvoicing } from '../../src' | ||
import { Config } from './config' | ||
import { itci } from './it' | ||
|
||
const httpClient = new Config().createHttpClient() | ||
|
||
/* eslint-disable jest/no-standalone-expect */ | ||
describe(`${ShipmentInvoicing.name}`, () => { | ||
itci('should be able to query service status', async () => { | ||
expect.assertions(1) | ||
|
||
const shipmentInvoicing = new ShipmentInvoicing(httpClient) | ||
|
||
const [response] = await shipmentInvoicing.getServiceStatus() | ||
|
||
expect(response.Status).toMatch(/GREEN|YELLOW|RED/) | ||
}) | ||
}) | ||
/* eslint-enable jest/no-standalone-expect */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ParsingError } from '../../src' | ||
import { mockMwsFail, mockMwsServiceStatus, parsingError } from '../utils' | ||
|
||
describe('shipmentInvoicing', () => { | ||
describe('getServiceStatus', () => { | ||
it('returns a parsed model when the status response is valid', async () => { | ||
expect.assertions(1) | ||
|
||
expect(await mockMwsServiceStatus.sellers.getServiceStatus()).toMatchSnapshot() | ||
}) | ||
|
||
it('throws a parsing error when the status response is not valid', async () => { | ||
expect.assertions(1) | ||
|
||
await expect(() => mockMwsFail.shipmentInvoicing.getServiceStatus()).rejects.toStrictEqual( | ||
new ParsingError(parsingError), | ||
) | ||
}) | ||
}) | ||
}) |