@12-apps/ui 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -9
- package/src/button/index.ts +1 -0
- package/src/social-login-button/index.ts +1 -0
- package/src/{social-login-button.tsx → social-login-button/social-login-button.tsx} +5 -5
- package/src/user-avatar/index.ts +1 -0
- package/src/{user-avatar.tsx → user-avatar/user-avatar.tsx} +4 -4
- package/eslint.config.js +0 -89
- package/src/__tests__/data-grid.test.tsx +0 -125
- package/src/__tests__/package-wiring.test.ts +0 -41
- package/src/__tests__/setup.ts +0 -1
- package/src/__tests__/social-login-button.test.tsx +0 -186
- package/src/__tests__/user-avatar.test.tsx +0 -195
- package/src/__tests__/viewport.test.ts +0 -50
- package/src/components/command/__tests__/command.test.tsx +0 -112
- package/src/components/data-display/Alert/Alert.stories.tsx +0 -559
- package/src/components/data-display/Alert/Alert.test.stories.tsx +0 -707
- package/src/components/data-display/AlertDialog/AlertDialog.stories.tsx +0 -362
- package/src/components/data-display/AlertDialog/AlertDialog.test.stories.tsx +0 -763
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.stories.tsx +0 -230
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.test.stories.tsx +0 -270
- package/src/components/data-display/Avatar/Avatar.stories.tsx +0 -721
- package/src/components/data-display/Avatar/Avatar.test.stories.tsx +0 -822
- package/src/components/data-display/Badge/Badge.stories.tsx +0 -1134
- package/src/components/data-display/Badge/Badge.test.stories.tsx +0 -1194
- package/src/components/data-display/Banner/Banner.stories.tsx +0 -528
- package/src/components/data-display/Banner/Banner.test.stories.tsx +0 -511
- package/src/components/data-display/Carousel/Carousel.stories.tsx +0 -607
- package/src/components/data-display/Carousel/Carousel.test.stories.tsx +0 -701
- package/src/components/data-display/Chart/Chart.stories.tsx +0 -568
- package/src/components/data-display/Chart/Chart.test.stories.tsx +0 -174
- package/src/components/data-display/Chart/SpecChart.stories.tsx +0 -150
- package/src/components/data-display/Chart/SpecChart.test.stories.tsx +0 -56
- package/src/components/data-display/Chart/__tests__/SpecChart.test.tsx +0 -60
- package/src/components/data-display/Chart/__tests__/chart-format.test.ts +0 -43
- package/src/components/data-display/Chart/__tests__/chart-spec.test.ts +0 -119
- package/src/components/data-display/Chip/Chip.stories.tsx +0 -252
- package/src/components/data-display/Chip/Chip.test.stories.tsx +0 -266
- package/src/components/data-display/DataGrid/DataGrid.stories.tsx +0 -515
- package/src/components/data-display/DataGrid/DataGrid.test.stories.tsx +0 -653
- package/src/components/data-display/DataViews/__tests__/DataViewsGrid.test.tsx +0 -271
- package/src/components/data-display/DataViews/__tests__/DataViewsTableBase.test.tsx +0 -134
- package/src/components/data-display/DataViews/__tests__/SaveViewModal.test.tsx +0 -83
- package/src/components/data-display/DataViews/__tests__/data-views-filter.test.ts +0 -115
- package/src/components/data-display/DataViews/__tests__/data-views-preview.test.ts +0 -53
- package/src/components/data-display/DataViews/__tests__/range-pill.test.tsx +0 -114
- package/src/components/data-display/DataViews/base-card.stories.tsx +0 -136
- package/src/components/data-display/DescriptionItem/DescriptionItem.stories.tsx +0 -254
- package/src/components/data-display/EmptyState/EmptyState.stories.tsx +0 -282
- package/src/components/data-display/EmptyState/EmptyState.test.stories.tsx +0 -441
- package/src/components/data-display/ErrorState/ErrorState.stories.tsx +0 -110
- package/src/components/data-display/ErrorState/ErrorState.test.stories.tsx +0 -133
- package/src/components/data-display/HoverCard/HoverCard.stories.tsx +0 -650
- package/src/components/data-display/HoverCard/HoverCard.test.stories.tsx +0 -929
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.stories.tsx +0 -411
- package/src/components/data-display/LazyImage/LazyImage.stories.tsx +0 -387
- package/src/components/data-display/Lightbox/Lightbox.stories.tsx +0 -315
- package/src/components/data-display/Lightbox/Lightbox.test.stories.tsx +0 -598
- package/src/components/data-display/LoadingState/LoadingState.stories.tsx +0 -124
- package/src/components/data-display/LoadingState/LoadingState.test.stories.tsx +0 -99
- package/src/components/data-display/MapPreview/MapPreview.stories.tsx +0 -458
- package/src/components/data-display/MapPreview/MapPreview.test.stories.tsx +0 -394
- package/src/components/data-display/Popover/Popover.stories.tsx +0 -295
- package/src/components/data-display/Popover/Popover.test.stories.tsx +0 -1162
- package/src/components/data-display/Progress/Progress.stories.tsx +0 -481
- package/src/components/data-display/Progress/Progress.test.stories.tsx +0 -2070
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.stories.tsx +0 -160
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.test.stories.tsx +0 -190
- package/src/components/data-display/Sheet/Sheet.stories.tsx +0 -883
- package/src/components/data-display/Sheet/Sheet.test.stories.tsx +0 -1105
- package/src/components/data-display/StatCard/StatCard.stories.tsx +0 -167
- package/src/components/data-display/StatCard/StatCard.test.stories.tsx +0 -240
- package/src/components/data-display/Stepper/Stepper.stories.tsx +0 -540
- package/src/components/data-display/Stepper/Stepper.test.stories.tsx +0 -600
- package/src/components/data-display/Table/Table.stories.tsx +0 -803
- package/src/components/data-display/Table/Table.test.stories.tsx +0 -369
- package/src/components/data-display/Timeline/Timeline.stories.tsx +0 -442
- package/src/components/data-display/Timeline/Timeline.test.stories.tsx +0 -930
- package/src/components/data-display/TimingDiagram/TimingDiagram.stories.tsx +0 -475
- package/src/components/data-display/TimingDiagram/TimingDiagram.test.stories.tsx +0 -734
- package/src/components/data-display/Tooltip/Tooltip.stories.tsx +0 -468
- package/src/components/data-display/Tooltip/Tooltip.test.stories.tsx +0 -1154
- package/src/components/feedback/ConfirmAction/ConfirmAction.stories.tsx +0 -146
- package/src/components/feedback/ConfirmAction/ConfirmAction.test.stories.tsx +0 -114
- package/src/components/feedback/ConfirmAction/__tests__/confirm-action.test.tsx +0 -288
- package/src/components/feedback/Dialog/Dialog.stories.tsx +0 -833
- package/src/components/feedback/Dialog/Dialog.test.stories.tsx +0 -964
- package/src/components/feedback/Dialog/__tests__/dialog-content-spacing.test.tsx +0 -66
- package/src/components/feedback/Modal/Modal.stories.tsx +0 -765
- package/src/components/feedback/Modal/Modal.test.stories.tsx +0 -251
- package/src/components/feedback/Sonner/Sonner.stories.tsx +0 -698
- package/src/components/feedback/Sonner/Sonner.test.stories.tsx +0 -896
- package/src/components/feedback/StackedModal/StackedModal.stories.tsx +0 -1783
- package/src/components/feedback/StackedModal/StackedModal.test.stories.tsx +0 -973
- package/src/components/feedback/StackedModal/__tests__/stacked-modal-viewport.test.tsx +0 -104
- package/src/components/feedback/Toast/Toast.stories.tsx +0 -548
- package/src/components/feedback/Toast/Toast.test.stories.tsx +0 -834
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.stories.tsx +0 -691
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.test.stories.tsx +0 -634
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.stories.tsx +0 -665
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.test.stories.tsx +0 -727
- package/src/components/form/Autocomplete/Autocomplete.stories.tsx +0 -715
- package/src/components/form/Autocomplete/Autocomplete.test.stories.tsx +0 -825
- package/src/components/form/Button/Button.stories.tsx +0 -365
- package/src/components/form/Button/Button.test.stories.tsx +0 -607
- package/src/components/form/Calendar/Calendar.stories.tsx +0 -349
- package/src/components/form/Calendar/Calendar.test.stories.tsx +0 -464
- package/src/components/form/CepField/CepField.stories.tsx +0 -138
- package/src/components/form/CepField/CepField.test.stories.tsx +0 -281
- package/src/components/form/Checkbox/Checkbox.stories.tsx +0 -265
- package/src/components/form/Checkbox/Checkbox.test.stories.tsx +0 -181
- package/src/components/form/CodeEditor/CodeEditor.stories.tsx +0 -871
- package/src/components/form/CodeEditor/CodeEditor.test.stories.tsx +0 -574
- package/src/components/form/Command/Command.stories.tsx +0 -580
- package/src/components/form/Command/Command.test.stories.tsx +0 -215
- package/src/components/form/CreatableSelect/CreatableSelect.stories.tsx +0 -112
- package/src/components/form/CreatableSelect/CreatableSelect.test.stories.tsx +0 -134
- package/src/components/form/Form/Form.stories.tsx +0 -687
- package/src/components/form/Form/Form.test.stories.tsx +0 -601
- package/src/components/form/Input/Input.stories.tsx +0 -260
- package/src/components/form/Input/Input.test.stories.tsx +0 -1191
- package/src/components/form/InputOTP/InputOTP.stories.tsx +0 -774
- package/src/components/form/InputOTP/InputOTP.test.stories.tsx +0 -588
- package/src/components/form/Label/Label.stories.tsx +0 -473
- package/src/components/form/Label/Label.test.stories.tsx +0 -915
- package/src/components/form/Menubar/Menubar.stories.tsx +0 -472
- package/src/components/form/Menubar/Menubar.test.stories.tsx +0 -584
- package/src/components/form/PasswordStrength/PasswordStrength.stories.tsx +0 -562
- package/src/components/form/PasswordStrength/PasswordStrength.test.stories.tsx +0 -327
- package/src/components/form/PhoneInput/PhoneInput.stories.tsx +0 -495
- package/src/components/form/PhoneInput/PhoneInput.test.stories.tsx +0 -666
- package/src/components/form/RadioGroup/RadioGroup.stories.tsx +0 -518
- package/src/components/form/RadioGroup/RadioGroup.test.stories.tsx +0 -685
- package/src/components/form/RichTextEditor/RichTextEditor.stories.tsx +0 -261
- package/src/components/form/RichTextEditor/RichTextEditor.test.stories.tsx +0 -491
- package/src/components/form/SearchPalette/SearchPalette.stories.tsx +0 -135
- package/src/components/form/Select/Select.stories.tsx +0 -364
- package/src/components/form/Select/Select.test.stories.tsx +0 -985
- package/src/components/form/Slider/Slider.stories.tsx +0 -418
- package/src/components/form/Slider/Slider.test.stories.tsx +0 -1042
- package/src/components/form/Switch/Switch.stories.tsx +0 -697
- package/src/components/form/Switch/Switch.test.stories.tsx +0 -597
- package/src/components/form/Textarea/Textarea.stories.tsx +0 -473
- package/src/components/form/Textarea/Textarea.test.stories.tsx +0 -702
- package/src/components/form/Toggle/Toggle.stories.tsx +0 -638
- package/src/components/form/Toggle/Toggle.test.stories.tsx +0 -1159
- package/src/components/form/ToggleGroup/ToggleGroup.stories.tsx +0 -617
- package/src/components/form/ToggleGroup/ToggleGroup.test.stories.tsx +0 -915
- package/src/components/form/UploadButton/UploadButton.stories.tsx +0 -367
- package/src/components/form/UploadButton/UploadButton.test.stories.tsx +0 -573
- package/src/components/form/total-form/total-form.test.tsx +0 -214
- package/src/components/layout/Accordion/Accordion.stories.tsx +0 -694
- package/src/components/layout/Accordion/Accordion.test.stories.tsx +0 -1344
- package/src/components/layout/Card/Card.stories.tsx +0 -591
- package/src/components/layout/Card/Card.test.stories.tsx +0 -1134
- package/src/components/layout/CardGrid/__tests__/CardGrid.test.tsx +0 -92
- package/src/components/layout/Collapsible/Collapsible.stories.tsx +0 -180
- package/src/components/layout/Collapsible/Collapsible.test.stories.tsx +0 -308
- package/src/components/layout/Container/Container.stories.tsx +0 -557
- package/src/components/layout/Container/Container.test.stories.tsx +0 -745
- package/src/components/layout/ContentToolbar/ContentToolbar.stories.tsx +0 -129
- package/src/components/layout/ContentToolbar/ContentToolbar.test.stories.tsx +0 -251
- package/src/components/layout/ContentToolbar/__tests__/ColumnsMenu.test.tsx +0 -39
- package/src/components/layout/ContentToolbar/__tests__/MultiSelectDropdown.test.tsx +0 -131
- package/src/components/layout/ContentToolbar/__tests__/SavedViewsMenu.test.tsx +0 -99
- package/src/components/layout/Dashboard/Dashboard.stories.tsx +0 -104
- package/src/components/layout/Dashboard/Dashboard.test.stories.tsx +0 -190
- package/src/components/layout/Drawer/Drawer.stories.tsx +0 -658
- package/src/components/layout/Drawer/Drawer.test.stories.tsx +0 -1343
- package/src/components/layout/Resizable/Resizable.stories.tsx +0 -1039
- package/src/components/layout/Resizable/Resizable.test.stories.tsx +0 -754
- package/src/components/layout/ScrollArea/ScrollArea.stories.tsx +0 -651
- package/src/components/layout/ScrollArea/ScrollArea.test.stories.tsx +0 -619
- package/src/components/layout/Separator/Separator.stories.tsx +0 -563
- package/src/components/layout/Separator/Separator.test.stories.tsx +0 -518
- package/src/components/layout/SettingsLayout/SettingsLayout.stories.tsx +0 -192
- package/src/components/layout/SettingsLayout/SettingsLayout.test.stories.tsx +0 -175
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -609
- package/src/components/layout/Sidebar/Sidebar.test.stories.tsx +0 -1324
- package/src/components/layout/Skeleton/Skeleton.stories.tsx +0 -689
- package/src/components/layout/Skeleton/Skeleton.test.stories.tsx +0 -521
- package/src/components/layout/Spacer/Spacer.stories.tsx +0 -502
- package/src/components/layout/Spacer/Spacer.test.stories.tsx +0 -474
- package/src/components/layout/TableFilter/TableFilter.stories.tsx +0 -82
- package/src/components/layout/TableFilter/TableFilter.test.stories.tsx +0 -87
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.stories.tsx +0 -638
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.test.stories.tsx +0 -1008
- package/src/components/navigation/CommandPalette/CommandPalette.stories.tsx +0 -386
- package/src/components/navigation/CommandPalette/CommandPalette.test.stories.tsx +0 -435
- package/src/components/navigation/ContextMenu/ContextMenu.stories.tsx +0 -614
- package/src/components/navigation/ContextMenu/ContextMenu.test.stories.tsx +0 -845
- package/src/components/navigation/DropdownMenu/DropdownMenu.stories.tsx +0 -578
- package/src/components/navigation/DropdownMenu/DropdownMenu.test.stories.tsx +0 -660
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.stories.tsx +0 -516
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.test.stories.tsx +0 -935
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuHorizontal.stories.tsx +0 -501
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuVertical.stories.tsx +0 -453
- package/src/components/navigation/Pagination/Pagination.stories.tsx +0 -602
- package/src/components/navigation/Pagination/Pagination.test.stories.tsx +0 -520
- package/src/components/navigation/Tabs/Tabs.stories.tsx +0 -1004
- package/src/components/navigation/Tabs/Tabs.test.stories.tsx +0 -1225
- package/src/components/typography/Blockquote/Blockquote.stories.tsx +0 -359
- package/src/components/typography/Blockquote/Blockquote.test.stories.tsx +0 -432
- package/src/components/typography/Code/Code.stories.tsx +0 -686
- package/src/components/typography/Code/Code.test.stories.tsx +0 -703
- package/src/components/typography/Heading/Heading.stories.tsx +0 -451
- package/src/components/typography/Heading/Heading.test.stories.tsx +0 -830
- package/src/components/typography/Paragraph/Paragraph.stories.tsx +0 -280
- package/src/components/typography/Paragraph/Paragraph.test.stories.tsx +0 -231
- package/src/components/typography/Text/Text.stories.tsx +0 -359
- package/src/components/typography/Text/Text.test.stories.tsx +0 -759
- package/src/components/utility/AnimatedIcon/AnimatedIcon.stories.tsx +0 -945
- package/src/components/utility/AnimatedIcon/AnimatedIcon.test.stories.tsx +0 -603
- package/src/components/utility/AspectRatio/AspectRatio.stories.tsx +0 -414
- package/src/components/utility/AspectRatio/AspectRatio.test.stories.tsx +0 -859
- package/src/components/utility/InfiniteScroll/InfiniteScroll.stories.tsx +0 -620
- package/src/components/utility/InfiniteScroll/InfiniteScroll.test.stories.tsx +0 -361
- package/src/components/utility/InstallPrompt/InstallPrompt.stories.tsx +0 -118
- package/src/components/utility/InstallPrompt/InstallPrompt.test.stories.tsx +0 -83
- package/src/components/utility/InstallPrompt/__tests__/InstallPrompt.ios.test.tsx +0 -65
- package/src/components/utility/InstallPrompt/__tests__/usePwaInstall.test.tsx +0 -271
- package/src/components/utility/Portal/Portal.stories.tsx +0 -340
- package/src/components/utility/Portal/Portal.test.stories.tsx +0 -2086
- package/src/components/utility/Transition/Transition.stories.tsx +0 -493
- package/src/components/utility/Transition/Transition.test.stories.tsx +0 -854
- package/src/components/utility/VirtualList/VirtualList.stories.tsx +0 -1073
- package/src/components/utility/VirtualList/VirtualList.test.stories.tsx +0 -1085
- package/src/components/utility/WorkflowStep/WorkflowStep.stories.tsx +0 -431
- package/src/components/utility/WorkflowStep/WorkflowStep.test.stories.tsx +0 -364
- /package/src/{button.tsx → button/button.tsx} +0 -0
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { expect, fn, within } from 'storybook/test';
|
|
3
|
-
|
|
4
|
-
import { Chart } from './Chart';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Chart> = {
|
|
7
|
-
title: 'DataDisplay/Chart/Tests',
|
|
8
|
-
component: Chart,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: 'centered',
|
|
11
|
-
chromatic: { disableSnapshot: false },
|
|
12
|
-
},
|
|
13
|
-
tags: ['autodocs', 'test', 'component:Chart'],
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default meta;
|
|
17
|
-
export type Story = StoryObj<typeof meta>;
|
|
18
|
-
|
|
19
|
-
// Test data
|
|
20
|
-
const testData = [
|
|
21
|
-
{ name: 'Jan', sales: 4000 },
|
|
22
|
-
{ name: 'Feb', sales: 3000 },
|
|
23
|
-
{ name: 'Mar', sales: 2000 },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
// Basic interaction test
|
|
27
|
-
export const BasicInteraction: Story = {
|
|
28
|
-
args: {
|
|
29
|
-
type: 'line',
|
|
30
|
-
data: testData,
|
|
31
|
-
series: [{ dataKey: 'sales', name: 'Sales' }],
|
|
32
|
-
title: 'Test Chart',
|
|
33
|
-
onClick: fn(),
|
|
34
|
-
},
|
|
35
|
-
play: async ({ canvasElement }) => {
|
|
36
|
-
const canvas = within(canvasElement);
|
|
37
|
-
const title = canvas.getByText('Test Chart');
|
|
38
|
-
expect(title).toBeInTheDocument();
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const FormInteraction: Story = {
|
|
43
|
-
args: {
|
|
44
|
-
type: 'bar',
|
|
45
|
-
data: testData,
|
|
46
|
-
series: [{ dataKey: 'sales', name: 'Sales' }],
|
|
47
|
-
title: 'Bar Test',
|
|
48
|
-
},
|
|
49
|
-
play: async ({ canvasElement }) => {
|
|
50
|
-
const canvas = within(canvasElement);
|
|
51
|
-
const title = canvas.getByText('Bar Test');
|
|
52
|
-
expect(title).toBeInTheDocument();
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const KeyboardNavigation: Story = {
|
|
57
|
-
args: {
|
|
58
|
-
type: 'line',
|
|
59
|
-
data: testData,
|
|
60
|
-
title: 'Keyboard Test',
|
|
61
|
-
},
|
|
62
|
-
play: async ({ canvasElement }) => {
|
|
63
|
-
const canvas = within(canvasElement);
|
|
64
|
-
const title = canvas.getByText('Keyboard Test');
|
|
65
|
-
expect(title).toBeInTheDocument();
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const ScreenReader: Story = {
|
|
70
|
-
args: {
|
|
71
|
-
type: 'pie',
|
|
72
|
-
data: [{ name: 'A', value: 50 }],
|
|
73
|
-
title: 'Accessibility Test',
|
|
74
|
-
},
|
|
75
|
-
play: async ({ canvasElement }) => {
|
|
76
|
-
const canvas = within(canvasElement);
|
|
77
|
-
const title = canvas.getByText('Accessibility Test');
|
|
78
|
-
expect(title).toBeInTheDocument();
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const FocusManagement: Story = {
|
|
83
|
-
args: {
|
|
84
|
-
type: 'bar',
|
|
85
|
-
data: testData,
|
|
86
|
-
title: 'Focus Test',
|
|
87
|
-
},
|
|
88
|
-
play: async ({ canvasElement }) => {
|
|
89
|
-
const canvas = within(canvasElement);
|
|
90
|
-
const title = canvas.getByText('Focus Test');
|
|
91
|
-
expect(title).toBeInTheDocument();
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export const ResponsiveDesign: Story = {
|
|
96
|
-
args: {
|
|
97
|
-
type: 'line',
|
|
98
|
-
data: testData,
|
|
99
|
-
title: 'Responsive Test',
|
|
100
|
-
responsive: true,
|
|
101
|
-
},
|
|
102
|
-
play: async ({ canvasElement }) => {
|
|
103
|
-
const canvas = within(canvasElement);
|
|
104
|
-
const title = canvas.getByText('Responsive Test');
|
|
105
|
-
expect(title).toBeInTheDocument();
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const ThemeVariations: Story = {
|
|
110
|
-
args: {
|
|
111
|
-
type: 'area',
|
|
112
|
-
data: testData,
|
|
113
|
-
title: 'Theme Test',
|
|
114
|
-
},
|
|
115
|
-
play: async ({ canvasElement }) => {
|
|
116
|
-
const canvas = within(canvasElement);
|
|
117
|
-
const title = canvas.getByText('Theme Test');
|
|
118
|
-
expect(title).toBeInTheDocument();
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const VisualStates: Story = {
|
|
123
|
-
args: {
|
|
124
|
-
type: 'bar',
|
|
125
|
-
data: testData,
|
|
126
|
-
title: 'Visual Test',
|
|
127
|
-
variant: 'elevated',
|
|
128
|
-
},
|
|
129
|
-
play: async ({ canvasElement }) => {
|
|
130
|
-
const canvas = within(canvasElement);
|
|
131
|
-
const title = canvas.getByText('Visual Test');
|
|
132
|
-
expect(title).toBeInTheDocument();
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export const Performance: Story = {
|
|
137
|
-
args: {
|
|
138
|
-
type: 'line',
|
|
139
|
-
data: testData,
|
|
140
|
-
title: 'Performance Test',
|
|
141
|
-
},
|
|
142
|
-
play: async ({ canvasElement }) => {
|
|
143
|
-
const canvas = within(canvasElement);
|
|
144
|
-
const title = canvas.getByText('Performance Test');
|
|
145
|
-
expect(title).toBeInTheDocument();
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export const EdgeCases: Story = {
|
|
150
|
-
args: {
|
|
151
|
-
type: 'line',
|
|
152
|
-
data: [{ name: 'Single', value: 42 }],
|
|
153
|
-
title: 'Edge Test',
|
|
154
|
-
},
|
|
155
|
-
play: async ({ canvasElement }) => {
|
|
156
|
-
const canvas = within(canvasElement);
|
|
157
|
-
const title = canvas.getByText('Edge Test');
|
|
158
|
-
expect(title).toBeInTheDocument();
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
export const Integration: Story = {
|
|
163
|
-
args: {
|
|
164
|
-
type: 'composed',
|
|
165
|
-
data: testData,
|
|
166
|
-
title: 'Integration Test',
|
|
167
|
-
showLegend: true,
|
|
168
|
-
},
|
|
169
|
-
play: async ({ canvasElement }) => {
|
|
170
|
-
const canvas = within(canvasElement);
|
|
171
|
-
const title = canvas.getByText('Integration Test');
|
|
172
|
-
expect(title).toBeInTheDocument();
|
|
173
|
-
},
|
|
174
|
-
};
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { SpecChart } from './SpecChart';
|
|
5
|
-
import type { ChartSpec } from './ChartSpec.types';
|
|
6
|
-
|
|
7
|
-
const meta: Meta<typeof SpecChart> = {
|
|
8
|
-
title: 'DataDisplay/SpecChart',
|
|
9
|
-
component: SpecChart,
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: 'padded',
|
|
12
|
-
docs: {
|
|
13
|
-
description: {
|
|
14
|
-
component:
|
|
15
|
-
'Renders a chart from a JSON-serializable ChartSpec plus plain data rows. ' +
|
|
16
|
-
'The spec API is layered over the prop-driven Chart — same implementation, ' +
|
|
17
|
-
'declarative surface for report builders and LLM authoring.',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
tags: ['autodocs', 'component:Chart'],
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default meta;
|
|
25
|
-
type Story = StoryObj<typeof meta>;
|
|
26
|
-
|
|
27
|
-
const salesByDay = [
|
|
28
|
-
{ day: 'Seg', total: 125000, perdas: 4500 },
|
|
29
|
-
{ day: 'Ter', total: 98000, perdas: 1200 },
|
|
30
|
-
{ day: 'Qua', total: 143500, perdas: 0 },
|
|
31
|
-
{ day: 'Qui', total: 110200, perdas: 7300 },
|
|
32
|
-
{ day: 'Sex', total: 189900, perdas: 2100 },
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
const paymentMethods = [
|
|
36
|
-
{ method: 'PIX', total: 420000 },
|
|
37
|
-
{ method: 'Cartão', total: 310000 },
|
|
38
|
-
{ method: 'Garçom', total: 86000 },
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
const lineSpec: ChartSpec = {
|
|
42
|
-
type: 'line',
|
|
43
|
-
title: 'Vendas por dia',
|
|
44
|
-
subtitle: 'Receita líquida (BRL)',
|
|
45
|
-
xAxis: { key: 'day' },
|
|
46
|
-
series: [{ key: 'total', label: 'Total', color: 'primary' }],
|
|
47
|
-
numberFormat: 'brl',
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const Line: Story = {
|
|
51
|
-
args: { spec: lineSpec, data: salesByDay },
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const StackedBars: Story = {
|
|
55
|
-
args: {
|
|
56
|
-
spec: {
|
|
57
|
-
type: 'bar',
|
|
58
|
-
title: 'Vendas vs perdas',
|
|
59
|
-
xAxis: { key: 'day' },
|
|
60
|
-
series: [
|
|
61
|
-
{ key: 'total', label: 'Vendas', color: 'primary' },
|
|
62
|
-
{ key: 'perdas', label: 'Perdas', color: 'error' },
|
|
63
|
-
],
|
|
64
|
-
stacked: true,
|
|
65
|
-
numberFormat: 'brl',
|
|
66
|
-
},
|
|
67
|
-
data: salesByDay,
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const Area: Story = {
|
|
72
|
-
args: {
|
|
73
|
-
spec: { ...lineSpec, type: 'area', title: 'Tendência de vendas' },
|
|
74
|
-
data: salesByDay,
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const Pie: Story = {
|
|
79
|
-
args: {
|
|
80
|
-
spec: {
|
|
81
|
-
type: 'pie',
|
|
82
|
-
title: 'Formas de pagamento',
|
|
83
|
-
xAxis: { key: 'method' },
|
|
84
|
-
series: [{ key: 'total' }],
|
|
85
|
-
numberFormat: 'brl',
|
|
86
|
-
},
|
|
87
|
-
data: paymentMethods,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const Donut: Story = {
|
|
92
|
-
args: {
|
|
93
|
-
spec: {
|
|
94
|
-
type: 'donut',
|
|
95
|
-
title: 'Formas de pagamento',
|
|
96
|
-
xAxis: { key: 'method' },
|
|
97
|
-
series: [{ key: 'total' }],
|
|
98
|
-
numberFormat: 'brl',
|
|
99
|
-
centerLabel: { label: 'Total', value: 'R$ 8.160' },
|
|
100
|
-
},
|
|
101
|
-
data: paymentMethods,
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const PercentFormat: Story = {
|
|
106
|
-
args: {
|
|
107
|
-
spec: {
|
|
108
|
-
type: 'bar',
|
|
109
|
-
title: 'Margem por dia',
|
|
110
|
-
xAxis: { key: 'day' },
|
|
111
|
-
series: [{ key: 'margin', label: 'Margem', color: 'success' }],
|
|
112
|
-
numberFormat: 'percent',
|
|
113
|
-
legend: false,
|
|
114
|
-
},
|
|
115
|
-
data: salesByDay.map((row) => ({ day: row.day, margin: row.total > 0 ? 0.2 + row.perdas / row.total : 0 })),
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const CustomColorScheme: Story = {
|
|
120
|
-
args: {
|
|
121
|
-
spec: {
|
|
122
|
-
...lineSpec,
|
|
123
|
-
type: 'bar',
|
|
124
|
-
title: 'Esquema de cores custom',
|
|
125
|
-
series: [
|
|
126
|
-
{ key: 'total', label: 'Total' },
|
|
127
|
-
{ key: 'perdas', label: 'Perdas' },
|
|
128
|
-
],
|
|
129
|
-
colorScheme: ['info', 'warning'],
|
|
130
|
-
},
|
|
131
|
-
data: salesByDay,
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export const FromJsonString: Story = {
|
|
136
|
-
render: () => {
|
|
137
|
-
const json =
|
|
138
|
-
'{"type":"area","title":"Spec vinda de JSON","xAxis":{"key":"day"},' +
|
|
139
|
-
'"series":[{"key":"total","label":"Total","color":"secondary"}],"numberFormat":"compact"}';
|
|
140
|
-
return <SpecChart spec={JSON.parse(json) as ChartSpec} data={salesByDay} />;
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const Loading: Story = {
|
|
145
|
-
args: { spec: lineSpec, data: [], loading: true },
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export const Empty: Story = {
|
|
149
|
-
args: { spec: { ...lineSpec, title: 'Sem dados' }, data: [] },
|
|
150
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { expect, within } from 'storybook/test';
|
|
3
|
-
|
|
4
|
-
import { SpecChart } from './SpecChart';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof SpecChart> = {
|
|
7
|
-
title: 'DataDisplay/SpecChart/Tests',
|
|
8
|
-
component: SpecChart,
|
|
9
|
-
parameters: { layout: 'padded' },
|
|
10
|
-
tags: ['autodocs', 'test', 'component:Chart'],
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default meta;
|
|
14
|
-
type Story = StoryObj<typeof meta>;
|
|
15
|
-
|
|
16
|
-
const data = [
|
|
17
|
-
{ day: 'Seg', total: 125000 },
|
|
18
|
-
{ day: 'Ter', total: 98000 },
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
export const RendersFromSpec: Story = {
|
|
22
|
-
args: {
|
|
23
|
-
spec: {
|
|
24
|
-
type: 'bar',
|
|
25
|
-
title: 'Spec Render',
|
|
26
|
-
xAxis: { key: 'day' },
|
|
27
|
-
series: [{ key: 'total', label: 'Total', color: 'primary' }],
|
|
28
|
-
numberFormat: 'brl',
|
|
29
|
-
},
|
|
30
|
-
data,
|
|
31
|
-
},
|
|
32
|
-
play: async ({ canvasElement }) => {
|
|
33
|
-
const canvas = within(canvasElement);
|
|
34
|
-
await expect(canvas.getByTestId('spec-chart')).toBeInTheDocument();
|
|
35
|
-
await expect(canvas.getByText('Spec Render')).toBeInTheDocument();
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const DonutCenterLabel: Story = {
|
|
40
|
-
args: {
|
|
41
|
-
spec: {
|
|
42
|
-
type: 'donut',
|
|
43
|
-
xAxis: { key: 'method' },
|
|
44
|
-
series: [{ key: 'total' }],
|
|
45
|
-
centerLabel: { label: 'Total', value: 'R$ 100' },
|
|
46
|
-
},
|
|
47
|
-
data: [
|
|
48
|
-
{ method: 'PIX', total: 60 },
|
|
49
|
-
{ method: 'Cartão', total: 40 },
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
play: async ({ canvasElement }) => {
|
|
53
|
-
const canvas = within(canvasElement);
|
|
54
|
-
await expect(canvas.getByTestId('spec-chart')).toBeInTheDocument();
|
|
55
|
-
},
|
|
56
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { describe, expect, it } from 'vitest';
|
|
4
|
-
|
|
5
|
-
import { parseChartSpec } from '../chart-spec';
|
|
6
|
-
import { SpecChart } from '../SpecChart';
|
|
7
|
-
|
|
8
|
-
const json = JSON.stringify({
|
|
9
|
-
type: 'bar',
|
|
10
|
-
title: 'Vendas por dia',
|
|
11
|
-
subtitle: 'Últimos 7 dias',
|
|
12
|
-
xAxis: { key: 'day' },
|
|
13
|
-
series: [
|
|
14
|
-
{ key: 'total', label: 'Total', color: 'primary' },
|
|
15
|
-
{ key: 'perdas', label: 'Perdas', color: 'error' },
|
|
16
|
-
],
|
|
17
|
-
numberFormat: 'brl',
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const data = [
|
|
21
|
-
{ day: 'seg', total: 1200, perdas: 100 },
|
|
22
|
-
{ day: 'ter', total: 3400, perdas: 0 },
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
describe('SpecChart', () => {
|
|
26
|
-
it('renders a chart from a pure JSON spec plus data rows', () => {
|
|
27
|
-
render(<SpecChart spec={parseChartSpec(JSON.parse(json))} data={data} />);
|
|
28
|
-
expect(screen.getByTestId('spec-chart')).toBeInTheDocument();
|
|
29
|
-
expect(screen.getByText('Vendas por dia')).toBeInTheDocument();
|
|
30
|
-
expect(screen.getByText('Últimos 7 dias')).toBeInTheDocument();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('renders pie specs', () => {
|
|
34
|
-
render(
|
|
35
|
-
<SpecChart
|
|
36
|
-
spec={parseChartSpec({
|
|
37
|
-
type: 'pie',
|
|
38
|
-
xAxis: { key: 'method' },
|
|
39
|
-
series: [{ key: 'total' }],
|
|
40
|
-
})}
|
|
41
|
-
data={[
|
|
42
|
-
{ method: 'PIX', total: 700 },
|
|
43
|
-
{ method: 'Cartão', total: 300 },
|
|
44
|
-
]}
|
|
45
|
-
/>,
|
|
46
|
-
);
|
|
47
|
-
expect(screen.getByTestId('spec-chart')).toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('shows the loading state', () => {
|
|
51
|
-
render(
|
|
52
|
-
<SpecChart
|
|
53
|
-
spec={parseChartSpec({ type: 'line', xAxis: { key: 'x' }, series: [{ key: 'y' }] })}
|
|
54
|
-
data={[]}
|
|
55
|
-
loading
|
|
56
|
-
/>,
|
|
57
|
-
);
|
|
58
|
-
expect(screen.getByTestId('spec-chart-loading')).toBeInTheDocument();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { chartValueFormatter, formatChartValue } from '../chart-format';
|
|
4
|
-
|
|
5
|
-
describe('formatChartValue', () => {
|
|
6
|
-
it('formats brl from integer centavos', () => {
|
|
7
|
-
const formatted = formatChartValue(123456, 'brl');
|
|
8
|
-
expect(formatted).toContain('R$');
|
|
9
|
-
expect(formatted).toContain('1.234,56');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('formats negative centavos', () => {
|
|
13
|
-
expect(formatChartValue(-500, 'brl')).toContain('5,00');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('formats percent from a fraction', () => {
|
|
17
|
-
expect(formatChartValue(0.153, 'percent')).toBe('15,3%');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('formats compact values', () => {
|
|
21
|
-
expect(formatChartValue(1500, 'compact')).toContain('1,5');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('formats integers without decimals', () => {
|
|
25
|
-
expect(formatChartValue(1234.56, 'integer')).toBe('1.235');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('defaults to decimal formatting', () => {
|
|
29
|
-
expect(formatChartValue(1234.567)).toBe('1.234,57');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('renders non-finite values as an empty string', () => {
|
|
33
|
-
expect(formatChartValue(Number.NaN, 'brl')).toBe('');
|
|
34
|
-
expect(formatChartValue(Number.POSITIVE_INFINITY)).toBe('');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('chartValueFormatter', () => {
|
|
39
|
-
it('curries the format', () => {
|
|
40
|
-
const format = chartValueFormatter('brl');
|
|
41
|
-
expect(format(100)).toContain('1,00');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import type { ChartSpec } from '../ChartSpec.types';
|
|
4
|
-
import { ChartSpecError, parseChartSpec, specToChartProps } from '../chart-spec';
|
|
5
|
-
import {
|
|
6
|
-
getRegisteredChartSpecTypes,
|
|
7
|
-
registerChartSpecRenderer,
|
|
8
|
-
type ChartSpecRenderContext,
|
|
9
|
-
} from '../chart-spec-registry';
|
|
10
|
-
|
|
11
|
-
const ctx: ChartSpecRenderContext = {
|
|
12
|
-
resolveColor: (token, index) => `${token ?? 'auto'}-${index}`,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const lineSpec: ChartSpec = {
|
|
16
|
-
type: 'line',
|
|
17
|
-
title: 'Vendas',
|
|
18
|
-
xAxis: { key: 'day' },
|
|
19
|
-
series: [{ key: 'total', label: 'Total', color: 'primary' }, { key: 'count' }],
|
|
20
|
-
numberFormat: 'brl',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
describe('parseChartSpec', () => {
|
|
24
|
-
it('accepts a valid spec round-tripped through JSON', () => {
|
|
25
|
-
const parsed = parseChartSpec(JSON.parse(JSON.stringify(lineSpec)));
|
|
26
|
-
expect(parsed.type).toBe('line');
|
|
27
|
-
expect(parsed.series).toHaveLength(2);
|
|
28
|
-
expect(parsed.xAxis.key).toBe('day');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('rejects non-objects', () => {
|
|
32
|
-
expect(() => parseChartSpec('nope')).toThrow(ChartSpecError);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('rejects unknown chart types and lists registered ones', () => {
|
|
36
|
-
expect(() => parseChartSpec({ ...lineSpec, type: 'sankey' })).toThrow(/registered chart types/);
|
|
37
|
-
expect(() => parseChartSpec({ ...lineSpec, type: 'sankey' })).toThrow(/line/);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('rejects a missing xAxis key', () => {
|
|
41
|
-
expect(() => parseChartSpec({ ...lineSpec, xAxis: {} })).toThrow(/"xAxis"/);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('rejects empty series', () => {
|
|
45
|
-
expect(() => parseChartSpec({ ...lineSpec, series: [] })).toThrow(/"series"/);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('rejects raw color values with an actionable message', () => {
|
|
49
|
-
expect(() => parseChartSpec({ ...lineSpec, series: [{ key: 'total', color: '#ff0000' }] })).toThrow(
|
|
50
|
-
/semantic color token/,
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('rejects invalid number formats', () => {
|
|
55
|
-
expect(() => parseChartSpec({ ...lineSpec, numberFormat: 'usd' })).toThrow(/"numberFormat"/);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('rejects invalid colorScheme entries', () => {
|
|
59
|
-
expect(() => parseChartSpec({ ...lineSpec, colorScheme: ['primary', 'magenta'] })).toThrow(
|
|
60
|
-
/"colorScheme\[1\]"/,
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe('specToChartProps', () => {
|
|
66
|
-
it('maps cartesian specs onto Chart props', () => {
|
|
67
|
-
const props = specToChartProps(lineSpec, [{ day: 'seg', total: 100, count: 2 }], ctx);
|
|
68
|
-
expect(props.type).toBe('line');
|
|
69
|
-
expect(props.xAxisKey).toBe('day');
|
|
70
|
-
expect(props.series).toEqual([
|
|
71
|
-
{ dataKey: 'total', name: 'Total', color: 'primary-0' },
|
|
72
|
-
{ dataKey: 'count', name: 'count', color: 'auto-1' },
|
|
73
|
-
]);
|
|
74
|
-
expect(props.valueFormatter?.(100)).toContain('1,00');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('honors stacked bars and legend/tooltip toggles', () => {
|
|
78
|
-
const props = specToChartProps(
|
|
79
|
-
{ ...lineSpec, type: 'bar', stacked: true, legend: false, tooltip: false },
|
|
80
|
-
[],
|
|
81
|
-
ctx,
|
|
82
|
-
);
|
|
83
|
-
expect(props.type).toBe('bar');
|
|
84
|
-
expect(props.stacked).toBe(true);
|
|
85
|
-
expect(props.showLegend).toBe(false);
|
|
86
|
-
expect(props.showTooltip).toBe(false);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('renders donut as pie with an inner radius and center label', () => {
|
|
90
|
-
const props = specToChartProps(
|
|
91
|
-
{
|
|
92
|
-
type: 'donut',
|
|
93
|
-
xAxis: { key: 'method' },
|
|
94
|
-
series: [{ key: 'total' }],
|
|
95
|
-
centerLabel: { label: 'Total', value: 'R$ 10' },
|
|
96
|
-
},
|
|
97
|
-
[],
|
|
98
|
-
ctx,
|
|
99
|
-
);
|
|
100
|
-
expect(props.type).toBe('pie');
|
|
101
|
-
expect(props.innerRadius).toBeGreaterThan(0);
|
|
102
|
-
expect(props.centerLabel).toEqual({ label: 'Total', value: 'R$ 10' });
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('supports registering new chart types without touching consumers', () => {
|
|
106
|
-
registerChartSpecRenderer('sparkline', (spec) => ({
|
|
107
|
-
type: 'line',
|
|
108
|
-
series: spec.series.map((s) => ({ dataKey: s.key })),
|
|
109
|
-
}));
|
|
110
|
-
expect(getRegisteredChartSpecTypes()).toContain('sparkline');
|
|
111
|
-
const spec = parseChartSpec({
|
|
112
|
-
type: 'sparkline',
|
|
113
|
-
xAxis: { key: 'x' },
|
|
114
|
-
series: [{ key: 'y' }],
|
|
115
|
-
});
|
|
116
|
-
const props = specToChartProps(spec, [], ctx);
|
|
117
|
-
expect(props.type).toBe('line');
|
|
118
|
-
});
|
|
119
|
-
});
|