44 lines
920 B
JavaScript
44 lines
920 B
JavaScript
const assert = require('assert')
|
|||
|
|
|
||
|
|
let relaunchedTo = ''
|
||
|
|
let customerCleared = false
|
||
|
|
let adminCleared = false
|
||
|
|
|
||
|
|
global.wx = {
|
||
|
|
reLaunch(options) {
|
||
|
|
relaunchedTo = options.url
|
||
|
|
if (typeof options.success === 'function') {
|
||
|
|
options.success()
|
||
|
|
}
|
||
|
|
},
|
||
|
|
removeStorageSync() {},
|
||
|
|
setStorageSync() {},
|
||
|
|
getStorageSync() {
|
||
|
|
return ''
|
||
|
|
},
|
||
|
|
removeTabBarBadge(options) {
|
||
|
|
if (options && typeof options.fail === 'function') {
|
||
|
|
options.fail()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
global.getApp = () => ({
|
||
|
|
clearUserSession() {
|
||
|
|
customerCleared = true
|
||
|
|
},
|
||
|
|
clearAdminSession() {
|
||
|
|
adminCleared = true
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
const sessionSwitch = require('./session-switch')
|
||
|
|
|
||
|
|
sessionSwitch.openAdminLogin()
|
||
|
|
assert.strictEqual(customerCleared, true)
|
||
|
|
assert.strictEqual(relaunchedTo, '/admin/pages/login/index')
|
||
|
|
|
||
|
|
sessionSwitch.openCustomerHome()
|
||
|
|
assert.strictEqual(adminCleared, true)
|
||
|
|
assert.strictEqual(relaunchedTo, '/pages/home/index')
|