提交 a291945f 编写于 作者: fxy060608's avatar fxy060608

fix(test): add polyfill

上级 676ab63b
......@@ -2,51 +2,64 @@ const path = require('path')
const glob = require('glob')
global.EVENTS = [
'touchstart',
'touchmove',
'touchcancel',
'touchend',
'click', //tap=>click
'longpress',
'longtap',
'transitionend',
'animationstart',
'animationiteration',
'animationend',
'touchforcechange'
'touchstart',
'touchmove',
'touchcancel',
'touchend',
'click', //tap=>click
'longpress',
'longtap',
'transitionend',
'animationstart',
'animationiteration',
'animationend',
'touchforcechange'
]
global.COMPONENTS = []
glob.sync('../../src/core/view/components/**/*/index.vue', {
nodir: true,
cwd: __dirname
nodir: true,
cwd: __dirname
}).forEach(file => {
global.COMPONENTS.push(path.basename(path.dirname(file)))
global.COMPONENTS.push(path.basename(path.dirname(file)))
})
glob.sync('../../src/platforms/' + process.env.UNI_PLATFORM + '/view/components/**/*/index.vue', {
nodir: true,
cwd: __dirname
nodir: true,
cwd: __dirname
}).forEach(file => {
global.COMPONENTS.push(path.basename(path.dirname(file)))
global.COMPONENTS.push(path.basename(path.dirname(file)))
})
let lastTime = 0
global.requestAnimationFrame = function(callback, element) {
const currTime = new Date().getTime()
const timeToCall = Math.max(0, 16.7 - (currTime - lastTime));
const id = global.setTimeout(function() {
callback(currTime + timeToCall)
}, timeToCall)
lastTime = currTime + timeToCall
return id
const currTime = new Date().getTime()
const timeToCall = Math.max(0, 16.7 - (currTime - lastTime));
const id = global.setTimeout(function() {
callback(currTime + timeToCall)
}, timeToCall)
lastTime = currTime + timeToCall
return id
}
global.cancelAnimationFrame = function(id) {
clearTimeout(id)
clearTimeout(id)
}
require('jsdom-global')(undefined, {
pretendToBeVisual: true
pretendToBeVisual: true
})
//fake
HTMLCanvasElement.prototype.getContext = function getContext() {
return {}
}
window.Date = Date
localStorage = {
getItem: function(key) {
return this[key]
},
setItem: function(key, value) {
this[key] = value
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册