chronocat/packages/engine-chronocat-event/tests/parser/fixtures/f-5-8-3-8-4-8/index.test.ts

20 lines
692 B
TypeScript
Raw Normal View History

2024-03-13 14:20:55 +00:00
import type { RedMessage } from '@chronocat/red'
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
import { buildParser } from '../../../../src/parser'
import { ctx, satoriConfig } from '../../../mocks'
test('Red 解析器应当正确解析 群聊 群成员被禁言消息', async () => {
const message = JSON.parse(
(await readFile(join(__dirname, 'data.json'))).toString('utf-8'),
) as RedMessage
const events = await buildParser(ctx, satoriConfig)(message)
expect(events).toBeTruthy() // 解析到的消息应该存在
expect(events).toHaveLength(1) // 应当解析到 1 条消息
const [event] = events!
expect(event).toMatchSnapshot()
})