webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js in katello-3.13.4 vs webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js in katello-3.14.0.rc1
- old
+ new
@@ -1,14 +1,15 @@
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import { loadSetting } from 'foremanReact/components/Settings/SettingsActions';
import SubscriptionsPage from '../SubscriptionsPage';
-import { successState, settingsSuccessState } from './subscriptions.fixtures';
+import { successState, settingsSuccessState, permissionDeniedState } from './subscriptions.fixtures';
import { loadSubscriptions, updateQuantity, loadTableColumns } from '../SubscriptionActions';
import { createColumns, updateColumns } from '../../../scenes/Settings/Tables/TableActions';
+jest.mock('foremanReact/components/PermissionDenied');
jest.mock('foremanReact/components/Pagination/PaginationWrapper', () => (<div>Pagination Mock</div>));
const loadTables = () => new Promise((resolve) => {
resolve();
});
@@ -43,11 +44,44 @@
closeTaskModal={noop}
disableDeleteButton={noop}
enableDeleteButton={noop}
/>);
+ const permissionDeniedPage = shallow(<SubscriptionsPage
+ organization={organization}
+ subscriptions={permissionDeniedState}
+ subscriptionTableSettings={settingsSuccessState}
+ loadSetting={loadSetting}
+ loadTables={loadTables}
+ loadTableColumns={loadTableColumns}
+ createColumns={createColumns}
+ updateColumns={updateColumns}
+ loadSubscriptions={loadSubscriptions}
+ updateQuantity={updateQuantity}
+ pollTaskUntilDone={noop}
+ pollBulkSearch={noop}
+ deleteSubscriptions={() => {}}
+ resetTasks={noop}
+ uploadManifest={noop}
+ deleteManifest={noop}
+ refreshManifest={noop}
+ updateSearchQuery={noop}
+ openManageManifestModal={noop}
+ closeManageManifestModal={noop}
+ openDeleteModal={noop}
+ closeDeleteModal={noop}
+ openTaskModal={noop}
+ closeTaskModal={noop}
+ disableDeleteButton={noop}
+ enableDeleteButton={noop}
+ />);
+
it('should render', async () => {
expect(toJson(page)).toMatchSnapshot();
+ });
+
+ it('should render <PermissionDenied /> when permissions are missing', async () => {
+ expect(toJson(permissionDeniedPage)).toMatchSnapshot();
});
it('should poll tasks when org changes', async () => {
jest.spyOn(page.instance(), 'pollTasks');