mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 16:28:43 -03:30
Add unit tests for recent changes to App.jsx.
This commit is contained in:
@@ -3,7 +3,7 @@ import { MemoryRouter } from 'react-router-dom';
|
|||||||
import { shallow, mount } from 'enzyme';
|
import { shallow, mount } from 'enzyme';
|
||||||
import App from '../src/App';
|
import App from '../src/App';
|
||||||
import api from '../src/api';
|
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 Dashboard from '../src/pages/Dashboard';
|
||||||
import Login from '../src/pages/Login';
|
import Login from '../src/pages/Login';
|
||||||
@@ -53,7 +53,13 @@ describe('<App />', () => {
|
|||||||
expect(logOutButton.length).toBe(1);
|
expect(logOutButton.length).toBe(1);
|
||||||
logOutButton.simulate('click');
|
logOutButton.simulate('click');
|
||||||
appWrapper.setState({ activeGroup: 'foo', activeItem: 'bar' });
|
appWrapper.setState({ activeGroup: 'foo', activeItem: 'bar' });
|
||||||
expect(api.get).toHaveBeenCalledTimes(1);
|
|
||||||
expect(api.get).toHaveBeenCalledWith(API_LOGOUT);
|
expect(api.get).toHaveBeenCalledWith(API_LOGOUT);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user