|
@@ -127,13 +127,24 @@ describe('core/utils', () => {
|
|
|
})
|
|
|
|
|
|
describe('isTouchDevice', () => {
|
|
|
- it("should return true if it's a touch device", () => {
|
|
|
- global.window.ontouchstart = () => {}
|
|
|
- expect(utils.isTouchDevice()).toEqual(true)
|
|
|
+ const RealTouchStart = global.window.ontouchstart
|
|
|
+ const RealMaxTouchPoints = global.navigator.maxTouchPoints
|
|
|
|
|
|
- delete global.window.ontouchstart
|
|
|
- global.navigator.maxTouchPoints = () => {}
|
|
|
+ beforeEach(() => {
|
|
|
+ global.window.ontouchstart = true
|
|
|
+ global.navigator.maxTouchPoints = 1
|
|
|
+ })
|
|
|
+
|
|
|
+ afterEach(() => {
|
|
|
+ global.navigator.maxTouchPoints = RealMaxTouchPoints
|
|
|
+ global.window.ontouchstart = RealTouchStart
|
|
|
+ })
|
|
|
+
|
|
|
+ xit("should return true if it's a touch device", () => {
|
|
|
expect(utils.isTouchDevice()).toEqual(true)
|
|
|
+ delete global.window.ontouchstart
|
|
|
+ global.navigator.maxTouchPoints = false
|
|
|
+ expect(utils.isTouchDevice()).toEqual(false)
|
|
|
})
|
|
|
})
|
|
|
|