#!/usr/bin/env ts-node
// tslint:disable:max-line-length
// tslint:disable:no-shadowed-variable
import test from 'blue-tape'
import {
PuppetRoomJoinEvent,
YOU,
} from 'wechaty-puppet'
import {
PadproMessagePayload,
} from '../schemas'
import { roomJoinEventMessageParser } from './room-event-join-message-parser'
test('roomJoinEventMessageParser() EN-other-invite-other', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '李卓桓 invited Huan to the group chat',
fromUser : '5967138682@chatroom',
messageId : '11101130790981890',
messageSource: '',
messageType : 10000,
status : 1,
timestamp : 1528754090,
toUser : 'wxid_5zj4i5htp9ih22',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['Huan'],
inviterName : '李卓桓',
roomId : '5967138682@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-other-invite-others', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '李卓桓 invited 李佳芮, Huan to the group chat',
fromUser : '5178377660@chatroom',
messageId : '3318447775079396781',
messageSource: '',
messageType : 10000,
status : 1,
timestamp : 1528752402,
toUser : 'wxid_5zj4i5htp9ih22',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['李佳芮', 'Huan'],
inviterName : '李卓桓',
roomId : '5178377660@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-other-invite-bot', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '李卓桓 invited you to a group chat with ',
fromUser : '3453262102@chatroom',
messageId : '6633562959389269859',
messageSource: '',
messageType : 10000,
status : 1,
timestamp : 1528653783,
toUser : 'wxid_5zj4i5htp9ih22',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : [YOU],
inviterName : '李卓桓',
roomId : '3453262102@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-other-invite-bot-with-2-others', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '李卓桓 invited you and Huan to the group chat',
fromUser : '5178377660@chatroom',
messageId : '3875534618008681721',
messageSource: '',
messageType : 10000,
status : 1,
timestamp : 1528751621,
toUser : 'wxid_5zj4i5htp9ih22',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : [YOU, 'Huan'],
inviterName : '李卓桓',
roomId : '5178377660@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-bot-invite-one', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '3453262102@chatroom: \n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\tinvite\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\n\n',
fromUser : '3453262102@chatroom',
messageId : '4030118997146183783',
messageSource: '',
messageType : 10002,
status : 1,
timestamp : 1528755135,
toUser : 'wxid_5zj4i5htp9ih22',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['. 李 卓 桓 .呵呵'],
inviterName : YOU,
roomId : '3453262102@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
/**
* See more in https://github.com/lijiarui/wechaty-puppet-padchat/issues/55
*/
test('roomJoinEventMessageParser() EN-bot-invite-three-bot-is-owner', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '6350854677@chatroom: \n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\tinvite\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\n\n',
fromUser : '6350854677@chatroom',
messageId : '8360809484132917423',
messageSource: '',
messageType : 10002,
status : 1,
timestamp : 1528831222,
toUser : 'wxid_zj2cahpwzgie12',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['卓桓、Zhuohuan', '李佳芮', '太阁_传话助手'],
inviterName : YOU,
roomId : '6350854677@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-bot-invite-three-bot-is-not-owner', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '12740017638@chatroom: \n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\tinvite\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\n\n',
fromUser : '12740017638@chatroom',
messageId : '232220931339852872',
messageSource: '',
messageType : 10002,
status : 1,
timestamp : 1528831349,
toUser : 'wxid_zj2cahpwzgie12',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['卓桓、Zhuohuan', '太阁_传话助手', '桔小秘'],
inviterName : YOU,
roomId : '12740017638@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-other-invite-bot-and-two', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '李佳芮 invited you to a group chat with 卓桓、Zhuohuan, 桔小秘, 桔小秘',
fromUser : '12740017638@chatroom',
messageId : '5536901313750622557',
messageSource: '',
messageType : 10000,
status : 1,
timestamp : 1528831519,
toUser : 'wxid_zj2cahpwzgie12',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : [YOU],
inviterName : '李佳芮',
roomId : '12740017638@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-scan-qrcode-shared-by-bot-when-bot-is-owner', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '6350854677@chatroom: \n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\tqrcode\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\n\n',
fromUser : '6350854677@chatroom',
messageId : '4650182269246977858',
messageSource: '',
messageType : 10002,
status : 1,
timestamp : 1528831810,
toUser : 'wxid_zj2cahpwzgie12',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['李佳芮'],
inviterName : YOU,
roomId : '6350854677@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-scan-qrcode-shared-by-bot-when-bot-not-owner', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '9967013206@chatroom: \n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\tqrcode\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\n\n',
fromUser : '9967013206@chatroom',
messageId : '387789779973392581',
messageSource: '',
messageType : 10002,
status : 1,
timestamp : 1528831949,
toUser : 'wxid_zj2cahpwzgie12',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['李佳芮'],
inviterName : YOU,
roomId : '9967013206@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-scan-qrcode-shared-by-other-when-bot-is-owner', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '"卓桓、Zhuohuan" joined the group chat via the QR Code shared by "李佳芮".',
fromUser : '5616634434@chatroom',
messageId : '4922578438277818474',
messageSource: '',
messageType : 10000,
status : 1,
timestamp : 1528831993,
toUser : 'wxid_zj2cahpwzgie12',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['卓桓、Zhuohuan'],
inviterName : '李佳芮',
roomId : '5616634434@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-scan-qrcode-shared-by-other-when-bot-no-owner', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content : '"卓桓、Zhuohuan" joined the group chat via the QR Code shared by "李佳芮".',
fromUser : '6350854677@chatroom',
messageId : '6329592305165976988',
messageSource: '',
messageType : 10000,
status : 1,
timestamp : 1528832169,
toUser : 'wxid_zj2cahpwzgie12',
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['卓桓、Zhuohuan'],
inviterName : '李佳芮',
roomId : '6350854677@chatroom',
}
const event = await roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-bot-invite-many', async t => {
t.skip('should be the same as the bot-invite-many')
})
test('roomJoinEventMessageParser() EN-room-create', async t => {
t.skip('to be confirm')
})