Skip to content

Commit

Permalink
added calculateShapeOffsetToXDropCoordinate unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
gutifer666 committed Aug 11, 2024
1 parent 6921724 commit 11dc6d2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/pods/canvas/use.monitor.business.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { calculateShapeOffsetToXDropCoordinate } from './use-monitor.business';
import { ShapeType } from '@/core/model';
import { getDefaultSizeFromShape } from './canvas.model';

describe('calculateShapeOffsetToXDropCoordinate', () => {
it('should return coordinateX - offset when coordinateX - offset is greater than 0', () => {
// Arrange
const coordinateX = 100;
const shapeType: ShapeType = 'input';
const defaultShapeSize = getDefaultSizeFromShape(shapeType);

// Act
const result = calculateShapeOffsetToXDropCoordinate(
coordinateX,
shapeType
);

// Assert
expect(result).toBe(coordinateX - defaultShapeSize.width / 2);
});

it('should return 0 when coordinateX - offset is less than or equal to 0', () => {
// Arrange
const coordinateX = 20;
const shapeType: ShapeType = 'input';

// Act
const result = calculateShapeOffsetToXDropCoordinate(
coordinateX,
shapeType
);

// Assert
expect(result).toBe(0);
});
});

0 comments on commit 11dc6d2

Please sign in to comment.