Skip to content

Commit

Permalink
Add test case for main config
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondyr committed Jan 27, 2025
1 parent 3dfcf71 commit cf6f196
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import userEvent from '@testing-library/user-event';
import { createQueryClientMock } from 'app-shared/mocks/queryClientMock';
import { QueryKey } from 'app-shared/types/QueryKey';
import { app, org } from '@studio/testing/testids';
import { layoutSet1NameMock, layoutSetsMock } from '../../../testing/layoutSetsMock';
import {
layoutSet1NameMock,
layoutSet2NameMock,
layoutSetsMock,
} from '../../../testing/layoutSetsMock';
import { layout1NameMock, layoutMock } from '../../../testing/layoutMock';

const summary2Component: FormItem = {
Expand All @@ -20,6 +24,10 @@ const summary2Component: FormItem = {

describe('ComponentMainConfig', () => {
describe('Summary2', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('should render summary2 config', async () => {
const user = userEvent.setup();
render(summary2Component);
Expand All @@ -46,6 +54,13 @@ describe('ComponentMainConfig', () => {
await user.click(summary2AddOverrideButton());
expect(handleComponentChange).toHaveBeenCalledTimes(1);
});

it('should call handleComponentChange when changing target', async () => {
const user = userEvent.setup();
render(summary2Component);
await user.selectOptions(summary2TargetLayoutSet(), layoutSet2NameMock);
expect(handleComponentChange).toHaveBeenCalledTimes(1);
});
});
});

Expand All @@ -58,6 +73,9 @@ const summary2CollapsedButton = (n: number) =>
name: new RegExp(`ux_editor.component_properties.summary.overrides.nth.*:${n}}`),
});

const summary2TargetLayoutSet = () =>
screen.getByRole('combobox', { name: /ux_editor.component_properties.target_layoutSet_id/ });

const handleComponentChange = jest.fn();
const render = (component: FormItem) => {
const queryClient = createQueryClientMock();
Expand Down

0 comments on commit cf6f196

Please sign in to comment.