功能:优化Salon作品选择与历史补单
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
const assert = require('assert')
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
global.wx = { showToast: () => {} }
|
||||
global.getApp = () => ({ globalData: { userInfo: { id: 1, shopId: 2, type: 2 } } })
|
||||
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.openProductModal()
|
||||
assert.strictEqual(page.data.productModalVisible, true)
|
||||
assert.strictEqual(page.data.productSelectorMode, 'list')
|
||||
page.refreshAvailableTimes = () => {}
|
||||
page.checkAvailability = () => {}
|
||||
page.selectProduct({ detail: { item: { id: 8, title: '法式', price: 238, priceText: '¥238', approximateDuration: '90' } } })
|
||||
assert.strictEqual(page.data.form.productId, 8)
|
||||
assert.strictEqual(page.data.selectedProduct.title, '法式')
|
||||
assert.strictEqual(page.data.selectedProductPriceText, '¥238')
|
||||
assert.strictEqual(page.data.form.manualProductTitle, '')
|
||||
assert.strictEqual(page.data.form.durationMinutes, '90')
|
||||
|
||||
page.data.manualProductDraft = { title: '手绘款', price: '299', description: '', tags: '', targetAudience: '', precautions: '', imageFileIds: '', imageUrl: '' }
|
||||
page.useManualProduct()
|
||||
assert.strictEqual(page.data.form.productId, '')
|
||||
assert.strictEqual(page.data.form.manualProductTitle, '手绘款')
|
||||
assert.strictEqual(page.data.form.manualProductPrice, '299')
|
||||
assert.strictEqual(page.data.selectedProductPriceText, '¥299')
|
||||
|
||||
Reference in New Issue
Block a user