将门店有效期展示移至店铺设置
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
let pageDefinition
|
||||
let currentProfile
|
||||
|
||||
global.Page = definition => { pageDefinition = definition }
|
||||
global.wx = { showToast: () => {} }
|
||||
|
||||
const profileCache = require('../../utils/profile-cache')
|
||||
profileCache.getProfile = async () => currentProfile
|
||||
require('./index')
|
||||
|
||||
async function loadProfile(profile) {
|
||||
currentProfile = profile
|
||||
const page = {
|
||||
data: { ...pageDefinition.data },
|
||||
setData(values) {
|
||||
Object.entries(values).forEach(([key, value]) => {
|
||||
const parts = key.split('.')
|
||||
if (parts.length === 1) this.data[key] = value
|
||||
else this.data[parts[0]] = { ...this.data[parts[0]], [parts[1]]: value }
|
||||
})
|
||||
}
|
||||
}
|
||||
await pageDefinition.loadProfile.call(page)
|
||||
return page.data
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const empty = await loadProfile({
|
||||
type: 2,
|
||||
shopBusinessExpireTime: null,
|
||||
shopBusinessExpired: false,
|
||||
shopBusinessRemainingDays: null
|
||||
})
|
||||
assert.strictEqual(empty.businessExpireDateText, '未设置')
|
||||
assert.strictEqual(empty.businessExpiryStatusText, '有效期未设置')
|
||||
|
||||
const active = await loadProfile({
|
||||
type: 2,
|
||||
shopBusinessExpireTime: '2026-12-31T23:59:59',
|
||||
shopBusinessExpired: false,
|
||||
shopBusinessRemainingDays: 66
|
||||
})
|
||||
assert.strictEqual(active.businessExpireDateText, '2026-12-31')
|
||||
assert.strictEqual(active.businessExpiryStatusText, '剩余 66 天')
|
||||
|
||||
const expired = await loadProfile({
|
||||
type: 2,
|
||||
shopBusinessExpireTime: '2026-10-01T00:00:00',
|
||||
shopBusinessExpired: true,
|
||||
shopBusinessRemainingDays: 0
|
||||
})
|
||||
assert.strictEqual(expired.businessExpiryStatusText, '已过期,暂不能新增预约')
|
||||
|
||||
const shopSettingsWxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
|
||||
const accountSettingsWxml = fs.readFileSync(path.join(__dirname, '../account-settings/index.wxml'), 'utf8')
|
||||
assert(shopSettingsWxml.includes('wx:if="{{profile.type == 2}}" class="card business-expiry-card"'))
|
||||
assert(!accountSettingsWxml.includes('business-expiry-card'))
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
Reference in New Issue
Block a user