Skip to content

Commit

Permalink
add test case for IE9
Browse files Browse the repository at this point in the history
when Element.prototype.closest is not available
  • Loading branch information
estevanmaito committed May 17, 2019
1 parent 8489231 commit 053f843
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/__tests__/helpers/getClosestElement.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,20 @@ describe('getClosestElement', () => {

expect(ancestor).toBeNull()
})


it('should still return the closest ancestor if Element.prototype.closest isn\'t available', () => {
delete Element.prototype.closest

const ancestor = getClosestElement(element, 'div')

expect(ancestor.classList).toContain('inner')
})

it('should still return null if there isn\'t a matching ancestor and if Element.prototype.closest isn\'t available', () => {
delete Element.prototype.closest

const ancestor = getClosestElement(element, 'section')

expect(ancestor).toBeNull()
})
})

0 comments on commit 053f843

Please sign in to comment.