功能:支持待分配预约与首次排班引导
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
const assert = require('assert')
|
||||
const employeesApi = require('../../api/employees')
|
||||
|
||||
let navigatedBack = false
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
setStorageSync: () => {},
|
||||
showToast: () => {},
|
||||
showModal: () => {},
|
||||
navigateBack: () => { navigatedBack = true }
|
||||
}
|
||||
global.getApp = () => ({ globalData: {} })
|
||||
global.getCurrentPages = () => []
|
||||
global.setTimeout = callback => { callback(); return 1 }
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
let emitted
|
||||
const page = {
|
||||
...definition,
|
||||
data: JSON.parse(JSON.stringify(definition.data)),
|
||||
getOpenerEventChannel: () => ({ emit: (name, value) => { emitted = { name, value } } }),
|
||||
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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
page.data.artistId = '88'
|
||||
page.data.onboarding = true
|
||||
page.data.onboardingSource = 'appointment'
|
||||
employeesApi.saveScheduleRule = async payload => {
|
||||
assert.strictEqual(payload.artistId, '88')
|
||||
assert.deepStrictEqual(payload.workDays, [1, 2, 3, 4, 5])
|
||||
}
|
||||
|
||||
await page.save()
|
||||
|
||||
assert.deepStrictEqual(emitted, { name: 'scheduleSaved', value: { artistId: '88' } })
|
||||
assert.strictEqual(navigatedBack, true)
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
Reference in New Issue
Block a user