Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
00e482eb
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,发现更多精彩内容 >>
未验证
提交
00e482eb
编写于
6月 12, 2018
作者:
Huan (李卓桓)
提交者:
GitHub
6月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1308 from lijiarui/0612
add room event
上级
b9a35903
44166ebd
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
79 addition
and
0 deletion
+79
-0
src/puppet-padchat/pure-function-helper.spec.ts
src/puppet-padchat/pure-function-helper.spec.ts
+57
-0
src/puppet-padchat/pure-function-helper.ts
src/puppet-padchat/pure-function-helper.ts
+22
-0
未找到文件。
src/puppet-padchat/pure-function-helper.spec.ts
浏览文件 @
00e482eb
...
...
@@ -7,6 +7,9 @@ import test from 'blue-tape'
import
{
PadchatPureFunctionHelper
as
pfHelper
,
RoomJoinType
,
RoomLeaveType
,
RoomTopicType
,
}
from
'
./pure-function-helper
'
import
{
...
...
@@ -315,6 +318,60 @@ test('messageRawPayloadParser', async t => {
t
.
deepEqual
(
payload
,
EXPECTED_MESSAGE_PAYLOAD_STATUS_NOTIFY
,
'
should parse status notify message payload
'
)
})
t
.
test
(
'
roomJoinMessageParser
'
,
async
t
=>
{
const
PADCHAT_MESSAGE_PAYLOAD_ROOM_JOIN
:
PadchatMessagePayload
=
{
content
:
'
"李卓桓"邀请"Huan LI++"加入了群聊
'
,
continue
:
1
,
description
:
''
,
from_user
:
'
5354656522@chatroom
'
,
msg_id
:
'
1303222499352704462
'
,
msg_source
:
''
,
msg_type
:
5
,
status
:
1
,
sub_type
:
10000
,
timestamp
:
1528657265
,
to_user
:
'
wxid_a8d806dzznm822
'
,
uin
:
1211516682
,
}
const
EXPECTED_MESSAGE_PAYLOAD_ROOM_JOIN
:
RoomJoinType
=
{
inviteeNameList
:
[
'
Huan LI++
'
],
inviterName
:
'
李卓桓
'
,
roomId
:
'
5354656522@chatroom
'
,
}
const
payload
=
pfHelper
.
roomJoinMessageParser
(
PADCHAT_MESSAGE_PAYLOAD_ROOM_JOIN
)
// console.log('payload:', payload)
t
.
deepEqual
(
payload
,
EXPECTED_MESSAGE_PAYLOAD_ROOM_JOIN
,
'
should parse room join message payload
'
)
})
t
.
test
(
'
roomLeaveMessageParser
'
,
async
t
=>
{
const
PADCHAT_MESSAGE_PAYLOAD_ROOM_LEAVE
:
PadchatMessagePayload
=
{
content
:
'
你将"Huan LI++"移出了群聊
'
,
continue
:
1
,
description
:
''
,
from_user
:
'
5354656522@chatroom
'
,
msg_id
:
'
7593234909679768634
'
,
msg_source
:
''
,
msg_type
:
5
,
status
:
1
,
sub_type
:
10000
,
timestamp
:
1528657235
,
to_user
:
'
lizhuohuan
'
,
uin
:
4763975
,
}
const
EXPECTED_MESSAGE_PAYLOAD_ROOM_LEAVE
:
RoomLeaveType
=
{
leaverNameList
:
[
'
Huan LI++
'
],
removerName
:
'
你
'
,
roomId
:
'
5354656522@chatroom
'
,
}
const
payload
=
pfHelper
.
roomJoinMessageParser
(
PADCHAT_MESSAGE_PAYLOAD_ROOM_LEAVE
)
// console.log('payload:', payload)
t
.
deepEqual
(
payload
,
EXPECTED_MESSAGE_PAYLOAD_ROOM_LEAVE
,
'
should parse room leave message payload
'
)
})
})
// test('friendRequestRawPayloadParser', async t => {
...
...
src/puppet-padchat/pure-function-helper.ts
浏览文件 @
00e482eb
...
...
@@ -41,6 +41,24 @@ import {
// PadchatRoomMemberPayload,
}
from
'
./padchat-schemas
'
export
interface
RoomJoinType
{
inviteeNameList
:
string
[],
inviterName
:
string
,
roomId
:
string
,
}
export
interface
RoomLeaveType
{
leaverNameList
:
string
[],
removerName
:
string
,
roomId
:
string
,
}
export
interface
RoomTopicType
{
changeName
:
string
,
topic
:
string
,
roomId
:
string
,
}
export
class
PadchatPureFunctionHelper
{
private
constructor
()
{
throw
new
Error
(
'
should not be instanciated. use static methods only.
'
)
...
...
@@ -404,6 +422,10 @@ export class PadchatPureFunctionHelper {
const
decodedObject
:
T
=
JSON
.
parse
(
decodedText
)
return
decodedObject
}
public
static
roomJoinMessageParser
(
rawPayload
:
PadchatMessagePayload
):
RoomJoinType
{
const
content
=
rawPayload
.
content
}
}
export
default
PadchatPureFunctionHelper
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录