Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions packages/http/src/validator/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,62 @@ describe('HttpValidator', () => {
});
});

describe('when media type is found', () => {
it('should validate the output of the found media type', () => {
assertLeft(
validator.validateOutput({
resource: {
method: 'get',
path: '/',
id: '1',
request: {},
responses: [
{
id: faker.random.word(),
code: '200',
contents: [
{
id: faker.random.word(),
mediaType: 'application/json',
},
{
id: faker.random.word(),
mediaType: 'application/required+json',
schema: {
type: 'object',
description: '',
additionalProperties: false,
properties: {
required_property: {
type: 'boolean',
},
},
required: ['required_property'],
},
},
],
},
],
},
element: {
statusCode: 200,
headers: { 'content-type': 'application/required+json' },
body: {},
},
}),
e =>
expect(e).toEqual([
{
code: 'required',
message: "Response body must have required property 'required_property'",
path: ['body'],
severity: 0,
},
])
);
});
});

describe('cannot match status code with responses', () => {
beforeEach(() => {
jest.spyOn(validators, 'validateBody').mockReturnValue(E.right({}));
Expand Down