Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
ac899aea
W
wechaty
项目概览
weixin_46011646
/
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,体验更适合开发者的 AI 搜索 >>
提交
ac899aea
编写于
7月 19, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
firebug
上级
2a4da39f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
22 deletion
+22
-22
package.json
package.json
+1
-1
src/puppet-web/event.js
src/puppet-web/event.js
+1
-1
src/puppet-web/server.js
src/puppet-web/server.js
+3
-3
test/puppet-web/index.spec.js
test/puppet-web/index.spec.js
+17
-17
未找到文件。
package.json
浏览文件 @
ac899aea
...
...
@@ -8,7 +8,7 @@
"pretest"
:
"npm run lint"
,
"start"
:
"node bin/io-bot.js"
,
"demo"
:
"node example/ding-dong-bot.js"
,
"test"
:
"cross-env TAP_TIMEOUT=600 tap --reporter=tap test/
**/*
.spec.js"
"test"
:
"cross-env TAP_TIMEOUT=600 tap --reporter=tap test/
{*,**/*}
.spec.js"
},
"repository"
:
{
"type"
:
"git"
,
...
...
src/puppet-web/event.js
浏览文件 @
ac899aea
...
...
@@ -48,7 +48,7 @@ function onBrowserDead(e) {
// guard by variable: isBrowserBirthing to prevent the 2nd time entrance.
if
(
this
.
isBrowserBirthing
)
{
if
(
this
.
isBrowserBirthing
===
true
)
{
log
.
warn
(
'
PuppetWebEvent
'
,
'
onBrowserDead() Im busy, dont call me again before I return. this time will return and do nothing
'
)
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onBrowserDead() Im busy, dont call me again before I return. this time will return and do nothing
'
)
return
}
else
{
log
.
warn
(
'
PuppetWebEvent
'
,
'
onBrowserDead() Im FAKE busy? isBrowserBirthing is not boolean true!
'
)
...
...
src/puppet-web/server.js
浏览文件 @
ac899aea
...
...
@@ -98,9 +98,9 @@ class Server extends EventEmitter {
// log: true
})
socketServer
.
sockets
.
on
(
'
connection
'
,
(
s
)
=>
{
log
.
verbose
(
'
PuppetWebServer
'
,
'
createSocketIo() got connection from browser
'
)
// console.log(s.handshake)
if
(
this
.
socketClient
)
{
this
.
socketClient
=
null
}
// close() ???
log
.
verbose
(
'
PuppetWebServer
'
,
'
createSocketIo() got connection from browser
'
)
// console.log(s.handshake)
if
(
this
.
socketClient
)
{
this
.
socketClient
=
undefined
}
// close() ???
this
.
socketClient
=
s
this
.
initEventsFromClient
(
s
)
})
...
...
test/puppet-web/index.spec.js
浏览文件 @
ac899aea
...
...
@@ -12,7 +12,20 @@ const PROFILE = 'unit-test-session.wechaty.json'
const
PuppetWeb
=
require
(
'
../../src/puppet-web
'
)
const
Message
=
require
(
'
../../src/message
'
)
test
(
'
PuppetWeb smoke testing
'
,
function
(
t
)
{
test
(
'
Puppet Web Self Message Identification
'
,
function
(
t
)
{
const
p
=
new
PuppetWeb
({
port
:
PORT
,
head
:
HEAD
,
profile
:
PROFILE
})
t
.
ok
(
p
,
'
should instantiated a PuppetWeb
'
)
const
EXPECTED_USER_ID
=
'
zixia
'
const
m
=
new
Message
()
m
.
set
(
'
from
'
,
EXPECTED_USER_ID
)
p
.
userId
=
EXPECTED_USER_ID
t
.
ok
(
p
.
self
(
m
),
'
should identified self for message which from is self
'
)
t
.
end
()
})
false
&&
test
(
'
PuppetWeb smoke testing
'
,
function
(
t
)
{
let
pw
=
new
PuppetWeb
({
port
:
PORT
,
head
:
HEAD
,
profile
:
PROFILE
})
t
.
ok
(
pw
,
'
should instantiated a PuppetWeb
'
)
...
...
@@ -83,7 +96,7 @@ log.level = 'info'
/////////////////////////////////////////////////////////////////////////////
function
dingSocket
(
server
)
{
const
maxTime
=
60000
// 60s
const
waitTime
=
5
00
const
waitTime
=
30
00
let
totalTime
=
0
return
new
Promise
((
resolve
,
reject
)
=>
{
log
.
verbose
(
'
TestPuppetWeb
'
,
'
dingSocket()
'
)
...
...
@@ -96,7 +109,7 @@ log.level = 'info'
return
testDing
()
function
testDing
()
{
// log.silly('TestPuppetWeb', server.socketio
)
log
.
silly
(
'
TestPuppetWeb
'
,
'
dingSocket() server.socketServer: %s
'
,
server
.
socketServer
)
if
(
!
server
.
socketClient
)
{
totalTime
+=
waitTime
if
(
totalTime
>
maxTime
)
{
...
...
@@ -107,7 +120,7 @@ log.level = 'info'
setTimeout
(
testDing
,
waitTime
)
return
}
//log.silly('TestPuppetWebServer
', server.socketClient)
log
.
silly
(
'
TestPuppetWeb
'
,
'
dingSocket() server.socketClient: %s
'
,
server
.
socketClient
)
server
.
socketClient
.
once
(
'
dong
'
,
data
=>
{
log
.
verbose
(
'
TestPuppetWeb
'
,
'
socket recv event dong:
'
+
data
)
return
resolve
(
data
)
...
...
@@ -117,16 +130,3 @@ log.level = 'info'
})
}
})
test
(
'
Puppet Web Self Message Identification
'
,
function
(
t
)
{
const
p
=
new
PuppetWeb
({
port
:
PORT
,
head
:
HEAD
,
profile
:
PROFILE
})
t
.
ok
(
p
,
'
should instantiated a PuppetWeb
'
)
const
EXPECTED_USER_ID
=
'
zixia
'
const
m
=
new
Message
()
m
.
set
(
'
from
'
,
EXPECTED_USER_ID
)
p
.
userId
=
EXPECTED_USER_ID
t
.
ok
(
p
.
self
(
m
),
'
should identified self for message which from is self
'
)
t
.
end
()
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录