提交 9066d738 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

#40 all unit tests works with typescript enabled ava!

上级 c97f81ff
......@@ -26,10 +26,11 @@
"pretest": "npm run lint && npm run clean && npm run build",
"test": "npm run test:phantomjs && npm run test:chrome",
"posttest": "npm run clean && npm run sloc",
"test:phantomjs": "cross-env LC_ALL=C WECHATY_LOG=info WECHATY_HEAD=phantomjs ava --timeout=10m \"dist/{src,test}/**/*.spec.js\"",
"test:phantomjs": "cross-env LC_ALL=C WECHATY_LOG=info WECHATY_HEAD=phantomjs ava --timeout=10m \"dist/test/*.spec.js\"",
"test:phantomjs.bak": "cross-env LC_ALL=C WECHATY_LOG=info WECHATY_HEAD=phantomjs ava --timeout=10m \"dist/{src,test}/**/*.spec.js\"",
"test:chrome": "cross-env LC_ALL=C WECHATY_LOG=silly WECHATY_HEAD=chrome ava --timeout=10m \"dist/{src,test}/**/*.spec.js\"",
"testdev": "cross-env LC_ALL=C WECHATY_LOG=silly ava --ext ts --serial --verbose --fail-fast --timeout=3m",
"testdist": "ava --verbose --fail-fast --timeout=3m",
"testdist": "ava --ext ts --verbose --fail-fast --timeout=3m",
"ava": "cross-env LC_ALL=C WECHATY_LOG=verbose ts-node node_modules/.bin/ava \"{src,test}/**/*.spec.js\"",
"start": "ts-node bin/client",
"dev": "ts-node dev.ts",
......
......@@ -62,7 +62,7 @@ export class MediaMessage extends Message {
return this.ready()
.then(() => {
return (Config.puppetInstance() as PuppetWeb)
.browser.checkSession()
.browser.readCookie()
})
.then(cookies => {
if (!this.obj.url) {
......
......@@ -124,7 +124,7 @@ function onServerDing(this: PuppetWeb, data) {
this.emit('watchdog', { data })
}
function onServerScan(this: PuppetWeb, data: ScanInfo) {
async function onServerScan(this: PuppetWeb, data: ScanInfo) {
log.verbose('PuppetWebEvent', 'onServerScan(%d)', data && data.code)
this.scan = data
......@@ -132,8 +132,8 @@ function onServerScan(this: PuppetWeb, data: ScanInfo) {
/**
* When wx.qq.com push a new QRCode to Scan, there will be cookie updates(?)
*/
this.browser.saveSession()
.catch(() => {/* fail safe */})
await this.browser.saveCookie()
.catch(() => {/* fail safe */})
if (this.userId) {
log.verbose('PuppetWebEvent', 'onServerScan() there has userId when got a scan event. emit logout and set userId to null')
......@@ -306,10 +306,10 @@ async function onServerLogin(this: PuppetWeb, data, attempt = 0): Promise<void>
await this.user.ready()
log.silly('PuppetWebEvent', `onServerLogin() user ${this.user.name()} logined`)
await this.browser.saveSession()
.catch(e => { // fail safe
log.verbose('PuppetWebEvent', 'onServerLogin() browser.saveSession exception: %s', e.message)
})
await this.browser.saveCookie()
.catch(e => { // fail safe
log.verbose('PuppetWebEvent', 'onServerLogin() browser.saveSession exception: %s', e.message)
})
this.emit('login', this.user)
......
......@@ -124,7 +124,7 @@ function watchDogReset(timeout, lastFeed) {
* save every 5 mins
*
*/
function autoSaveSession(this: PuppetWeb, force = false) {
async function autoSaveSession(this: PuppetWeb, force = false) {
log.silly('PuppetWebWatchdog', 'autoSaveSession()')
if (!this.userId) {
......@@ -140,7 +140,7 @@ function autoSaveSession(this: PuppetWeb, force = false) {
, this.setting.profile
, Math.floor(SAVE_SESSION_INTERVAL / 1000 / 60)
)
this.browser.saveSession()
await this.browser.saveCookie()
this.watchDogLastSaveSession = Date.now()
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册