Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should throw an error if httpPost crashes', async () => {
const view = new ElasticSearchView(
orgLabel,
projectLabel,
mockElasticSearchViewResponse,
);
const message = 'some error message';
mockReject(Error(message));
await expect(view.aggregation(mockAggregationQuery)).rejects.toThrow(
Error,
);
});
test('Should have error with invalid url', (done) => {
fetch.mockReject(new Error('Bad Request'));
const component = shallow();
(component.instance() as any).retrieveData().then(() => {
expect(component.state('data')).toEqual([]);
expect(component.state('error')).toBeDefined();
done();
});
});
it('should throw an error if httpPost crashes', async () => {
const view = new ElasticSearchView(
orgLabel,
projectLabel,
mockElasticSearchViewResponse,
);
const myQuery = {};
mockReject(new Error('very bad'));
await expect(view.rawQuery(myQuery)).rejects.toThrow(Error);
});