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
105415e
commit 00cdc9a
Showing
7 changed files
with
90 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 RECOMMENDATIONS_API_VERSION = '2013-04-01' | ||
|
||
export class Recommendations { | ||
constructor(private httpClient: HttpClient) {} | ||
|
||
async getServiceStatus() { | ||
return getServiceStatusByResource( | ||
this.httpClient, | ||
Resource.Recommendations, | ||
RECOMMENDATIONS_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 { Recommendations } from '../../src' | ||
import { Config } from './config' | ||
import { itci } from './it' | ||
|
||
const httpClient = new Config().createHttpClient() | ||
|
||
/* eslint-disable jest/no-standalone-expect */ | ||
describe(`${Recommendations.name}`, () => { | ||
itci('should be able to query service status', async () => { | ||
expect.assertions(1) | ||
|
||
const recommendations = new Recommendations(httpClient) | ||
|
||
const [response] = await recommendations.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,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`recommendations getServiceStatus returns a parsed model when the status response is valid 1`] = ` | ||
Array [ | ||
Object { | ||
"Status": "GREEN", | ||
"Timestamp": "2020-05-06T08:22:23.582Z", | ||
}, | ||
Object { | ||
"quotaMax": 1000, | ||
"quotaRemaining": 999, | ||
"quotaResetOn": 2020-04-06T10:22:23.582Z, | ||
"requestId": "0", | ||
"timestamp": 2020-05-06T09:22:23.582Z, | ||
}, | ||
] | ||
`; |
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('recommendations', () => { | ||
describe('getServiceStatus', () => { | ||
it('returns a parsed model when the status response is valid', async () => { | ||
expect.assertions(1) | ||
|
||
expect(await mockMwsServiceStatus.recommendations.getServiceStatus()).toMatchSnapshot() | ||
}) | ||
|
||
it('throws a parsing error when the status response is not valid', async () => { | ||
expect.assertions(1) | ||
|
||
await expect(() => mockMwsFail.recommendations.getServiceStatus()).rejects.toStrictEqual( | ||
new ParsingError(parsingError), | ||
) | ||
}) | ||
}) | ||
}) |