#!/usr/bin/env ts-node
// tslint:disable:max-line-length
// tslint:disable:no-shadowed-variable
import test from 'blue-tape'
import {
PadproMessagePayload,
PadproRoomInviteEvent,
} from '../schemas'
import { roomInviteEventMessageParser } from './room-event-invite-message-parser'
test('roomInviteEventMessageParser() ZH', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content: '邀请你加入群聊"高原ོ"邀请你加入群聊Wechaty Developers' Home 2,进入可查看详情。view5000http://support.weixin.qq.com/cgi-bin/mmsupport-bin/addchatroombyinvite?ticket=AVs3velIDxTkA0EOhKogxg%3D%3D0http://weixin.qq.com/cgi-bin/getheadimg?username=42e4fc96ae9472a2063bbabbe1cfbddbe3b59b105d1d59c217099cb8f3441f95lylezhuifeng01',
fromUser: 'lylezhuifeng',
messageId: '7724778097781555979',
messageSource: '\n',
messageType: 49,
status: 1,
timestamp: 1532158619,
toUser: 'wxid_rdwh63c150bm12',
}
const EXPECTED_EVENT: PadproRoomInviteEvent = {
fromUser: 'lylezhuifeng',
msgId: '7724778097781555979',
roomName: 'Wechaty Developers\' Home 2',
timestamp: 1532158619,
url: 'http://support.weixin.qq.com/cgi-bin/mmsupport-bin/addchatroombyinvite?ticket=AVs3velIDxTkA0EOhKogxg%3D%3D',
}
const event = await roomInviteEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomInviteEventMessageParser() EN', async t => {
const MESSAGE_PAYLOAD: PadproMessagePayload = {
content: 'Group Chat Invitation"高原ོ" invited you to join the group chat "💃🏻这个群特别炸💃🏻". Enter to view details.view5000http://support.weixin.qq.com/cgi-bin/mmsupport-bin/addchatroombyinvite?ticket=AV5L4pEpxU7L8XAEFRxuHw%3D%3D0http://weixin.qq.com/cgi-bin/getheadimg?username=04ef81268a57fc57de56d6c64e2982669163556ca6bd32c2edccc34ee889052elylezhuifeng01',
data: '',
fromUser: 'lylezhuifeng',
messageId: '7969935287794034973',
messageSource: '\n',
messageType: 49,
status: 1,
timestamp: 1532273578,
toUser: 'wxid_rdwh63c150bm12',
}
const EXPECTED_EVENT: PadproRoomInviteEvent = {
fromUser: 'lylezhuifeng',
msgId: '7969935287794034973',
roomName: '💃🏻这个群特别炸💃🏻',
timestamp: 1532273578,
url: 'http://support.weixin.qq.com/cgi-bin/mmsupport-bin/addchatroombyinvite?ticket=AV5L4pEpxU7L8XAEFRxuHw%3D%3D',
}
const event = await roomInviteEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})