-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added calculateShapeOffsetToXDropCoordinate unit test
- Loading branch information
1 parent
6921724
commit 11dc6d2
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |