53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
const assert = require('assert')
|
|
|
|
global.wx = {
|
|
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
|
getDeviceInfo: () => ({ platform: 'devtools' }),
|
|
getStorageSync: () => '',
|
|
setStorageSync: () => {},
|
|
removeStorageSync: () => {}
|
|
}
|
|
|
|
const appMock = {
|
|
globalData: {
|
|
userInfo: { type: 2 },
|
|
openEmployeeReview: true
|
|
}
|
|
}
|
|
global.getApp = () => appMock
|
|
|
|
let definition
|
|
global.Page = value => { definition = value }
|
|
require('./index')
|
|
|
|
function createPage() {
|
|
return {
|
|
...definition,
|
|
data: { ...definition.data, isManager: true },
|
|
setData(values) { Object.assign(this.data, values) }
|
|
}
|
|
}
|
|
|
|
async function run() {
|
|
const employeesApi = require('../../api/employees')
|
|
employeesApi.reviewApplications = async () => [{
|
|
id: 12,
|
|
applicationNo: 'SALON-001',
|
|
applicantNickname: '小周',
|
|
createTime: '2026-10-12T10:30:00'
|
|
}]
|
|
|
|
const page = createPage()
|
|
await page.onShow()
|
|
|
|
assert.strictEqual(appMock.globalData.openEmployeeReview, false)
|
|
assert.strictEqual(page.data.reviewExpanded, true)
|
|
assert.strictEqual(page.data.reviewPendingCount, 1)
|
|
assert.strictEqual(page.data.reviewApplications[0].applicationTimeText, '2026-10-12 10:30')
|
|
}
|
|
|
|
run().catch(error => {
|
|
console.error(error)
|
|
process.exitCode = 1
|
|
})
|