数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
775 B

2 years ago
import { afterEach, beforeEach, describe, expect, xit } from '@jest/globals'
import isTouchDevice from './isTouchDevice.js'
describe('isTouchDevice', () => {
const RealTouchStart = globalThis.window.ontouchstart
const RealMaxTouchPoints = globalThis.navigator.maxTouchPoints
beforeEach(() => {
globalThis.window.ontouchstart = true
globalThis.navigator.maxTouchPoints = 1
})
afterEach(() => {
globalThis.navigator.maxTouchPoints = RealMaxTouchPoints
globalThis.window.ontouchstart = RealTouchStart
})
xit("should return true if it's a touch device", () => {
expect(isTouchDevice()).toEqual(true)
delete globalThis.window.ontouchstart
globalThis.navigator.maxTouchPoints = false
expect(isTouchDevice()).toEqual(false)
})
})