uppy/packages/@uppy/utils/src/isTouchDevice.test.js
Antoine du Hamel 51ecc66e64
@uppy/utils: refactor to TS (#4699)
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Co-authored-by: Nick Rutten <2504906+nickrttn@users.noreply.github.com>
Co-authored-by: Murderlon <merlijn@soverin.net>
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
2023-11-06 15:01:50 +01:00

24 lines
771 B
JavaScript

import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import isTouchDevice from './isTouchDevice.ts'
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
})
it.skip("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)
})
})