Address PR review comments.

This commit is contained in:
kialam
2018-11-13 09:53:36 -05:00
parent 44e9d3919d
commit 03f6e52cf1
6 changed files with 18 additions and 18 deletions

View File

@@ -2,7 +2,7 @@ import React from 'react';
import { shallow, mount } from 'enzyme';
import App from '../src/App';
import api from '../src/api';
import * as constant from '../src/endpoints';
import { API_LOGOUT } from '../src/endpoints';
import Dashboard from '../src/pages/Dashboard';
import Login from '../src/pages/Login';
@@ -66,13 +66,13 @@ describe('<App />', () => {
});
test('api.logout called from logout button', async () => {
api.BaseGet = jest.fn().mockImplementation(() => Promise.resolve({}));
api.get = jest.fn().mockImplementation(() => Promise.resolve({}));
const appWrapper = mount(<App />);
const logoutButton = appWrapper.find('LogoutButton');
logoutButton.props().onDevLogout();
appWrapper.setState({ activeGroup: 'foo', activeItem: 'bar' });
expect(api.BaseGet).toHaveBeenCalledTimes(1);
expect(api.BaseGet).toHaveBeenCalledWith(constant.API_LOGOUT);
expect(api.get).toHaveBeenCalledTimes(1);
expect(api.get).toHaveBeenCalledWith(API_LOGOUT);
await asyncFlush();
expect(appWrapper.state().activeItem).toBe(DEFAULT_ACTIVE_ITEM);
expect(appWrapper.state().activeGroup).toBe(DEFAULT_ACTIVE_GROUP);