componentWithQualifier = this.addQualifier({ ...nav, ...component });
} catch (e) {
if (this.mounted) {
- if (e && e.status === HttpStatus.Forbidden) {
+ if (e && e instanceof Response && e.status === HttpStatus.Forbidden) {
this.props.requireAuthorization(this.props.router);
} else {
this.setState({ component: undefined, loading: false });
import { mockBranch, mockMainBranch, mockPullRequest } from '../../../helpers/mocks/branch-like';
import { mockComponent } from '../../../helpers/mocks/component';
import { mockTask } from '../../../helpers/mocks/tasks';
+import { HttpStatus } from '../../../helpers/request';
import { mockAppState, mockLocation, mockRouter } from '../../../helpers/testMocks';
import { waitAndUpdate } from '../../../helpers/testUtils';
import { AlmKeys } from '../../../types/alm-settings';
});
it('should show component not found if it does not exist', async () => {
- (getComponentNavigation as jest.Mock).mockRejectedValueOnce({ status: 404 });
+ (getComponentNavigation as jest.Mock).mockRejectedValueOnce(
+ new Response(null, { status: HttpStatus.NotFound })
+ );
const wrapper = shallowRender();
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot();
});
it('should redirect if the user has no access', async () => {
- (getComponentNavigation as jest.Mock).mockRejectedValueOnce({ status: 403 });
+ (getComponentNavigation as jest.Mock).mockRejectedValueOnce(
+ new Response(null, { status: HttpStatus.Forbidden })
+ );
const requireAuthorization = jest.fn();
const wrapper = shallowRender({ requireAuthorization });
await waitAndUpdate(wrapper);