-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(docs): consolidate logic (#540)
* refactor(docs): consolidate logic * chore: slightly more debugging info * test: more coverage In the process of writing more coverage, I realized that we didn't wrap an error properly and it was just returning raw JSON. Yay tests!
- Loading branch information
1 parent
c7e53a2
commit 9d9e40c
Showing
5 changed files
with
158 additions
and
199 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -682,6 +682,41 @@ describe('rdme docs:single', () => { | |
postMock.done(); | ||
versionMock.done(); | ||
}); | ||
|
||
it('should fail if some other error when retrieving page slug', async () => { | ||
const slug = 'fail-doc'; | ||
|
||
const errorObject = { | ||
error: 'INTERNAL_ERROR', | ||
message: 'Unknown error (yikes)', | ||
suggestion: '...a suggestion to resolve the issue...', | ||
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}; | ||
|
||
const getMock = getNockWithVersionHeader(version) | ||
.get(`/api/v1/docs/${slug}`) | ||
.basicAuth({ user: key }) | ||
.reply(500, errorObject); | ||
|
||
const versionMock = getApiNock() | ||
.get(`/api/v1/version/${version}`) | ||
.basicAuth({ user: key }) | ||
.reply(200, { version }); | ||
|
||
const filepath = './__tests__/__fixtures__/failure-docs/fail-doc.md'; | ||
|
||
const formattedErrorObject = { | ||
...errorObject, | ||
message: `Error uploading ${chalk.underline(`${filepath}`)}:\n\n${errorObject.message}`, | ||
}; | ||
|
||
await expect(docsSingle.run({ filepath: `${filepath}`, key, version })).rejects.toStrictEqual( | ||
new APIError(formattedErrorObject) | ||
); | ||
|
||
getMock.done(); | ||
versionMock.done(); | ||
}); | ||
}); | ||
|
||
describe('slug metadata', () => { | ||
|
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
Oops, something went wrong.