2021-10-22 03:43:15 +03:00
|
|
|
import React from 'react';
|
2022-06-06 19:22:05 +03:00
|
|
|
import { render, screen, waitFor } from '@testing-library/react';
|
2022-01-10 18:41:53 +03:00
|
|
|
import { TraceTab } from '../src/StackTraceTab';
|
2020-09-29 16:37:13 +03:00
|
|
|
|
|
|
|
const actions = {
|
|
|
|
0: { type: 'PERFORM_ACTION', action: { type: '@@INIT' } },
|
|
|
|
1: { type: 'PERFORM_ACTION', action: { type: 'INCREMENT_COUNTER' } },
|
|
|
|
2: {
|
|
|
|
type: 'PERFORM_ACTION',
|
|
|
|
action: { type: 'INCREMENT_COUNTER' },
|
|
|
|
stack:
|
|
|
|
'Error\n at fn1 (app.js:72:24)\n at fn2 (app.js:84:31)\n ' +
|
|
|
|
'at fn3 (chrome-extension://lmhkpmbekcpmknklioeibfkpmmfibljd/js/page.bundle.js:1269:80)',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-01-10 18:41:53 +03:00
|
|
|
const TraceTabAsAny = TraceTab as any;
|
2020-09-29 16:37:13 +03:00
|
|
|
|
|
|
|
describe('StackTraceTab component', () => {
|
2021-10-22 03:43:15 +03:00
|
|
|
it('should render with no props', async () => {
|
2022-01-10 18:41:53 +03:00
|
|
|
const { container } = render(<TraceTabAsAny />);
|
2021-10-22 03:43:15 +03:00
|
|
|
await screen.findByTestId('stack-trace');
|
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2020-09-29 16:37:13 +03:00
|
|
|
});
|
|
|
|
|
2021-10-22 03:43:15 +03:00
|
|
|
it('should render with props, but without stack', async () => {
|
|
|
|
const { container } = render(
|
2023-07-12 21:03:20 +03:00
|
|
|
<TraceTabAsAny actions={actions} action={actions[0].action} />,
|
2021-10-22 03:43:15 +03:00
|
|
|
);
|
|
|
|
await screen.findByTestId('stack-trace');
|
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2020-09-29 16:37:13 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render the link to docs', () => {
|
2021-10-22 03:43:15 +03:00
|
|
|
const { container } = render(
|
2023-07-12 21:03:20 +03:00
|
|
|
<TraceTabAsAny actions={actions} action={actions[1].action} />,
|
2021-10-22 03:43:15 +03:00
|
|
|
);
|
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2020-09-29 16:37:13 +03:00
|
|
|
});
|
|
|
|
|
2021-10-22 03:43:15 +03:00
|
|
|
it('should render with trace stack', async () => {
|
|
|
|
const { container } = render(
|
2023-07-12 21:03:20 +03:00
|
|
|
<TraceTabAsAny actions={actions} action={actions[2].action} />,
|
2021-10-22 03:43:15 +03:00
|
|
|
);
|
2022-06-06 19:22:05 +03:00
|
|
|
const stackTraceDiv = await screen.findByTestId('stack-trace');
|
|
|
|
await waitFor(() =>
|
2023-07-12 21:03:20 +03:00
|
|
|
expect(stackTraceDiv.querySelector('div')).toBeTruthy(),
|
2022-06-06 19:22:05 +03:00
|
|
|
);
|
2021-10-22 03:43:15 +03:00
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2020-09-29 16:37:13 +03:00
|
|
|
});
|
|
|
|
});
|