Files
grafana/public/app/features/logs/components/log-context/LogContextButtons.test.tsx
Gábor Farkas 9ca888527b Logs: Implement "infinite" scrolling in log context (#69459)
* logs: context: allow "infinite" scroll

* Log Context: Add visual changes to infinite scrolling (#70461)

* remove text showing how many log lines are loaded

* better positioning of loading indicators

* add border

* fix import

* better loading states

* improve corner cases

* increase page size 10 => 50

* updated unit test, simplified code

* fixed tests

* updated tests

* removed unused code

* fixed test

* improved refid-handling in loki

* removed unnecessary code

* better variable name

* refactor

* refactor

---------

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
2023-06-28 11:51:16 +03:00

30 lines
1.1 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { LogContextButtons } from './LogContextButtons';
describe('LogContextButtons', () => {
it('should call onChangeWrapLines when the checkbox is used, case 1', async () => {
const onChangeWrapLines = jest.fn();
render(<LogContextButtons onChangeWrapLines={onChangeWrapLines} />);
const wrapLinesBox = screen.getByRole('checkbox', {
name: 'Wrap lines',
});
await userEvent.click(wrapLinesBox);
expect(onChangeWrapLines).toHaveBeenCalledTimes(1);
expect(onChangeWrapLines).toHaveBeenCalledWith(true);
});
it('should call onChangeWrapLines when the checkbox is used, case 2', async () => {
const onChangeWrapLines = jest.fn();
render(<LogContextButtons onChangeWrapLines={onChangeWrapLines} wrapLines />);
const wrapLinesBox = screen.getByRole('checkbox', {
name: 'Wrap lines',
});
await userEvent.click(wrapLinesBox);
expect(onChangeWrapLines).toHaveBeenCalledTimes(1);
expect(onChangeWrapLines).toHaveBeenCalledWith(false);
});
});