1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import React from 'react';
- import {shallow, mountWithTheme} from 'sentry-test/enzyme';
- import {Client} from 'app/api';
- import AccountIdentities from 'app/views/settings/account/accountIdentities';
- const ENDPOINT = '/users/me/social-identities/';
- describe('AccountIdentities', function() {
- beforeEach(function() {
- Client.clearMockResponses();
- });
- it('renders empty', function() {
- Client.addMockResponse({
- url: ENDPOINT,
- method: 'GET',
- body: [],
- });
- const wrapper = shallow(<AccountIdentities />, TestStubs.routerContext());
- expect(wrapper).toMatchSnapshot();
- });
- it('renders list', function() {
- Client.addMockResponse({
- url: ENDPOINT,
- method: 'GET',
- body: [
- {
- id: '1',
- provider: 'github',
- providerLabel: 'GitHub',
- },
- ],
- });
- const wrapper = shallow(<AccountIdentities />, TestStubs.routerContext());
- expect(wrapper).toMatchSnapshot();
- });
- it('disconnects identity', function() {
- Client.addMockResponse({
- url: ENDPOINT,
- method: 'GET',
- body: [
- {
- id: '1',
- provider: 'github',
- providerLabel: 'GitHub',
- },
- ],
- });
- const wrapper = mountWithTheme(<AccountIdentities />, TestStubs.routerContext());
- const disconnectRequest = {
- url: `${ENDPOINT}1/`,
- method: 'DELETE',
- };
- const mock = Client.addMockResponse(disconnectRequest);
- expect(mock).not.toHaveBeenCalled();
- wrapper
- .find('Button')
- .first()
- .simulate('click');
- expect(mock).toHaveBeenCalledTimes(1);
- expect(mock).toHaveBeenCalledWith(
- `${ENDPOINT}1/`,
- expect.objectContaining({
- method: 'DELETE',
- })
- );
- });
- });
|