import { calcMarginSize } from '../../src/utils/ElementUtils'; import { OverflowDirection } from '../../src'; describe('calcMarginSize', () => { it('should calculate correctly the size of horizontal margin', () => { const element = document.createElement('div'); element.style.marginLeft = '10px'; element.style.marginRight = '15px'; document.body.appendChild(element); const size = calcMarginSize(element, OverflowDirection.HORIZONTAL); expect(size).toBe(25); }); it('should calculate correctly the size of vertical margin', () => { const element = document.createElement('div'); element.style.marginTop = '5px'; element.style.marginBottom = '20px'; document.body.appendChild(element); const size = calcMarginSize(element, OverflowDirection.VERTICAL); expect(size).toBe(25); }); it('should threat values defined as zero', () => { const element = document.createElement('div'); document.body.appendChild(element); const horizontalSize = calcMarginSize(element, OverflowDirection.HORIZONTAL); const verticalSize = calcMarginSize(element, OverflowDirection.VERTICAL); expect(horizontalSize).toBe(0); expect(verticalSize).toBe(0); }); });