-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tests and modify error response message
SL-732
- Loading branch information
Chris Miaskowski
committed
Dec 17, 2018
1 parent
f4d8b1e
commit 73db545
Showing
7 changed files
with
181 additions
and
106 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
packages/http/src/__tests__/__snapshots__/http-prism-instance.spec.ts.snap
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,64 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Http Prism Instance function tests given correct route should return correct response 1`] = ` | ||
Object { | ||
"input": Object { | ||
"method": "get", | ||
"url": Object { | ||
"path": "/pet/findByStatus", | ||
"query": Object { | ||
"status": Array [ | ||
"available", | ||
"pending", | ||
], | ||
}, | ||
}, | ||
}, | ||
"output": Object { | ||
"headers": Object { | ||
"Content-type": "application/json", | ||
}, | ||
"statusCode": 200, | ||
}, | ||
"validations": Object { | ||
"input": Array [], | ||
"output": Array [], | ||
}, | ||
} | ||
`; | ||
|
||
exports[`Http Prism Instance function tests given route with invalid param should return a validation error 1`] = ` | ||
Object { | ||
"input": Object { | ||
"method": "get", | ||
"url": Object { | ||
"path": "/pet/findByStatus", | ||
}, | ||
}, | ||
"output": Object { | ||
"body": "ERROR: Your request is not valid. | ||
We cannot generate a sensible response because your '400' | ||
response has neither example nor schema or is not defined. | ||
Here is the original validation result instead: [{\\"path\\":[\\"query\\",\\"status\\"],\\"name\\":\\"required\\",\\"summary\\":\\"\\",\\"message\\":\\"Missing status query param\\",\\"severity\\":\\"error\\"}]", | ||
"headers": Object { | ||
"Content-type": "text/plain", | ||
}, | ||
"statusCode": 400, | ||
}, | ||
"validations": Object { | ||
"input": Array [ | ||
Object { | ||
"message": "Missing status query param", | ||
"name": "required", | ||
"path": Array [ | ||
"query", | ||
"status", | ||
], | ||
"severity": "error", | ||
"summary": "", | ||
}, | ||
], | ||
"output": Array [], | ||
}, | ||
} | ||
`; |
28 changes: 0 additions & 28 deletions
28
packages/http/src/__tests__/__snapshots__/httpPrismInstance.spec.ts.snap
This file was deleted.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
packages/http/src/__tests__/fixtures/no-refs-petstore-minimal.oas2.json
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,87 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"title": "Swagger Petstore" | ||
}, | ||
"host": "petstore.swagger.io", | ||
"basePath": "/v2", | ||
"tags": [], | ||
"schemes": ["https", "http"], | ||
"paths": { | ||
"/pet/findByStatus": { | ||
"get": { | ||
"tags": ["pet"], | ||
"summary": "Finds Pets by status", | ||
"operationId": "findPetsByStatus", | ||
"produces": ["application/xml", "application/json"], | ||
"parameters": [ | ||
{ | ||
"name": "status", | ||
"in": "query", | ||
"description": "Status values that need to be considered for filter", | ||
"required": true, | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"enum": ["available", "pending", "sold"], | ||
"default": "available" | ||
}, | ||
"collectionFormat": "multi" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "successful operation", | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"required": ["name", "photoUrls"], | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"example": "doggie" | ||
}, | ||
"photoUrls": { | ||
"type": "array", | ||
"xml": { | ||
"name": "photoUrl", | ||
"wrapped": true | ||
}, | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"400": { | ||
"description": "Invalid status value" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"petstore_auth": ["write:pets", "read:pets"] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"securityDefinitions": { | ||
"petstore_auth": { | ||
"type": "oauth2", | ||
"authorizationUrl": "https://petstore.swagger.io/oauth/dialog", | ||
"flow": "implicit", | ||
"scopes": { | ||
"write:pets": "modify pets in your account", | ||
"read:pets": "read your pets" | ||
} | ||
}, | ||
"api_key": { | ||
"type": "apiKey", | ||
"name": "api_key", | ||
"in": "header" | ||
} | ||
} | ||
} |
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