grafana/public/app/features/explore/LogsNavigationPages.test.tsx
Josh Hunt 3c6e0e8ef8
Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

47 lines
1.5 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import React, { ComponentProps } from 'react';
import { LogsNavigationPages } from './LogsNavigationPages';
type LogsNavigationPagesProps = ComponentProps<typeof LogsNavigationPages>;
const setup = (propOverrides?: object) => {
const props: LogsNavigationPagesProps = {
pages: [
{
logsRange: { from: 1619081941000, to: 1619081945930 },
queryRange: { from: 1619081645930, to: 1619081945930 },
},
{
logsRange: { from: 1619081951000, to: 1619081955930 },
queryRange: { from: 1619081655930, to: 1619081955930 },
},
],
currentPageIndex: 0,
oldestLogsFirst: false,
timeZone: 'local',
loading: false,
changeTime: jest.fn(),
...propOverrides,
};
return render(<LogsNavigationPages {...props} />);
};
describe('LogsNavigationPages', () => {
it('should render logs navigation pages', () => {
setup();
expect(screen.getByTestId('logsNavigationPages')).toBeInTheDocument();
});
it('should render logs pages with correct range if normal order', () => {
setup();
expect(screen.getByText(/02:59:05 — 02:59:01/i)).toBeInTheDocument();
expect(screen.getByText(/02:59:15 — 02:59:11/i)).toBeInTheDocument();
});
it('should render logs pages with correct range if flipped order', () => {
setup({ oldestLogsFirst: true });
expect(screen.getByText(/02:59:11 — 02:59:15/i)).toBeInTheDocument();
expect(screen.getByText(/02:59:01 — 02:59:05/i)).toBeInTheDocument();
});
});