-
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.
test: adding coverage for PUT endpoint error handling
- Loading branch information
1 parent
7836b05
commit 3970905
Showing
1 changed file
with
31 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -387,7 +387,7 @@ describe('rdme openapi', () => { | |
).rejects.toMatchSnapshot(); | ||
}); | ||
|
||
it('should throw an error if an invalid Swagger definition is supplied', async () => { | ||
it('should throw an error if an invalid Swagger definition is supplied (create)', async () => { | ||
const errorObject = { | ||
error: 'INTERNAL_ERROR', | ||
message: 'Unknown error (README VALIDATION ERROR "x-samples-languages" must be of type "Array")', | ||
|
@@ -422,6 +422,36 @@ describe('rdme openapi', () => { | |
return mock.done(); | ||
}); | ||
|
||
it('should throw an error if an invalid Swagger definition is supplied (update)', async () => { | ||
const errorObject = { | ||
error: 'INTERNAL_ERROR', | ||
message: 'Unknown error (README VALIDATION ERROR "x-samples-languages" must be of type "Array")', | ||
suggestion: '...a suggestion to resolve the issue...', | ||
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}; | ||
|
||
const registryUUID = getRandomRegistryId(); | ||
|
||
const mock = getApiNock() | ||
.post('/api/v1/api-registry', body => body.match('form-data; name="spec"')) | ||
.reply(201, { registryUUID, spec: { openapi: '3.0.0' } }) | ||
.put(`/api/v1/api-specification/${id}`, { registryUUID }) | ||
.delayConnection(1000) | ||
.basicAuth({ user: key }) | ||
.reply(400, errorObject); | ||
|
||
await expect( | ||
openapi.run({ | ||
spec: './__tests__/__fixtures__/swagger-with-invalid-extensions.json', | ||
id, | ||
key, | ||
version, | ||
}) | ||
).rejects.toStrictEqual(new APIError(errorObject)); | ||
|
||
return mock.done(); | ||
}); | ||
|
||
it('should throw an error if registry upload fails', async () => { | ||
const errorObject = { | ||
error: 'INTERNAL_ERROR', | ||
|