优化:统一小程序业务引用选择交互
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
let definition
|
||||
global.Component = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
const events = []
|
||||
const component = {
|
||||
data: {
|
||||
items: [{ id: 7, title: '小周' }]
|
||||
},
|
||||
triggerEvent(name, detail) {
|
||||
events.push({ name, detail })
|
||||
}
|
||||
}
|
||||
Object.assign(component, definition.methods)
|
||||
|
||||
component.onSearch({ detail: { value: '周' } })
|
||||
component.selectItem({ currentTarget: { dataset: { index: 0 } } })
|
||||
component.retry()
|
||||
component.action()
|
||||
component.close()
|
||||
|
||||
assert.deepStrictEqual(events.map(item => item.name), ['search', 'select', 'retry', 'action', 'close'])
|
||||
assert.strictEqual(events[0].detail.value, '周')
|
||||
assert.strictEqual(events[1].detail.item.id, 7)
|
||||
|
||||
const wxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
|
||||
const wxss = fs.readFileSync(path.join(__dirname, 'index.wxss'), 'utf8')
|
||||
assert.match(wxml, /class="selector-mask"[^>]*catchtouchmove="stopEvent"/)
|
||||
assert.match(wxml, /<scroll-view class="selector-scroll" scroll-y/)
|
||||
assert.doesNotMatch(wxml, /selector-scroll[^>]*catchtouchmove/)
|
||||
assert.match(wxss, /\.selector-sheet\s*\{[^}]*height:\s*88vh;[^}]*flex-direction:\s*column;[^}]*overflow:\s*hidden;/s)
|
||||
assert.match(wxss, /\.selector-scroll\s*\{[^}]*min-height:\s*0;[^}]*flex:\s*1;/s)
|
||||
Reference in New Issue
Block a user