PromucFlow_constructor/app/client/src/layoutSystems/common/dropTarget/DragLayerComponent.test.tsx
Valera Melnikov d7cd02a45d
fix: add testing library eslint rules (#31028)
Added recommended rules for testing library

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added `data-testid` attributes across various components for improved
test identification.

- **Tests**
- Enhanced test cases with asynchronous handling (`async`/`await`) for
more reliable user interaction simulations.
- Transitioned to using `getByTestId` instead of `queryByTestId` for
better assertion reliability in tests.
- Added `await` before the `userEvent.click(el)` statement in the
ChartWidget test file.
- Updated the destructured variable names from `queryByTestId` to
`getByTestId` in the DividerWidget test file for improved clarity.
- Added an import for `screen` from "@testing-library/react" and updated
element querying in the TabsWidget test file.

- **Chores**
- Updated ESLint configurations to include testing-library plugins and
rules, improving code quality and consistency in test files.
- Removed unnecessary `cleanup` function calls after tests, following
best practices for test cleanup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-02-12 18:59:10 +03:00

47 lines
1.3 KiB
TypeScript

import React from "react";
import { ThemeProvider } from "styled-components";
import TestRenderer from "react-test-renderer";
import DragLayerComponent from "./DragLayerComponent";
import { RenderModes } from "constants/WidgetConstants";
import { theme } from "constants/DefaultTheme";
describe("DragLayerComponent", () => {
it("it checks noPad prop", () => {
const dummyWidget = {
type: "CANVAS_WIDGET",
widgetId: "0",
widgetName: "canvas",
parentColumnSpace: 1,
parentRowSpace: 1,
parentRowHeight: 0,
canDropTargetExtend: false,
parentColumnWidth: 0,
leftColumn: 0,
visible: true,
rightColumn: 0,
topRow: 0,
bottomRow: 0,
version: 17,
isLoading: false,
renderMode: RenderModes.CANVAS,
children: [],
noPad: true,
onBoundsUpdate: () => {
//
},
isOver: true,
parentWidgetId: "parent",
force: true,
};
const testRenderer = TestRenderer.create(
<ThemeProvider theme={theme}>
<DragLayerComponent {...dummyWidget} />
</ThemeProvider>,
);
const testInstance = testRenderer.root;
// eslint-disable-next-line testing-library/await-async-queries
expect(testInstance.findByType(DragLayerComponent).props.noPad).toBe(true);
});
});