import '@testing-library/jest-dom'; import {dimension} from '@shopify/jest-dom-mocks'; import $, {VeamsQueryObject} from '../src'; beforeEach(() => { dimension.mock({ offsetHeight: 200, offsetWidth: 200 }); }); afterEach(() => { dimension.restore(); }); test('outerWidth() - get width', () => { document.body.innerHTML = `
text content
`; const $targetEl: VeamsQueryObject = $(document.getElementById('target-el')); const outerWidth: number = $targetEl.outerWidth(); expect($targetEl).toHaveLength(1); expect(outerWidth).toBe(200); }); test('outerWidth() - get width (including margin)', () => { document.body.innerHTML = `
text content
text content
`; const $targetEls: VeamsQueryObject = $('.target-el'); const outerWidth: number = $targetEls.outerWidth(true); expect($targetEls).toHaveLength(2); expect(outerWidth).toBe(220); });