mirror of
https://github.com/ansible/awx.git
synced 2026-02-04 02:58:13 -03:30
decouple App and Login components
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import React from 'react';
|
||||
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, API_CONFIG } from '../src/endpoints';
|
||||
|
||||
import Dashboard from '../src/pages/Dashboard';
|
||||
import Login from '../src/pages/Login';
|
||||
import { asyncFlush } from '../jest.setup';
|
||||
|
||||
const DEFAULT_ACTIVE_GROUP = 'views_group';
|
||||
@@ -24,30 +24,6 @@ describe('<App />', () => {
|
||||
expect(appWrapper.length).toBe(1);
|
||||
});
|
||||
|
||||
test('renders login page when not authenticated', () => {
|
||||
api.isAuthenticated = jest.fn();
|
||||
api.isAuthenticated.mockReturnValue(false);
|
||||
|
||||
const appWrapper = mount(<Router><App /></Router>);
|
||||
|
||||
const login = appWrapper.find(Login);
|
||||
expect(login.length).toBe(1);
|
||||
const dashboard = appWrapper.find(Dashboard);
|
||||
expect(dashboard.length).toBe(0);
|
||||
});
|
||||
|
||||
test('renders dashboard when authenticated', () => {
|
||||
api.isAuthenticated = jest.fn();
|
||||
api.isAuthenticated.mockReturnValue(true);
|
||||
|
||||
const appWrapper = mount(<Router><App routeGroups={routeGroups} /></Router>);
|
||||
|
||||
const dashboard = appWrapper.find(Dashboard);
|
||||
expect(dashboard.length).toBe(1);
|
||||
const login = appWrapper.find(Login);
|
||||
expect(login.length).toBe(0);
|
||||
});
|
||||
|
||||
test('onNavToggle sets state.isNavOpen to opposite', () => {
|
||||
const appWrapper = shallow(<App />);
|
||||
expect(appWrapper.state().isNavOpen).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user