import { quadrangleArea, triangleArea } from './documentDetector'; describe('quadrangleArea', () => { it('should calculate the area of a square', () => { const a = { x: 0, y: 0 }; const b = { x: 0, y: 1 }; const c = { x: 1, y: 1 }; const d = { x: 1, y: 0 }; expect(quadrangleArea([a, b, c, d])).toBe(1); }); it('should calculate the area of a quadrangle', () => { const a = { x: -2, y: 1 }; const b = { x: -1, y: 0 }; const c = { x: 1, y: 1 }; const d = { x: 1, y: 2 }; expect(quadrangleArea([a, b, c, d])).toBe(3); }); }); describe('triangleArea', () => { it('should calculate the area of a right triangle', () => { const a = { x: 0, y: 0 }; const b = { x: 0, y: 1 }; const c = { x: 2, y: 0 }; expect(triangleArea(a, b, c)).toBe(1); }); it('should calculate the area of a triangle', () => { const a = { x: -2, y: 1 }; const b = { x: -1, y: 0 }; const c = { x: 1, y: 1 }; expect(triangleArea(a, b, c)).toBe(1.5); }); });