#!/usr/bin/env -S node --no-warnings --loader ts-node/esm /* eslint-disable sort-keys */ import { test } from 'tstest' import PuppetMini from './puppet-mini.js' import * as PUPPET from '@juzi/wechaty-puppet' import type { MiniMessagePayload } from './help/struct.js' /** * zrn-fight - https://github.com/zrn-fight * * 2021.10.14 * * This test can pass CI. * The job running on runner Hosted Agent will exceede the maximum execution time of 360 minutes. * * issue:https://github.com/wechaty/wechaty-puppet-walnut/issues/9 * */ test.skip('PuppetWalnut perfect restart testing', async t => { const puppet = new PuppetMini() for (let n = 0; n < 3; n++) { await puppet.start() await puppet.stop() t.pass('perfect restart succeed at #' + n) } }) const puppet = new PuppetMini({ token: 'mini_1325g3v4vs4xvu7snst', chatbotId: 'juzi_1qaz@WSX', mqName: 'kbl', mqPassword: '1qaz@WSX', encodeKey: '1K7eLVVfbmMy9oPu', encodeIv: '9meNaLuIP1JDpJYF', }) test('message parser for text message', async t => { const MiniMessagePayload: MiniMessagePayload = { id: '17112648589192', type: 7, text: 'hello world', talkerId: 'osudur6e7243', talkerName: '张三', talkerAvatar: 'https://img.aibotk.com/aibotk/public/yq3wWdBL0BnJV4Z1_mini-kbl-avatar.png', listenerId: 'juzi_1qaz@WSX', timestamp: 1711264858, } const messagePayload = await puppet.messageRawPayloadParser(MiniMessagePayload) t.ok( messagePayload.listenerId === 'juzi_1qaz@WSX' && messagePayload.talkerId === 'osudur6e7243' && messagePayload.text === 'hello world' && messagePayload.type === PUPPET.types.Message.Text, ) })