Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('ignores server validation and returns 200', () => {
assertResolvesRight(
prism.request(
{
method: 'get',
url: {
path: '/pet',
},
},
resources
),
result => {
expect(result.output).toBeDefined();
expect(result.output.statusCode).toBe(200);
}
);
});
});
it('returns body text', async () => {
const response = {
headers: new Headers(),
json: jest.fn(),
text: jest.fn().mockResolvedValue('Plavalaguna'),
};
await assertResolvesRight(parseResponseBody(response), body => expect(body).toEqual('Plavalaguna'));
expect(response.json).not.toHaveBeenCalled();
});
});
it(testText, () => {
const op = prism.request(request, resources, config);
errors
? assertResolvesLeft(op, e =>
expect(e).toMatchObject(ProblemJsonError.fromTemplate(NO_PATH_MATCHED_ERROR))
)
: assertResolvesRight(op);
});
});
it('returns parsed response', () => {
return assertResolvesRight(
parseResponse({
status: 200,
headers: new Headers({ 'content-type': 'application/json', test: 'test' }),
json: jest.fn().mockResolvedValue({ test: 'test' }),
text: jest.fn(),
}),
response => {
expect(response).toEqual({
statusCode: 200,
headers: { 'content-type': 'application/json', test: 'test' },
body: { test: 'test' },
});
}
);
});
});