mirror of
https://github.com/ansible/awx.git
synced 2026-02-04 02:58:13 -03:30
Update unit tests.
This commit is contained in:
@@ -2,6 +2,8 @@ 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 Dashboard from '../src/pages/Dashboard';
|
||||
import Login from '../src/pages/Login';
|
||||
import { asyncFlush } from '../jest.setup';
|
||||
@@ -64,12 +66,13 @@ describe('<App />', () => {
|
||||
});
|
||||
|
||||
test('api.logout called from logout button', async () => {
|
||||
api.logout = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
api.BaseGet = 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.logout).toHaveBeenCalledTimes(1);
|
||||
expect(api.BaseGet).toHaveBeenCalledTimes(1);
|
||||
expect(api.BaseGet).toHaveBeenCalledWith(constant.API_LOGOUT);
|
||||
await asyncFlush();
|
||||
expect(appWrapper.state().activeItem).toBe(DEFAULT_ACTIVE_ITEM);
|
||||
expect(appWrapper.state().activeGroup).toBe(DEFAULT_ACTIVE_GROUP);
|
||||
|
||||
Reference in New Issue
Block a user