#!/usr/bin/env ts-node /* eslint-disable */ // tslint:disable:max-line-length // tslint:disable:no-shadowed-variable import test from 'blue-tape' import { YOU, } from 'wechaty-puppet' import { PadplusMessagePayload, RoomTopicEvent, } from '../schemas' import { roomTopicEventMessageParser } from './room-event-topic-message-parser' test('roomTopicEventMessageParser() EN-other-modify-topic', async t => { const MESSAGE_PAYLOAD: PadplusMessagePayload = { content: "24674062762@chatroom:\n\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\n\n", createTime: 1595937860255, fromMemberUserName: '24674062762@chatroom', fromUserName: '24674062762@chatroom', imgBuf: '', imgStatus: 1, l1MsgType: 5, msgId: '6943891507426521668', msgSource: '', msgSourceCd: 2, msgType: 10002, newMsgId: 6943891507426522000, pushContent: '', status: 4, toUserName: 'wxid_orp7dihe2pm112', uin: '289099750', wechatUserName: 'wxid_orp7dihe2pm112', } const EXPECTED_EVENT: RoomTopicEvent = { changerId: 'wxid_8kg1wdu3jvk322', roomId: '24674062762@chatroom', timestamp: 1595937860255, topic: 'new topic', } const event = await roomTopicEventMessageParser(MESSAGE_PAYLOAD) t.deepEqual(event, EXPECTED_EVENT, 'should parse event') }) test('roomTopicEventMessageParser() EN-bot-modify-topic', async t => { const MESSAGE_PAYLOAD: PadplusMessagePayload = { content: 'You changed the group name to \"new topic !\"', createTime: 1595938073258, fromUserName: '24674062762@chatroom', imgBuf: '', imgStatus: 1, l1MsgType: 5, msgId: '666326374143297636', msgSource: '', msgSourceCd: 2, msgType: 10002, newMsgId: 666326374143297700, pushContent: '', status: 4, toUserName: 'wxid_orp7dihe2pm112', uin: '289099750', wechatUserName: 'wxid_orp7dihe2pm112' } const EXPECTED_EVENT: RoomTopicEvent = { changerId: YOU, roomId: '24674062762@chatroom', timestamp: 1595938073258, topic: 'new topic !', } const event = await roomTopicEventMessageParser(MESSAGE_PAYLOAD) t.deepEqual(event, EXPECTED_EVENT, 'should parse event') })