Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.www.
wechaty
提交
bd5f2d0a
W
wechaty
项目概览
.www.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bd5f2d0a
编写于
5月 30, 2018
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix unit tests
上级
ed136098
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
49 deletion
+22
-49
src/puppet-puppeteer/bridge.spec.ts
src/puppet-puppeteer/bridge.spec.ts
+0
-38
src/puppet-puppeteer/puppeteer-message.spec.ts
src/puppet-puppeteer/puppeteer-message.spec.ts
+5
-0
src/puppet/puppet.ts
src/puppet/puppet.ts
+1
-1
src/wechaty.spec.ts
src/wechaty.spec.ts
+1
-0
src/wechaty.ts
src/wechaty.ts
+15
-10
未找到文件。
src/puppet-puppeteer/bridge.spec.ts
浏览文件 @
bd5f2d0a
...
...
@@ -180,44 +180,6 @@ test('clickSwitchAccount()', async t => {
})
})
// test('retryPromise()', async t => {
// const EXPECTED_RESOLVE = 'Okey'
// const EXPECTED_REJECT = 'NotTheTime'
// function delayedFactory(timeout: number) {
// const startTime = Date.now()
// return function() {
// const nowTime = Date.now()
// if (nowTime - startTime > timeout) {
// return Promise.resolve(EXPECTED_RESOLVE)
// }
// return Promise.reject(EXPECTED_REJECT)
// }
// }
// const thenSpy = spy()
// const retryPromise = require('retry-promise').default
// const delay500 = delayedFactory(500)
// await retryPromise({ max: 1, backoff: 1 }, function() {
// return delay500()
// }).catch((e: any) => {
// thenSpy(e)
// })
// t.true(thenSpy.withArgs(EXPECTED_REJECT).calledOnce, 'should got EXPECTED_REJECT when wait not enough')
// thenSpy.resetHistory()
// const anotherDelay50 = delayedFactory(50)
// await retryPromise({ max: 6, backoff: 10 }, function() {
// return anotherDelay50()
// })
// .then((r: string) => {
// thenSpy(r)
// })
// t.true(thenSpy.withArgs(EXPECTED_RESOLVE).calledOnce, 'should got EXPECTED_RESOLVE when wait enough')
// })
test
(
'
WechatyBro.ding()
'
,
async
t
=>
{
const
profile
=
new
Profile
(
Math
.
random
().
toString
(
36
).
substr
(
2
,
5
))
const
bridge
=
new
Bridge
({
...
...
src/puppet-puppeteer/puppeteer-message.spec.ts
浏览文件 @
bd5f2d0a
...
...
@@ -216,6 +216,9 @@ test('findAll()', async t => {
;
(
wechaty
as
any
).
initPuppetAccessory
(
puppet
)
const
sandbox
=
sinon
.
createSandbox
()
sandbox
.
stub
(
puppet
,
'
contactPayload
'
).
resolves
({})
const
MOCK_USER_ID
=
'
TEST-USER-ID
'
puppet
.
login
(
MOCK_USER_ID
)
...
...
@@ -224,6 +227,8 @@ test('findAll()', async t => {
})
t
.
is
(
msgList
.
length
,
2
,
'
Message.findAll with limit 2
'
)
sandbox
.
restore
()
})
test
(
'
self()
'
,
async
t
=>
{
...
...
src/puppet/puppet.ts
浏览文件 @
bd5f2d0a
...
...
@@ -357,7 +357,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
await
userSelf
.
ready
()
this
.
id
=
userId
console
.
log
(
'
this.id=
'
,
this
.
id
)
//
console.log('this.id=', this.id)
this
.
emit
(
'
login
'
,
userId
)
}
...
...
src/wechaty.spec.ts
浏览文件 @
bd5f2d0a
...
...
@@ -77,6 +77,7 @@ test('event:start/stop', async t => {
await
wechaty
.
start
()
await
wechaty
.
stop
()
// console.log(startSpy.callCount)
t
.
ok
(
startSpy
.
calledOnce
,
'
should get event:start once
'
)
t
.
ok
(
stopSpy
.
calledOnce
,
'
should get event:stop once
'
)
})
...
...
src/wechaty.ts
浏览文件 @
bd5f2d0a
...
...
@@ -530,19 +530,24 @@ export class Wechaty extends PuppetAccessory implements Sayable {
break
case
'
start
'
:
puppet
.
removeAllListeners
(
'
start
'
)
puppet
.
on
(
'
start
'
,
()
=>
{
this
.
emit
(
'
start
'
)
}
)
break
case
'
stop
'
:
puppet
.
removeAllListeners
(
'
stop
'
)
puppet
.
on
(
'
stop
'
,
()
=>
{
this
.
emit
(
'
stop
'
)
}
)
// do not emit 'start'/'stop' again for wechaty
break
// case 'start':
// puppet.removeAllListeners('start')
// puppet.on('start', () => {
// this.emit('start')
// } )
// break
// case 'stop':
// puppet.removeAllListeners('stop')
// puppet.on('stop', () => {
// this.emit('stop')
// } )
// break
case
'
friend
'
:
puppet
.
removeAllListeners
(
'
friend
'
)
puppet
.
on
(
'
friend
'
,
payload
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录