KsqlDb.spec.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React from 'react';
  2. import KsqlDb from 'components/KsqlDb/KsqlDb';
  3. import { render, WithRoute } from 'lib/testHelpers';
  4. import { screen } from '@testing-library/dom';
  5. import {
  6. clusterKsqlDbPath,
  7. clusterKsqlDbQueryPath,
  8. getNonExactPath,
  9. } from 'lib/paths';
  10. const KSqLComponentText = {
  11. list: 'list',
  12. query: 'query',
  13. };
  14. jest.mock('components/KsqlDb/List/List', () => () => (
  15. <div>{KSqLComponentText.list}</div>
  16. ));
  17. jest.mock('components/KsqlDb/Query/Query', () => () => (
  18. <div>{KSqLComponentText.query}</div>
  19. ));
  20. describe('KsqlDb Component', () => {
  21. const clusterName = 'clusterName';
  22. const renderComponent = (path: string) =>
  23. render(
  24. <WithRoute path={getNonExactPath(clusterKsqlDbPath())}>
  25. <KsqlDb />
  26. </WithRoute>,
  27. { initialEntries: [path] }
  28. );
  29. it('Renders the List', () => {
  30. renderComponent(clusterKsqlDbPath(clusterName));
  31. expect(screen.getByText(KSqLComponentText.list)).toBeInTheDocument();
  32. });
  33. it('Renders the List', () => {
  34. renderComponent(clusterKsqlDbQueryPath(clusterName));
  35. expect(screen.getByText(KSqLComponentText.query)).toBeInTheDocument();
  36. });
  37. });