forked from fingerprintjs/fingerprintjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtouch_support.test.ts
More file actions
23 lines (21 loc) · 924 Bytes
/
touch_support.test.ts
File metadata and controls
23 lines (21 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { withMockProperties } from '../../tests/utils'
import getTouchSupport from './touch_support'
describe('Sources', () => {
describe('touchSupport', () => {
it('detects touchable device', () => {
const touchSupport = getTouchSupport()
expect(typeof touchSupport.maxTouchPoints).toBe('number')
expect(typeof touchSupport.touchEvent).toBe('boolean')
expect(typeof touchSupport.touchStart).toBe('boolean')
})
// Some browsers return a string value for `maxTouchPoints`.
// This test checks that it's fetched as a number regardless.
it('handles fake values', async () => {
// Configuring the mock property as `{ value: '5' }` doesn't work in old browsers.
await withMockProperties(navigator, { maxTouchPoints: { get: () => '5' } }, () => {
const touchSupport = getTouchSupport()
expect(touchSupport.maxTouchPoints).toBe(5)
})
})
})
})