You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haoliang-net/tests/LogsDashboard.test.ts

34 lines
855 B
TypeScript

import { describe, it, expect } from 'vitest'
type LogItem = {
id: string
timestamp: string
machineId: string
programName: string
level: string
message: string
}
type DashboardData = {
total: number
counts: Record<string, number>
logs: LogItem[]
analysis?: string
}
describe('日志看板数据结构', () => {
it('应包含 logs、counts、total 字段且类型正确', () => {
const sample: DashboardData = {
total: 5,
counts: { ERROR: 1, INFO: 4 },
logs: [
{ id: 'l1', timestamp: '2026-05-01T12:00:00Z', machineId: 'M1', programName: 'ProgA', level: 'ERROR', message: 'Something failed' }
],
analysis: '最近一次采集无显著趋势'
}
expect(sample).toHaveProperty('logs')
expect(sample).toHaveProperty('counts')
expect(typeof sample.total).toBe('number')
})
})