-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more validation to Rite Aid API (#547)
- Loading branch information
Showing
11 changed files
with
1,566 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use strict"; | ||
const originalModule = jest.requireActual("../utils"); | ||
|
||
const warningLoggers = {}; | ||
const warnings = []; | ||
|
||
const mock = { | ||
...originalModule, | ||
|
||
createWarningLogger(prefix) { | ||
warningLoggers[prefix] = jest.fn((message) => warnings.push(message)); | ||
return warningLoggers[prefix]; | ||
}, | ||
|
||
// Only for use in tests: get mock function for a logger. | ||
__getWarningLogger(prefix) { | ||
prefix = prefix || Object.keys(warningLoggers).pop(); | ||
return warningLoggers[prefix]; | ||
}, | ||
|
||
// Only for use in tests: get a list of all warnings that were logged. | ||
__getWarnings() { | ||
return warnings; | ||
}, | ||
}; | ||
|
||
module.exports = mock; |
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,12 @@ | ||
const assert = require("assert").strict; | ||
const { HttpApiError } = require("../../exceptions"); | ||
|
||
class RiteAidApiError extends HttpApiError { | ||
parse(response) { | ||
assert.equal(typeof response.body, "object"); | ||
this.details = response.body; | ||
this.message = `${this.details.Status} ${this.details.ErrCde}: ${this.details.ErrMsg}`; | ||
} | ||
} | ||
|
||
module.exports = { RiteAidApiError }; |
Oops, something went wrong.