Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('returns error', async () => {
const response = {
headers: new Headers({ 'content-type': 'application/json' }),
json: jest.fn().mockRejectedValue(new Error('Big Bada Boom')),
text: jest.fn(),
};
await assertResolvesLeft(parseResponseBody(response), error => expect(error.message).toEqual('Big Bada Boom'));
expect(response.text).not.toHaveBeenCalled();
});
});
it('returns error', () => {
return assertResolvesLeft(
parseResponse({
status: 200,
headers: new Headers(),
json: jest.fn(),
text: jest.fn().mockRejectedValue(new Error('Big Bada Boom')),
}),
error => {
expect(error.message).toEqual('Big Bada Boom');
}
);
});
});
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 an error if the the header is missing', () => {
assertResolvesLeft(
prism.request(
{
method: 'get',
url: {
path: '/pet/login',
},
},
resources
)
);
});
});