From 7c2dcab83725c1dce2df7529127d0ccf0aae095f Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Thu, 10 Aug 2023 15:16:40 +0300 Subject: [PATCH] testing: add `StandardGauge` stories --- src/components/StandardGauge.stories.tsx | 37 ++++++++++++++++++++++++ src/components/StandardGauge.tsx | 5 ++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/components/StandardGauge.stories.tsx diff --git a/src/components/StandardGauge.stories.tsx b/src/components/StandardGauge.stories.tsx new file mode 100644 index 00000000..fdeeeac6 --- /dev/null +++ b/src/components/StandardGauge.stories.tsx @@ -0,0 +1,37 @@ +import type { Meta, StoryObj } from '@storybook/react' + +import StandardGauge from './StandardGauge' + +const meta = { + title: 'General/StandardGauge', + component: StandardGauge, + parameters: { + layout: 'centered', + }, + tags: ['autodocs'], + decorators: [ + Story => ( +
+ +
+ ), + ], +} satisfies Meta + +export default meta +type Story = StoryObj + +export const WithDataPoints: Story = { + args: { + data: [ + { id: '1', color: 'red', label: 'Red', value: 42 }, + { id: '2', color: 'blue', label: 'Blue', value: 1337 }, + ], + }, +} + +export const WithoutDataPoints: Story = { + args: { + data: [], + }, +} diff --git a/src/components/StandardGauge.tsx b/src/components/StandardGauge.tsx index 6db42bb7..5db9a1a6 100644 --- a/src/components/StandardGauge.tsx +++ b/src/components/StandardGauge.tsx @@ -1,13 +1,14 @@ import { ResponsivePie } from '@nivo/pie' -interface Data { +export interface GaugeDataPoint { id: string label: string value: number color: string } + interface StandardGaugeProps { - data: Data[] + data: GaugeDataPoint[] } const StandardGauge = ({ data }: StandardGaugeProps) => (