| 1 |
import chai from 'chai'; |
| 2 |
const { expect } = chai; |
| 3 |
import getOuterSizes from '../../src/utils/getOuterSizes'; |
| 4 |
|
| 5 |
describe('utils/getOuterSizes', () => { |
| 6 |
let node; |
| 7 |
|
| 8 |
beforeEach(() => { |
| 9 |
node = document.createElement('div'); |
| 10 |
}); |
| 11 |
|
| 12 |
describe('when the element is not attach on the DOM', () => { |
| 13 |
it('should returns 0 width and height for empty elements', () => { |
| 14 |
expect(getOuterSizes(node)).to.deep.equal({ |
| 15 |
width: 0, |
| 16 |
height: 0, |
| 17 |
}); |
| 18 |
}); |
| 19 |
}); |
| 20 |
|
| 21 |
describe('when the element is attach on the DOM', () => { |
| 22 |
it('should returns width and height for elements without margins', () => { |
| 23 |
node.style.width = '20px'; |
| 24 |
node.style.height = '20px'; |
| 25 |
document.body.appendChild(node); |
| 26 |
node.style.position = 'relative'; |
| 27 |
|
| 28 |
expect(getOuterSizes(node)).to.deep.equal({ |
| 29 |
width: 20, |
| 30 |
height: 20, |
| 31 |
}); |
| 32 |
}); |
| 33 |
|
| 34 |
it('should returns width and height for elements with margins', () => { |
| 35 |
node.style.width = '20px'; |
| 36 |
node.style.height = '20px'; |
| 37 |
node.style.margin = '10px'; |
| 38 |
document.body.appendChild(node); |
| 39 |
node.style.position = 'relative'; |
| 40 |
|
| 41 |
expect(getOuterSizes(node)).to.deep.equal({ |
| 42 |
width: 40, |
| 43 |
height: 40, |
| 44 |
}); |
| 45 |
}); |
| 46 |
}); |
| 47 |
}); |