testing: add `HealthInfoSection` stories
This commit is contained in:
parent
7c2dcab837
commit
dcb5f85403
|
@ -0,0 +1,70 @@
|
|||
import type { Meta, StoryObj } from '@storybook/react'
|
||||
|
||||
import HealthInfoSection from './HealthInfoSection'
|
||||
|
||||
const meta = {
|
||||
title: 'Device Health/HealthInfoSection',
|
||||
component: HealthInfoSection,
|
||||
parameters: {
|
||||
layout: 'centered',
|
||||
},
|
||||
tags: ['autodocs'],
|
||||
} satisfies Meta<typeof HealthInfoSection>
|
||||
|
||||
export default meta
|
||||
type Story = StoryObj<typeof meta>
|
||||
|
||||
export const AllGoodStats: Story = {
|
||||
args: {
|
||||
usedStorage: 79 * 1024 * 1024 * 1024,
|
||||
maxStorage: 100 * 1024 * 1024 * 1024,
|
||||
usedRamMemory: 32 * 1024 * 1024 * 1024,
|
||||
maxRamMemory: 64 * 1024 * 1024 * 1024,
|
||||
cpuClockRate: 2.4,
|
||||
networkLatency: 50,
|
||||
},
|
||||
}
|
||||
|
||||
export const StorageBad: Story = {
|
||||
args: {
|
||||
usedStorage: 80 * 1024 * 1024 * 1024,
|
||||
maxStorage: 100 * 1024 * 1024 * 1024,
|
||||
usedRamMemory: 32 * 1024 * 1024 * 1024,
|
||||
maxRamMemory: 64 * 1024 * 1024 * 1024,
|
||||
cpuClockRate: 2.5,
|
||||
networkLatency: 50,
|
||||
},
|
||||
}
|
||||
|
||||
export const CpuBad: Story = {
|
||||
args: {
|
||||
usedStorage: 79 * 1024 * 1024 * 1024,
|
||||
maxStorage: 100 * 1024 * 1024 * 1024,
|
||||
usedRamMemory: 32 * 1024 * 1024 * 1024,
|
||||
maxRamMemory: 64 * 1024 * 1024 * 1024,
|
||||
cpuClockRate: 2.3,
|
||||
networkLatency: 50,
|
||||
},
|
||||
}
|
||||
|
||||
export const RamBad: Story = {
|
||||
args: {
|
||||
usedStorage: 79 * 1024 * 1024 * 1024,
|
||||
maxStorage: 100 * 1024 * 1024 * 1024,
|
||||
usedRamMemory: 56 * 1024 * 1024 * 1024,
|
||||
maxRamMemory: 64 * 1024 * 1024 * 1024,
|
||||
cpuClockRate: 2.4,
|
||||
networkLatency: 50,
|
||||
},
|
||||
}
|
||||
|
||||
export const LatencyBad: Story = {
|
||||
args: {
|
||||
usedStorage: 79 * 1024 * 1024 * 1024,
|
||||
maxStorage: 100 * 1024 * 1024 * 1024,
|
||||
usedRamMemory: 32 * 1024 * 1024 * 1024,
|
||||
maxRamMemory: 64 * 1024 * 1024 * 1024,
|
||||
cpuClockRate: 2.4,
|
||||
networkLatency: 101,
|
||||
},
|
||||
}
|
|
@ -26,7 +26,7 @@ const HealthInfoSection = (props: HealthInfoSectionProps) => {
|
|||
|
||||
const usedStoragePercentage = (usedStorage / maxStorage) * 100
|
||||
const usedRamMemoryPercentage = (usedRamMemory / maxRamMemory) * 100
|
||||
const cpuClockRatePercentage = cpuClockRate > 2.4 ? 100 : 0
|
||||
const cpuClockRatePercentage = cpuClockRate < 2.4 ? 100 : 0
|
||||
const networkLatencyPercentage = networkLatency > 100 ? 100 : 0
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue