Skip to content

Commit

Permalink
chore: fix failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gkuzin13 committed Feb 19, 2024
1 parent 88fa7e0 commit d85564d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 13 additions & 5 deletions apps/client/src/__tests__/cursor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ARROW_TRANSFORMER } from '@/constants/shape';
import { stateGenerator } from '@/test/data-generators';
import { findCanvas, renderWithProviders } from '@/test/test-utils';
import { createNode } from '@/utils/node';
import { screen, waitFor } from '@testing-library/react';
import { act, screen, waitFor } from '@testing-library/react';
import Konva from 'konva';
import type { NodeType } from 'shared';

Expand Down Expand Up @@ -143,12 +143,16 @@ describe('cursor', () => {
const { container } = await findCanvas();

// fire dragStart event
Konva.stages[0].fire('dragstart');
await act(async () => {
Konva.stages[0].fire('dragstart');
});

expect(container.style.cursor).toBe('grabbing');

// fire dragEnd event
Konva.stages[0].fire('dragend');
await act(async () => {
Konva.stages[0].fire('dragend');
});

expect(container.style.cursor).toBe('grab');
});
Expand All @@ -163,12 +167,16 @@ describe('cursor', () => {
const { container } = await findCanvas();

// fire dragStart event
Konva.stages[0].fire('dragstart');
await act(async () => {
Konva.stages[0].fire('dragstart');
});

expect(container.style.cursor).toBe('all-scroll');

// fire dragEnd event
Konva.stages[0].fire('dragend');
await act(async () => {
Konva.stages[0].fire('dragend');
});

expect(container.style.cursor).toBe('');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ const NodesTransformer = ({
}, [selectedNodes, onlySingleNode]);

useEffect(() => {
if (!transformerRef.current) {
const transformer = transformerRef.current;
const layer = transformer?.getLayer();

if (!transformer || !layer) {
return;
}

const layer = transformerRef.current.getLayer() as Konva.Layer;
const nodeIds = new Set(selectedNodes.map(({ nodeProps }) => nodeProps.id));
const nodes = layer.find((node: Konva.Node) => nodeIds.has(node.id()));

Expand Down

0 comments on commit d85564d

Please sign in to comment.