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.
fix: unit test utils, finances and fulfillment inv unit tests
- Loading branch information
1 parent
f08cb36
commit d1b37a7
Showing
3 changed files
with
52 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,41 @@ | ||
import { readFileSync } from 'fs' | ||
import { join } from 'path' | ||
|
||
import { amazonMarketplaces, HttpClient, MWS } from '../src' | ||
|
||
const httpConfig = { | ||
awsAccessKeyId: '', | ||
marketplace: amazonMarketplaces.CA, | ||
mwsAuthToken: '', | ||
secretKey: '', | ||
sellerId: '', | ||
} | ||
|
||
const headers = { | ||
'x-mws-request-id': '0', | ||
'x-mws-timestamp': '2020-05-06T09:22:23.582Z', | ||
'x-mws-quota-max': '1000', | ||
'x-mws-quota-remaining': '999', | ||
'x-mws-quota-resetson': '2020-04-06T10:22:23.582Z', | ||
} | ||
|
||
export const getFixture = (filename: string): string => | ||
readFileSync(join(__dirname, `unit/__fixtures__/${filename}.xml`), { encoding: 'utf8' }) | ||
|
||
export const createMockHttpClient = (fixture: string) => | ||
new MWS( | ||
new HttpClient(httpConfig, () => | ||
Promise.resolve({ | ||
data: getFixture(fixture), | ||
headers, | ||
}), | ||
), | ||
) | ||
|
||
export const mockMwsFail = new MWS( | ||
new HttpClient(httpConfig, () => Promise.resolve({ data: '', headers: {} })), | ||
) | ||
|
||
export const parsingError = 'Expected an object, but received a string with value ""' | ||
|
||
export const mockMwsServiceStatus = createMockHttpClient('get_service_status') |