mirror of
https://github.com/ansible/awx.git
synced 2026-02-15 10:10:01 -03:30
Merge pull request #162 from AlexSCorey/128-UsePFTabs
Add PF's Tabs to Orgs Details page
This commit is contained in:
62
__tests__/components/RoutedTabs.test.jsx
Normal file
62
__tests__/components/RoutedTabs.test.jsx
Normal file
@@ -0,0 +1,62 @@
|
||||
import React from 'react';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import { Router } from 'react-router-dom';
|
||||
import { createMemoryHistory } from 'history';
|
||||
import RoutedTabs, { _RoutedTabs } from '../../src/components/Tabs/RoutedTabs';
|
||||
|
||||
let wrapper;
|
||||
let history;
|
||||
|
||||
const tabs = [
|
||||
{ name: 'Details', link: '/organizations/19/details', id: 1 },
|
||||
{ name: 'Access', link: '/organizations/19/access', id: 2 },
|
||||
{ name: 'Teams', link: '/organizations/19/teams', id: 3 },
|
||||
{ name: 'Notification', link: '/organizations/19/notification', id: 4 }
|
||||
];
|
||||
|
||||
describe('<RoutedTabs />', () => {
|
||||
beforeEach(() => {
|
||||
history = createMemoryHistory({
|
||||
initialEntries: ['/organizations/19/teams'],
|
||||
});
|
||||
});
|
||||
|
||||
test('RoutedTabs renders successfully', () => {
|
||||
wrapper = shallow(
|
||||
<_RoutedTabs
|
||||
tabsArray={tabs}
|
||||
history={history}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.find('Tab')).toHaveLength(4);
|
||||
});
|
||||
|
||||
test('Given a URL the correct tab is active', async () => {
|
||||
wrapper = mount(
|
||||
<Router history={history}>
|
||||
<RoutedTabs
|
||||
tabsArray={tabs}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
expect(history.location.pathname).toEqual('/organizations/19/teams');
|
||||
expect(wrapper.find('Tabs').prop('activeKey')).toBe(3);
|
||||
});
|
||||
|
||||
test('should update history when new tab selected', async () => {
|
||||
wrapper = mount(
|
||||
<Router history={history}>
|
||||
<RoutedTabs
|
||||
tabsArray={tabs}
|
||||
/>
|
||||
</Router>
|
||||
);
|
||||
|
||||
wrapper.find('Tabs').prop('onSelect')({}, 2);
|
||||
wrapper.update();
|
||||
|
||||
expect(history.location.pathname).toEqual('/organizations/19/access');
|
||||
expect(wrapper.find('Tabs').prop('activeKey')).toBe(2);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { I18nProvider } from '@lingui/react';
|
||||
import Organization from '../../../../../src/pages/Organizations/screens/Organization/Organization';
|
||||
|
||||
Reference in New Issue
Block a user