AddPanelWidget.test.tsx 966 B

12345678910111213141516171819202122232425262728293031
  1. import { render, screen } from '@testing-library/react';
  2. import React from 'react';
  3. import { DashboardModel, PanelModel } from '../../state';
  4. import { AddPanelWidgetUnconnected as AddPanelWidget, Props } from './AddPanelWidget';
  5. const getTestContext = (propOverrides?: object) => {
  6. const props: Props = {
  7. dashboard: new DashboardModel({}),
  8. panel: new PanelModel({}),
  9. addPanel: jest.fn() as any,
  10. };
  11. Object.assign(props, propOverrides);
  12. return render(<AddPanelWidget {...props} />);
  13. };
  14. describe('AddPanelWidget', () => {
  15. it('should render component without error', () => {
  16. expect(() => {
  17. getTestContext();
  18. });
  19. });
  20. it('should render the add panel actions', () => {
  21. getTestContext();
  22. expect(screen.getByText(/Add a new panel/i)).toBeInTheDocument();
  23. expect(screen.getByText(/Add a new row/i)).toBeInTheDocument();
  24. expect(screen.getByText(/Add a panel from the panel library/i)).toBeInTheDocument();
  25. });
  26. });