#!/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() ZH-bot-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: 1595936004247, fromUserName: '24674062762@chatroom', imgBuf: '', imgStatus: 1, l1MsgType: 5, msgId: '4392351666543040436', msgSource: '', msgSourceCd: 2, msgType: 10002, newMsgId: 4392351666543040500, pushContent: '', status: 4, toUserName: 'wxid_zovb9ol86m7l22', uin: '2963338780', wechatUserName: 'wxid_zovb9ol86m7l22', } const EXPECTED_EVENT: RoomTopicEvent = { changerId: 'wxid_8kg1wdu3jvk322', roomId: '24674062762@chatroom', timestamp: 1595936004247, topic: '测试群', } const event = await roomTopicEventMessageParser(MESSAGE_PAYLOAD) t.deepEqual(event, EXPECTED_EVENT, 'should parse event') }) test('roomTopicEventMessageParser() ZH-other-modify-topic', async t => { const MESSAGE_PAYLOAD: PadplusMessagePayload = { content: '你修改群名为“命名了”', createTime: 1568208437265, fromUserName: '18295482296@chatroom', imgBuf: '', imgStatus: 1, l1MsgType: 5, msgId: '3567919101394598675', msgSource: '', msgSourceCd: 2, msgType: 10000, newMsgId: 3567919101394599000, pushContent: '', status: 4, toUserName: 'wxid_zovb9ol86m7l22', uin: '2963338780', wechatUserName: 'wxid_zovb9ol86m7l22', } const EXPECTED_EVENT: RoomTopicEvent = { changerId: YOU, roomId: '18295482296@chatroom', timestamp: 1568208437265, topic: '命名了', } const event = await roomTopicEventMessageParser(MESSAGE_PAYLOAD) t.deepEqual(event, EXPECTED_EVENT, 'should parse event') })