Skip to content

Commit

Permalink
add getTooltipPosition tests
Browse files Browse the repository at this point in the history
  • Loading branch information
estevanmaito committed May 17, 2019
1 parent 8b7498f commit d2e8b47
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/__tests__/helpers/getTooltipPosition.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import getTooltipPosition, { getDistanceFromTop } from '../../helpers/getTooltipPosition'

const props = {
iconSize: 24,
buttonMargin: 7 * 2,
arrowSize: 5,
icons: {
icons: {},
length: 2
}
}

window.getSelection = () => ({
getRangeAt: () => ({
getBoundingClientRect: () => ({
width: 75,
height: 21,
top: 218,
left: 720
})
})
})

describe('getDistanceFromTop', () => {
it('should return distance from top', () => {
const distance = getDistanceFromTop()

expect(distance).toEqual(0)
})
})

describe('getTooltipPosition', () => {
it('should return the tooltip position', () => {
const tooltipPosition = getTooltipPosition(props)

const expected = {
top: 175,
left: 719.5
}

expect(tooltipPosition).toEqual(expected)
})

})

0 comments on commit d2e8b47

Please sign in to comment.