ConfirmDeleteModal.test.tsx 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { render, screen, within } from '@testing-library/react';
  2. import React from 'react';
  3. import { ConfirmDeleteModal } from './ConfirmDeleteModal';
  4. describe('ConfirmModal', () => {
  5. it('should render correct title, body, dismiss-, cancel- and delete-text', () => {
  6. const items = new Map();
  7. const dashboardsUIDs = new Set();
  8. dashboardsUIDs.add('uid1');
  9. dashboardsUIDs.add('uid2');
  10. items.set('dashboard', dashboardsUIDs);
  11. const isDeleteModalOpen = true;
  12. const onDeleteItems = jest.fn();
  13. render(
  14. <ConfirmDeleteModal
  15. onDeleteItems={onDeleteItems}
  16. results={items}
  17. isOpen={isDeleteModalOpen}
  18. onDismiss={() => {}}
  19. />
  20. );
  21. expect(screen.getByRole('heading', { name: 'Delete' })).toBeInTheDocument();
  22. expect(screen.getByText('Do you want to delete the 2 selected dashboards?')).toBeInTheDocument();
  23. expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
  24. const button = screen.getByRole('button', { name: 'Confirm Modal Danger Button' });
  25. expect(within(button).getByText('Delete')).toBeInTheDocument();
  26. });
  27. });