import { IObject } from 'interfaces' import determineHeight, { MAX_HEIGHT, ASPECT_RATIO } from './determineHeight' describe('determineHeight', () => { it('should return the correct height for a given width', () => { const object: IObject = { id: 'object2', type: 'image', children: [], attributes: { width: 150, height: 200, name: 'object2', x: 0, y: 0 }, layout: {}, } const result = determineHeight(object) expect(result).toBe(100) }) it('should not return a height greater than the maximum height', () => { const object: IObject = { id: 'object3', type: 'image', children: [], attributes: { width: 400, height: 500, name: 'object3', x: 0, y: 0 }, layout: {}, } const result = determineHeight(object) expect(result).toBe(220) }) it('should return the maximum height if the input object does not have a width attribute', () => { const object: IObject = { id: 'object4', type: 'image', children: [], // @ts-ignore attributes: { height: 200, name: 'object4', x: 0, y: 0 }, layout: {}, } const result = determineHeight(object) expect(result).toBe(MAX_HEIGHT) }) it('should return the maximum height if the input width is zero', () => { const object: IObject = { id: 'object6', type: 'image', children: [], attributes: { width: 0, height: 200, name: 'object6', x: 0, y: 0 }, layout: {}, } const result = determineHeight(object) expect(result).toBe(MAX_HEIGHT) }) it('should round the result correctly', () => { const object: IObject = { id: 'object7', type: 'image', children: [], attributes: { width: 199, height: 200, name: 'object7', x: 0, y: 0 }, layout: {}, } const result = determineHeight(object) expect(result).toBe(Math.round(199 * ASPECT_RATIO)) }) })