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 handle "notFound" route', done => {
let params = { error: new GenericError() };
spyOn(router._routes, 'get').and.returnValue(route);
spyOn(router, '_handle').and.returnValue(
Promise.resolve({
content: '',
status: 200,
error: params.error
})
);
router
.handleNotFound(params, options)
.then(response => {
expect(router._handle).toHaveBeenCalledWith(route, params, options);
expect(response.error instanceof GenericError).toEqual(true);
it('should return false for client error, which return status 5**', () => {
let isClientError = router.isClientError(
new GenericError('Server error', { status: 500 })
);
expect(isClientError).toEqual(false);
});
it('should return true for redirection, which return status 3**', () => {
let isRedireciton = router.isRedirection(
new GenericError('Redirection', {
status: 300,
url: 'http://www.example.com/redirect'
})
);
expect(isRedireciton).toEqual(true);
});
it('should return true for client error, which return status 4**', () => {
let isClientError = router.isClientError(
new GenericError('Client error', { status: 404 })
);
expect(isClientError).toEqual(true);
});
it('should return true for client error, which return status 4**', () => {
let isRedireciton = router.isRedirection(
new GenericError('Client error', { status: 400 })
);
expect(isRedireciton).toEqual(false);
});
spyOn(proxy, 'request').and.callFake(() => {
return Promise.reject(new GenericError('', data.params));
});