init commit
This commit is contained in:
15
test/index.test.js
Normal file
15
test/index.test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const _ = require('./utils')
|
||||
|
||||
test('render', async () => {
|
||||
const componentId = _.load('index', 'comp')
|
||||
const component = _.render(componentId, {prop: 'index.test.properties'})
|
||||
|
||||
const parent = document.createElement('parent-wrapper')
|
||||
component.attach(parent)
|
||||
|
||||
expect(_.match(component.dom, '<wx-view class="comp--index">index.test.properties-false</wx-view>')).toBe(true)
|
||||
|
||||
await _.sleep(10)
|
||||
|
||||
expect(_.match(component.dom, '<wx-view class="comp--index">index.test.properties-true</wx-view>')).toBe(true)
|
||||
})
|
||||
22
test/utils.js
Normal file
22
test/utils.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const path = require('path')
|
||||
const simulate = require('miniprogram-simulate')
|
||||
|
||||
const config = require('../tools/config')
|
||||
|
||||
const srcPath = config.srcPath
|
||||
const oldLoad = simulate.load
|
||||
simulate.load = function (componentPath, ...args) {
|
||||
componentPath = path.join(srcPath, componentPath)
|
||||
return oldLoad(componentPath, ...args)
|
||||
}
|
||||
|
||||
module.exports = simulate
|
||||
|
||||
// adjust the simulated wx api
|
||||
const oldGetSystemInfoSync = global.wx.getSystemInfoSync
|
||||
global.wx.getSystemInfoSync = function() {
|
||||
const res = oldGetSystemInfoSync()
|
||||
res.SDKVersion = '2.4.1'
|
||||
|
||||
return res
|
||||
}
|
||||
18
test/wx.test.js
Normal file
18
test/wx.test.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const _ = require('./utils')
|
||||
|
||||
test('wx.getSystemInfo', async () => {
|
||||
wx.getSystemInfo({
|
||||
success(res) {
|
||||
expect(res.errMsg).toBe('getSystemInfo:ok')
|
||||
},
|
||||
complete(res) {
|
||||
expect(res.errMsg).toBe('getSystemInfo:ok')
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('wx.getSystemInfoSync', async () => {
|
||||
const info = wx.getSystemInfoSync()
|
||||
expect(info.SDKVersion).toBe('2.4.1')
|
||||
expect(info.version).toBe('6.6.3')
|
||||
})
|
||||
Reference in New Issue
Block a user