功能:优化Salon作品选择与历史补单
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
const assert = require('assert')
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
global.wx = { showToast: () => {} }
|
||||
require('./index')
|
||||
|
||||
function createPage() {
|
||||
return {
|
||||
...definition,
|
||||
data: JSON.parse(JSON.stringify(definition.data)),
|
||||
setData(values) {
|
||||
Object.entries(values).forEach(([key, value]) => {
|
||||
const parts = key.split('.')
|
||||
let target = this.data
|
||||
for (let index = 0; index < parts.length - 1; index += 1) target = target[parts[index]]
|
||||
target[parts[parts.length - 1]] = value
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const page = createPage()
|
||||
page.openProductSelector()
|
||||
assert.strictEqual(page.data.productSelectorVisible, true)
|
||||
assert.strictEqual(page.data.productSelectorMode, 'list')
|
||||
page.selectProduct({ detail: { item: { id: 12, title: '轻奢款', price: 168, priceText: '¥168' } } })
|
||||
assert.strictEqual(page.data.form.productId, 12)
|
||||
assert.strictEqual(page.data.form.amount, '168')
|
||||
assert.strictEqual(page.data.selectedProductPriceText, '¥168')
|
||||
assert.strictEqual(page.data.form.manualProductTitle, '')
|
||||
|
||||
page.data.manualProductDraft = { title: '临时款', price: '199' }
|
||||
page.useManualProduct()
|
||||
assert.strictEqual(page.data.form.productId, '')
|
||||
assert.strictEqual(page.data.form.manualProductTitle, '临时款')
|
||||
assert.strictEqual(page.data.form.amount, '199')
|
||||
assert.strictEqual(page.data.selectedProductPriceText, '¥199')
|
||||
|
||||
page.openManualProduct()
|
||||
assert.strictEqual(page.data.productSelectorMode, 'manual')
|
||||
page.toggleManualProductMore()
|
||||
assert.strictEqual(page.data.manualMoreExpanded, true)
|
||||
|
||||
Reference in New Issue
Block a user