2024-04-05 19:34:26 +00:00
|
|
|
import type { RedMessage } from '@chronocat/red'
|
2024-03-13 14:50:07 +00:00
|
|
|
import h from '@satorijs/element'
|
|
|
|
import { Messager } from '../../../../src/api/message/create/messager'
|
2024-04-05 19:34:26 +00:00
|
|
|
import { ctx, satoriConfig, saveResult } from '../../../mocks'
|
2024-03-13 14:50:07 +00:00
|
|
|
|
|
|
|
test('Red 编码器应当正确编码 纯文本消息', async () => {
|
2024-04-05 19:34:26 +00:00
|
|
|
const commonSend = jest.fn(async () => undefined as unknown as RedMessage)
|
|
|
|
const commonSave = jest.fn(async () => saveResult)
|
|
|
|
const commonSendForward = jest.fn(
|
|
|
|
async () => undefined as unknown as RedMessage,
|
|
|
|
)
|
|
|
|
|
2024-03-13 14:50:07 +00:00
|
|
|
await new Messager(
|
|
|
|
ctx,
|
|
|
|
satoriConfig,
|
|
|
|
{
|
|
|
|
send: commonSend,
|
|
|
|
save: commonSave,
|
|
|
|
sendForward: commonSendForward,
|
|
|
|
},
|
|
|
|
'9998',
|
|
|
|
).send(h.parse('xxx'))
|
|
|
|
|
|
|
|
const sendCalls = commonSend.mock.calls.map((x) => x.slice(1))
|
|
|
|
|
|
|
|
expect(sendCalls).toMatchSnapshot()
|
|
|
|
})
|