mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
Add unit tests for recent changes to App.jsx.
This commit is contained in:
parent
4eb04b6f5c
commit
aaa9096b4e
@ -3,7 +3,7 @@ import { HashRouter as Router } from 'react-router-dom';
|
||||
import { shallow, mount } from 'enzyme';
|
||||
import App from '../src/App';
|
||||
import api from '../src/api';
|
||||
import { API_LOGOUT } from '../src/endpoints';
|
||||
import { API_LOGOUT, API_CONFIG } from '../src/endpoints';
|
||||
|
||||
import Dashboard from '../src/pages/Dashboard';
|
||||
import Login from '../src/pages/Login';
|
||||
@ -63,10 +63,16 @@ describe('<App />', () => {
|
||||
const appWrapper = shallow(<App.WrappedComponent />);
|
||||
appWrapper.instance().onDevLogout();
|
||||
appWrapper.setState({ activeGroup: 'foo', activeItem: 'bar' });
|
||||
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);
|
||||
});
|
||||
|
||||
test('Componenet makes REST call to API_CONFIG endpoint when mounted', () => {
|
||||
api.get = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
const appWrapper = shallow(<App.WrappedComponent />);
|
||||
expect(api.get).toHaveBeenCalledTimes(1);
|
||||
expect(api.get).toHaveBeenCalledWith(API_CONFIG);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user