UNPKG

668 BJavaScriptView Raw
1const isTouchDevice = require('./isTouchDevice')
2
3describe('isTouchDevice', () => {
4 const RealTouchStart = global.window.ontouchstart
5 const RealMaxTouchPoints = global.navigator.maxTouchPoints
6
7 beforeEach(() => {
8 global.window.ontouchstart = true
9 global.navigator.maxTouchPoints = 1
10 })
11
12 afterEach(() => {
13 global.navigator.maxTouchPoints = RealMaxTouchPoints
14 global.window.ontouchstart = RealTouchStart
15 })
16
17 xit("should return true if it's a touch device", () => {
18 expect(isTouchDevice()).toEqual(true)
19 delete global.window.ontouchstart
20 global.navigator.maxTouchPoints = false
21 expect(isTouchDevice()).toEqual(false)
22 })
23})