Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
c18917b6
W
wechaty
项目概览
.Veneno.
/
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,发现更多精彩内容 >>
提交
c18917b6
编写于
7月 06, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
uncomment unit tests
上级
7a82c184
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
4 addition
and
67 deletion
+4
-67
package.json
package.json
+1
-1
test/puppet-web.spec.js
test/puppet-web.spec.js
+1
-1
test/room.spec.js
test/room.spec.js
+2
-65
未找到文件。
package.json
浏览文件 @
c18917b6
{
"name"
:
"wechaty"
,
"version"
:
"0.2.
4
"
,
"version"
:
"0.2.
5
"
,
"description"
:
"Wechat for Bot. (Personal Account NOT Official Account)"
,
"main"
:
"index.js"
,
"scripts"
:
{
...
...
test/puppet-web.spec.js
浏览文件 @
c18917b6
...
...
@@ -12,7 +12,7 @@ const PROFILE = 'unit-test-session.wechaty.json'
const
PuppetWeb
=
require
(
'
../src/puppet-web
'
)
const
Message
=
require
(
'
../src/message
'
)
false
&&
test
(
'
PuppetWeb smoke testing
'
,
function
(
t
)
{
test
(
'
PuppetWeb smoke testing
'
,
function
(
t
)
{
let
pw
=
new
PuppetWeb
({
port
:
PORT
,
head
:
HEAD
,
profile
:
PROFILE
})
t
.
ok
(
pw
,
'
should instantiated a PuppetWeb
'
)
...
...
test/room.spec.js
浏览文件 @
c18917b6
const
test
=
require
(
'
tap
'
).
test
const
Message
=
require
(
'
../src/message
'
)
const
Room
=
require
(
'
../src/room
'
)
const
Contact
=
require
(
'
../src/contact
'
)
const
Puppet
=
require
(
'
../src/puppet
'
)
const
log
=
require
(
'
../src/npmlog-env
'
)
...
...
@@ -59,71 +60,7 @@ test('Room smoke testing', t => {
})
*/
false
&&
test
(
'
Message ready() promise testing
'
,
t
=>
{
// must different with other rawData, because Contact class with load() will cache the result. or use Contact.resetPool()
const
rawData
=
JSON
.
parse
(
'
{"RemarkPYQuanPin":"","RemarkPYInitial":"","PYInitial":"BJFRHXS","PYQuanPin":"beijingfeirenhuaxiangsan","Uin":0,"UserName":"@@4aa0ae1e1ebc568b613fa43ce93b478df0339f73340d87083822c2016d2e53d9","NickName":"北京飞人滑翔伞","HeadImgUrl":"/cgi-bin/mmwebwx-bin/webwxgetheadimg?seq=649595794&username=@@4aa0ae1e1ebc568b613fa43ce93b478df0339f73340d87083822c2016d2e53d9&skey=","ContactFlag":3,"MemberCount":111,"RemarkName":"","HideInputBarFlag":0,"Sex":0,"Signature":"","VerifyFlag":0,"OwnerUin":2354729644,"StarFriend":0,"AppAccountFlag":0,"Statues":0,"AttrStatus":0,"Province":"","City":"","Alias":"","SnsFlag":0,"UniFriend":0,"DisplayName":"","ChatRoomId":0,"KeyWord":"","EncryChatRoomId":"@7b3dcd218431d79045cda3493c3179ae","MMOrderSymbol":"BEIJINGFEIRENHUAXIANGSAN","MMInChatroom":true,"_index":90,"_h":50,"_offsetTop":4448,"$$hashKey":"01J","MMFromBatchGet":true,"MMFromBatchget":true,"MMBatchgetMember":true,"MMCanCreateChatroom":true}
'
)
const
expectedFromUserName
=
'
@0748ee480711bf20af91c298a0d7dcc77c30a680c1004157386b81cf13474823
'
const
expectedToUserName
=
'
@b58f91e0c5c9e841e290d862ddb63c14
'
const
expectedFromNickName
=
'
From Nick Name Test
'
const
expectedToNickName
=
'
To Nick Name Test
'
const
expectedMsgId
=
'
3009511950433684462
'
Contact
.
init
()
// Mock
const
mockContactGetter
=
function
(
id
)
{
log
.
silly
(
'
TestRoom
'
,
`mocked getContact(
${
id
}
)`
)
return
new
Promise
((
resolve
,
reject
)
=>
{
let
obj
=
{}
switch
(
id
)
{
case
expectedFromUserName
:
obj
=
{
UserName
:
expectedFromUserName
,
NickName
:
expectedFromNickName
}
break
case
expectedToUserName
:
obj
=
{
UserName
:
expectedToUserName
,
NickName
:
expectedToNickName
}
break
default
:
log
.
error
(
'
TestRoom
'
,
`mocked getContact(
${
id
}
) unknown`
)
break
}
log
.
silly
(
'
TestRoom
'
,
'
setTimeout mocked getContact
'
)
setTimeout
(
r
=>
{
log
.
silly
(
'
TestRoom
'
,
'
mocked getContact resolved
'
)
return
resolve
(
obj
)
},
200
)
})
}
const
m
=
new
Message
(
rawData
)
t
.
equal
(
m
.
get
(
'
id
'
),
expectedMsgId
,
'
id/MsgId right
'
)
m
.
ready
(
mockContactGetter
)
.
then
(
r
=>
{
/*
const fromC = m.get('from')
const toC = m.get('to')
fromC.dump()
toC.dump()
*/
t
.
equal
(
m
.
get
(
'
from
'
).
get
(
'
id
'
)
,
expectedFromUserName
,
'
contact ready for FromUserName
'
)
t
.
equal
(
m
.
get
(
'
from
'
).
get
(
'
name
'
)
,
expectedFromNickName
,
'
contact ready for FromNickName
'
)
t
.
equal
(
m
.
get
(
'
to
'
).
get
(
'
id
'
)
,
expectedToUserName
,
'
contact ready for ToUserName
'
)
t
.
equal
(
m
.
get
(
'
to
'
).
get
(
'
name
'
)
,
expectedToNickName
,
'
contact ready for ToNickName
'
)
})
.
catch
(
e
=>
t
.
fail
(
'
m.ready() rejected:
'
+
e
))
.
then
(
t
.
end
)
// test end
})
false
&&
test
(
'
TBW: Message static method
'
,
t
=>
{
test
(
'
TBW: Message static method
'
,
t
=>
{
Contact
.
attach
(
new
Puppet
())
const
m
=
Message
.
find
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录