MoveToFolderModal.test.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { render, screen } from '@testing-library/react';
  2. import React from 'react';
  3. import { Provider } from 'react-redux';
  4. import configureMockStore from 'redux-mock-store';
  5. import { MoveToFolderModal } from './MoveToFolderModal';
  6. jest.mock('app/core/components/Select/FolderPicker', () => {
  7. return {
  8. FolderPicker: () => null,
  9. };
  10. });
  11. describe('MoveToFolderModal', () => {
  12. it('should render correct title, body, dismiss-, cancel- and move-text', async () => {
  13. const items = new Map();
  14. const dashboardsUIDs = new Set();
  15. dashboardsUIDs.add('uid1');
  16. dashboardsUIDs.add('uid2');
  17. items.set('dashboard', dashboardsUIDs);
  18. const isMoveModalOpen = true;
  19. const mockStore = configureMockStore<any, any>();
  20. const store = mockStore({ dashboard: { panels: [] } });
  21. const onMoveItems = jest.fn();
  22. render(
  23. <Provider store={store}>
  24. <MoveToFolderModal onMoveItems={onMoveItems} results={items} isOpen={isMoveModalOpen} onDismiss={() => {}} />
  25. </Provider>
  26. );
  27. expect(screen.getByRole('heading', { name: 'Choose Dashboard Folder' })).toBeInTheDocument();
  28. expect(screen.getByText('Move the 2 selected dashboards to the following folder:')).toBeInTheDocument();
  29. expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
  30. expect(screen.getByRole('button', { name: 'Move' })).toBeInTheDocument();
  31. });
  32. });