LogsNavigationPages.test.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { render, screen } from '@testing-library/react';
  2. import React, { ComponentProps } from 'react';
  3. import { LogsNavigationPages } from './LogsNavigationPages';
  4. type LogsNavigationPagesProps = ComponentProps<typeof LogsNavigationPages>;
  5. const setup = (propOverrides?: object) => {
  6. const props: LogsNavigationPagesProps = {
  7. pages: [
  8. {
  9. logsRange: { from: 1619081941000, to: 1619081945930 },
  10. queryRange: { from: 1619081645930, to: 1619081945930 },
  11. },
  12. {
  13. logsRange: { from: 1619081951000, to: 1619081955930 },
  14. queryRange: { from: 1619081655930, to: 1619081955930 },
  15. },
  16. ],
  17. currentPageIndex: 0,
  18. oldestLogsFirst: false,
  19. timeZone: 'local',
  20. loading: false,
  21. changeTime: jest.fn(),
  22. ...propOverrides,
  23. };
  24. return render(<LogsNavigationPages {...props} />);
  25. };
  26. describe('LogsNavigationPages', () => {
  27. it('should render logs navigation pages', () => {
  28. setup();
  29. expect(screen.getByTestId('logsNavigationPages')).toBeInTheDocument();
  30. });
  31. it('should render logs pages with correct range if normal order', () => {
  32. setup();
  33. expect(screen.getByText(/02:59:05 — 02:59:01/i)).toBeInTheDocument();
  34. expect(screen.getByText(/02:59:15 — 02:59:11/i)).toBeInTheDocument();
  35. });
  36. it('should render logs pages with correct range if flipped order', () => {
  37. setup({ oldestLogsFirst: true });
  38. expect(screen.getByText(/02:59:11 — 02:59:15/i)).toBeInTheDocument();
  39. expect(screen.getByText(/02:59:01 — 02:59:05/i)).toBeInTheDocument();
  40. });
  41. });