feat(backend-git-gateway): handle identity disabled error message (#3002)

This commit is contained in:
Erez Rokah
2020-01-06 21:10:37 +02:00
committed by Shawn Erquhart
parent b54d42fcfe
commit b5ffccdac5
5 changed files with 428 additions and 11 deletions

View File

@ -0,0 +1,42 @@
import React from 'react';
import { Map } from 'immutable';
import { render } from '@testing-library/react';
window.netlifyIdentity = {
currentUser: jest.fn(),
on: jest.fn(),
close: jest.fn(),
};
describe('GitGatewayAuthenticationPage', () => {
const props = {
config: Map({ logo_url: 'logo_url' }),
t: jest.fn(key => key),
onLogin: jest.fn(),
inProgress: false,
};
beforeEach(() => {
jest.clearAllMocks();
jest.resetModules();
});
it('should render with identity error', () => {
const { default: GitGatewayAuthenticationPage } = require('../AuthenticationPage');
const { asFragment } = render(<GitGatewayAuthenticationPage {...props} />);
const errorCallback = window.netlifyIdentity.on.mock.calls.find(call => call[0] === 'error')[1];
errorCallback(
new Error('Failed to load settings from https://site.netlify.com/.netlify/identity'),
);
expect(asFragment()).toMatchSnapshot();
});
it('should render with no identity error', () => {
const { default: GitGatewayAuthenticationPage } = require('../AuthenticationPage');
const { asFragment } = render(<GitGatewayAuthenticationPage {...props} />);
expect(asFragment()).toMatchSnapshot();
});
});

File diff suppressed because one or more lines are too long