Skip to content

Commit

Permalink
Adding new cases
Browse files Browse the repository at this point in the history
  • Loading branch information
LourdesRsdp committed Aug 1, 2024
1 parent 6b2781d commit c2484a4
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions src/common/utils/shapes/shape-restrictions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fitSizeToShapeSizeRestrictions } from './shape-restrictions';
import { ShapeSizeRestrictions } from './shape-restrictions';
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions';
import { ShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions';

//Mock data
const restrictions: ShapeSizeRestrictions = {
Expand All @@ -10,14 +10,6 @@ const restrictions: ShapeSizeRestrictions = {
defaultWidth: 100,
defaultHeight: 100,
};
const restrictions2: ShapeSizeRestrictions = {
minWidth: 50,
minHeight: 30,
maxWidth: -1,
maxHeight: -1,
defaultWidth: 100,
defaultHeight: 100,
};

describe('./pods/canvas/canvas.util', () => {
it('should set width to minimum width if width is 0', () => {
Expand Down Expand Up @@ -119,14 +111,45 @@ describe('./pods/canvas/canvas.util', () => {
//Assert
expect(result).toEqual({ width: 50, height: 30 });
});
it('should return width and height as is when maxWidth and maxHeight are -1', () => {
it('should return width and height as is when all bounds are -1', () => {
// Arrange
const width = 400;
const height = 250;
const restrictions2: ShapeSizeRestrictions = {
minWidth: -1,
minHeight: -1,
maxWidth: -1,
maxHeight: -1,
defaultWidth: 100,
defaultHeight: 100,
};

// Act
const result = fitSizeToShapeSizeRestrictions(restrictions2, width, height);

//Assert
expect(result).toEqual({ width: 400, height: 250 });
});
it('should return width and height as is when maxWidth and maxHeight are -1', () => {
// Arrange
const width = 400;
const height = 250;
const defaultShapeSizeRestrictions: ShapeSizeRestrictions = {
minWidth: 0,
minHeight: 0,
maxWidth: -1,
maxHeight: -1,
defaultWidth: 100,
defaultHeight: 100,
};

// Act
const result = fitSizeToShapeSizeRestrictions(
defaultShapeSizeRestrictions,
width,
height
);

//Assert
expect(result).toEqual({ width: 400, height: 250 });
});
Expand Down

0 comments on commit c2484a4

Please sign in to comment.