41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
|
|
import SystemPerformanceCard from '../SystemPerformanceCard'
|
|
|
|
describe('SystemPerformanceCard', () => {
|
|
test('用容器口径显示内存,并在空闲时不假装还有排队', () => {
|
|
render(
|
|
<SystemPerformanceCard
|
|
loading={false}
|
|
error={null}
|
|
data={{
|
|
cpu: { usage: 2, loadAverage: [2.23, 1.51, 1.33], cores: 36 },
|
|
memory: {
|
|
used: 155,
|
|
total: 6144,
|
|
percentage: 3,
|
|
usedBytes: 162_533_376,
|
|
totalBytes: 6_442_450_944,
|
|
source: 'container',
|
|
hostUsedBytes: 14_342_000_000,
|
|
hostTotalBytes: 15_900_000_000,
|
|
hostPercentage: 90,
|
|
},
|
|
network: { uploadSpeed: 5700, downloadSpeed: 4500 },
|
|
uploadQueue: { total: 0, processing: [], waiting: [] },
|
|
transcodeQueue: { total: 0, maxConcurrent: 1, processing: [], waiting: [] },
|
|
}}
|
|
/>,
|
|
)
|
|
|
|
expect(screen.getByText('系统性能')).toBeInTheDocument()
|
|
expect(screen.getByText('36 核 · 1/5/15 分钟负载')).toBeInTheDocument()
|
|
expect(screen.getByText(/155 MB \/ 6 GB/)).toBeInTheDocument()
|
|
expect(screen.getByText(/整台机器大约用了 90%/)).toBeInTheDocument()
|
|
expect(screen.queryByText(/14342/)).not.toBeInTheDocument()
|
|
expect(screen.getAllByText('空闲')).toHaveLength(2)
|
|
expect(screen.getByText('本应用,不是整台机器')).toBeInTheDocument()
|
|
expect(screen.queryByText('加载中...')).not.toBeInTheDocument()
|
|
})
|
|
})
|