Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
logs
/
components
/
log-context
/
File Content:
LogContextButtons.test.tsx
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} onScrollCenterClick={jest.fn()} />); 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} onScrollCenterClick={jest.fn()} wrapLines />); const wrapLinesBox = screen.getByRole('checkbox', { name: 'Wrap lines', }); await userEvent.click(wrapLinesBox); expect(onChangeWrapLines).toHaveBeenCalledTimes(1); expect(onChangeWrapLines).toHaveBeenCalledWith(false); }); it('should call onScrollCenterClick when the button is clicked', async () => { const onScrollCenterClick = jest.fn(); render(<LogContextButtons onChangeWrapLines={jest.fn()} onScrollCenterClick={onScrollCenterClick} />); const scrollButton = screen.getByRole('button'); await userEvent.click(scrollButton); expect(onScrollCenterClick).toHaveBeenCalledTimes(1); }); });
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
LogContextButtons.test.tsx
1606 bytes
0644
LogContextButtons.tsx
1297 bytes
0644
LogRowContextModal.test.tsx
14822 bytes
0644
LogRowContextModal.tsx
21401 bytes
0644
N4ST4R_ID | Naxtarrr