ywana-core8 0.1.103 → 0.2.1
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/dist/index.css +4941 -324
- package/dist/index.js +42338 -0
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +37458 -31678
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +39634 -34010
- package/dist/index.umd.js.map +1 -1
- package/package.json +26 -29
- package/src/Test.stories.jsx +28 -0
- package/src/desktop/Desktop.stories.jsx +110 -0
- package/src/desktop/WindowContext.js +135 -0
- package/src/desktop/WindowManager.js +355 -0
- package/src/desktop/desktop.css +55 -4
- package/src/desktop/desktop.js +312 -6
- package/src/desktop/index.js +7 -0
- package/src/desktop/window.css +229 -36
- package/src/desktop/window.js +254 -20
- package/src/desktop.backup/desktop.css +6 -0
- package/src/desktop.backup/desktop.js +13 -0
- package/src/desktop.backup/window.css +58 -0
- package/src/desktop.backup/window.js +27 -0
- package/src/html/Accordion.stories.jsx +178 -0
- package/src/html/Button.stories.jsx +175 -0
- package/src/html/Checkbox.stories.jsx +131 -0
- package/src/html/Chip.stories.jsx +189 -0
- package/src/html/Color.stories.jsx +234 -0
- package/src/html/Form.stories.jsx +271 -0
- package/src/html/Icon.stories.jsx +233 -0
- package/src/html/Progress.stories.jsx +247 -0
- package/src/html/Radio.stories.jsx +289 -0
- package/src/html/StyleTest.stories.jsx +81 -0
- package/src/html/Switch.stories.jsx +329 -0
- package/src/html/Tab.stories.jsx +239 -0
- package/src/html/Table.stories.jsx +188 -0
- package/src/html/Table2.stories.jsx +238 -0
- package/src/html/TextField2.stories.jsx +337 -0
- package/src/html/Tree.stories.jsx +285 -0
- package/src/html/accordion.example.js +0 -74
- package/src/html/accordion.js +1 -6
- package/src/html/button.js +2 -13
- package/src/html/checkbox.js +1 -9
- package/src/html/chip.js +2 -19
- package/src/html/color.js +1 -14
- package/src/html/form.js +4 -15
- package/src/html/header2.js +1 -12
- package/src/html/icon.js +1 -7
- package/src/html/index.js +1 -1
- package/src/html/list.js +1 -19
- package/src/html/menu.js +9 -5
- package/src/html/progress.js +5 -53
- package/src/html/property.js +9 -25
- package/src/html/radio.js +2 -16
- package/src/html/section.js +1 -6
- package/src/html/selector.js +2 -19
- package/src/html/switch.css +134 -100
- package/src/html/switch.example.js +46 -36
- package/src/html/switch.js +43 -192
- package/src/html/tab.js +3 -24
- package/src/html/text.js +1 -12
- package/src/html/textfield2.js +5 -42
- package/src/html/thumbnail.js +1 -12
- package/src/html/tokenfield.js +2 -21
- package/src/html/tree.js +3 -35
- package/src/index.js +1 -0
- package/__previewjs__/Wrapper.tsx +0 -14
- package/build-doc.sh +0 -10
- package/db/db.json +0 -89
- package/db/routes.json +0 -0
- package/dist/index.cjs +0 -36722
- package/dist/index.cjs.map +0 -1
- package/dist/index.css.map +0 -1
- package/doc/README.md +0 -196
- package/doc/evalulations/ACCORDION_EVALUATION.md +0 -583
- package/doc/evalulations/CHECKBOX_EVALUATION.md +0 -273
- package/doc/evalulations/CHIP_EVALUATION.md +0 -542
- package/doc/evalulations/COLOR_EVALUATION.md +0 -524
- package/doc/evalulations/COMPONENTS_EVALUATION.md +0 -477
- package/doc/evalulations/FORM_EVALUATION.md +0 -459
- package/doc/evalulations/HEADER_EVALUATION.md +0 -436
- package/doc/evalulations/ICON_EVALUATION.md +0 -254
- package/doc/evalulations/LIST_EVALUATION.md +0 -574
- package/doc/evalulations/PROGRESS_EVALUATION.md +0 -450
- package/doc/evalulations/RADIO_EVALUATION.md +0 -439
- package/doc/evalulations/RADIO_VISUAL_FIX.md +0 -183
- package/doc/evalulations/SECTION_IMPROVEMENTS.md +0 -153
- package/doc/evalulations/SWITCH_EVALUATION.md +0 -335
- package/doc/evalulations/SWITCH_VISUAL_FIX.md +0 -232
- package/doc/evalulations/TAB_EVALUATION.md +0 -626
- package/doc/evalulations/TEXTFIELD_EVALUATION.md +0 -747
- package/doc/evalulations/TOOLTIP_FIX.md +0 -157
- package/doc/evalulations/TREE_EVALUATION.md +0 -708
- package/doc/index.html +0 -0
- package/doc/package-lock.json +0 -17298
- package/doc/package.json +0 -34
- package/doc/public/index.html +0 -24
- package/doc/scripts/generate-examples.js +0 -129
- package/doc/src/App.css +0 -171
- package/doc/src/App.js +0 -114
- package/doc/src/components/ExamplePage.js +0 -129
- package/doc/src/components/WelcomePage.js +0 -84
- package/doc/src/index.css +0 -246
- package/doc/src/index.js +0 -17
- package/doc/src/theme.css +0 -256
- package/jest.config.js +0 -24
- package/preview.config.js +0 -38
- package/publish.sh +0 -6
- package/src/desktop/dektop.test.js +0 -11
- package/src/domain/CollectionAPI.test.js +0 -19
- package/src/domain/ContentEditor.test.js +0 -52
- package/src/domain2/CollectionAPI.test.js +0 -19
- package/src/domain2/CollectionContext.test.js +0 -71
- package/src/domain2/CollectionPage.test.js +0 -112
- package/src/domain2/DynamicForm.test.js +0 -47
- package/src/html/accordion.test.js +0 -37
- package/src/html/accordion.unit.test.js +0 -334
- package/src/html/button.example.new.js +0 -416
- package/src/html/button.test.js +0 -422
- package/src/html/checkbox.test.js +0 -285
- package/src/html/chip.test.js +0 -425
- package/src/html/color.example.js.backup +0 -527
- package/src/html/color.test.js +0 -377
- package/src/html/components.example.js.backup +0 -492
- package/src/html/components_enhanced.test.js +0 -581
- package/src/html/form.example.js.backup +0 -385
- package/src/html/form.test.js +0 -369
- package/src/html/header2.example.js.backup +0 -411
- package/src/html/header2.test.js +0 -377
- package/src/html/icon.example.js.backup +0 -268
- package/src/html/icon.test.js +0 -231
- package/src/html/label.test.js +0 -0
- package/src/html/list.example.js.backup +0 -404
- package/src/html/list.test.js +0 -383
- package/src/html/progress.example.js.backup +0 -424
- package/src/html/progress.test.js +0 -313
- package/src/html/property.example.js.backup +0 -553
- package/src/html/property.test.js +0 -371
- package/src/html/radio.example.js.backup +0 -389
- package/src/html/radio.test.js +0 -318
- package/src/html/section.example.js.backup +0 -99
- package/src/html/section.test.js +0 -131
- package/src/html/selector.test.js +0 -20
- package/src/html/switch.example.js.backup +0 -461
- package/src/html/switch.test.js +0 -355
- package/src/html/tab.example.js.backup +0 -446
- package/src/html/tab.test.js +0 -25
- package/src/html/tab_enhanced.test.js +0 -504
- package/src/html/table.test.js +0 -70
- package/src/html/table2.test.js +0 -582
- package/src/html/text.test.js +0 -15
- package/src/html/textfield.test.js +0 -51
- package/src/html/textfield2.example.js.backup +0 -1370
- package/src/html/textfield2.test.js +0 -950
- package/src/html/tokenfield.example.js.backup +0 -503
- package/src/html/tokenfield.test.js +0 -423
- package/src/html/tree.example.js.backup +0 -475
- package/src/html/tree.test.js +0 -43
- package/src/html/tree_enhanced.test.js +0 -495
- package/src/http/token.test.js +0 -50
- package/src/incubator/pdfViewer.js +0 -33
- package/src/incubator/wizard.test.js +0 -127
- package/src/site/site.test.js +0 -230
- package/src/site/view.test.js +0 -41
- package/src/widgets/calendar/Calendar.test.js +0 -28
- package/src/widgets/explorer/Explorer.test.js +0 -121
- package/src/widgets/ide/editor.test.js +0 -33
- package/src/widgets/kanban/Kanban.test.js +0 -78
- package/src/widgets/login/LoginBox.test.js +0 -12
- package/src/widgets/login/ResetPasswordBox.test.js +0 -34
- package/src/widgets/login/validations.test.js +0 -51
- package/src/widgets/planner/Planner.test.js +0 -60
- package/src/widgets/upload/Upload.test.js +0 -32
- package/table2.test.js +0 -454
@@ -1,313 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { CircularProgress, LinearProgress, StepProgress, RadialProgress, MultiProgress } from './progress'
|
3
|
-
|
4
|
-
// Pruebas unitarias para los componentes Progress mejorados
|
5
|
-
describe('Progress Components', () => {
|
6
|
-
// Mock de los componentes dependientes
|
7
|
-
const mockIcon = jest.fn()
|
8
|
-
|
9
|
-
beforeEach(() => {
|
10
|
-
jest.clearAllMocks()
|
11
|
-
|
12
|
-
// Mock del componente Icon
|
13
|
-
jest.doMock('./icon', () => ({
|
14
|
-
Icon: mockIcon
|
15
|
-
}))
|
16
|
-
})
|
17
|
-
|
18
|
-
describe('CircularProgress Component', () => {
|
19
|
-
test('component exports correctly', () => {
|
20
|
-
expect(CircularProgress).toBeDefined()
|
21
|
-
expect(typeof CircularProgress).toBe('function')
|
22
|
-
})
|
23
|
-
|
24
|
-
test('component has correct PropTypes', () => {
|
25
|
-
expect(CircularProgress.propTypes).toBeDefined()
|
26
|
-
expect(CircularProgress.propTypes.value).toBeDefined()
|
27
|
-
expect(CircularProgress.propTypes.max).toBeDefined()
|
28
|
-
expect(CircularProgress.propTypes.size).toBeDefined()
|
29
|
-
expect(CircularProgress.propTypes.variant).toBeDefined()
|
30
|
-
expect(CircularProgress.propTypes.color).toBeDefined()
|
31
|
-
expect(CircularProgress.propTypes.showValue).toBeDefined()
|
32
|
-
expect(CircularProgress.propTypes.animated).toBeDefined()
|
33
|
-
})
|
34
|
-
|
35
|
-
test('component has correct defaultProps', () => {
|
36
|
-
expect(CircularProgress.defaultProps).toBeDefined()
|
37
|
-
expect(CircularProgress.defaultProps.value).toBe(0)
|
38
|
-
expect(CircularProgress.defaultProps.max).toBe(100)
|
39
|
-
expect(CircularProgress.defaultProps.size).toBe('medium')
|
40
|
-
expect(CircularProgress.defaultProps.variant).toBe('indeterminate')
|
41
|
-
expect(CircularProgress.defaultProps.color).toBe('primary')
|
42
|
-
expect(CircularProgress.defaultProps.animated).toBe(true)
|
43
|
-
})
|
44
|
-
|
45
|
-
test('calculates dimensions correctly', () => {
|
46
|
-
const calculateDimensions = (size) => {
|
47
|
-
const sizes = {
|
48
|
-
small: { size: 24, strokeWidth: 2 },
|
49
|
-
medium: { size: 40, strokeWidth: 3 },
|
50
|
-
large: { size: 56, strokeWidth: 4 },
|
51
|
-
xlarge: { size: 80, strokeWidth: 5 }
|
52
|
-
}
|
53
|
-
return sizes[size] || sizes.medium
|
54
|
-
}
|
55
|
-
|
56
|
-
expect(calculateDimensions('small')).toEqual({ size: 24, strokeWidth: 2 })
|
57
|
-
expect(calculateDimensions('medium')).toEqual({ size: 40, strokeWidth: 3 })
|
58
|
-
expect(calculateDimensions('large')).toEqual({ size: 56, strokeWidth: 4 })
|
59
|
-
expect(calculateDimensions('xlarge')).toEqual({ size: 80, strokeWidth: 5 })
|
60
|
-
expect(calculateDimensions('invalid')).toEqual({ size: 40, strokeWidth: 3 })
|
61
|
-
})
|
62
|
-
|
63
|
-
test('calculates circle properties correctly', () => {
|
64
|
-
const calculateCircleProps = (size, thickness, value, max, variant) => {
|
65
|
-
const radius = (size - thickness) / 2
|
66
|
-
const circumference = 2 * Math.PI * radius
|
67
|
-
const strokeDasharray = circumference
|
68
|
-
const strokeDashoffset = variant === 'determinate'
|
69
|
-
? circumference - (value / max) * circumference
|
70
|
-
: 0
|
71
|
-
|
72
|
-
return { radius, circumference, strokeDasharray, strokeDashoffset }
|
73
|
-
}
|
74
|
-
|
75
|
-
const result = calculateCircleProps(40, 4, 50, 100, 'determinate')
|
76
|
-
expect(result.radius).toBe(18)
|
77
|
-
expect(result.circumference).toBeCloseTo(113.1, 1)
|
78
|
-
expect(result.strokeDasharray).toBeCloseTo(113.1, 1)
|
79
|
-
expect(result.strokeDashoffset).toBeCloseTo(56.55, 1)
|
80
|
-
})
|
81
|
-
|
82
|
-
test('formats display value correctly', () => {
|
83
|
-
const formatDisplayValue = (value, max, formatValue, variant) => {
|
84
|
-
if (formatValue) {
|
85
|
-
return formatValue(value, max)
|
86
|
-
}
|
87
|
-
return variant === 'determinate'
|
88
|
-
? `${Math.round((value / max) * 100)}%`
|
89
|
-
: ''
|
90
|
-
}
|
91
|
-
|
92
|
-
expect(formatDisplayValue(50, 100, null, 'determinate')).toBe('50%')
|
93
|
-
expect(formatDisplayValue(33, 100, null, 'determinate')).toBe('33%')
|
94
|
-
expect(formatDisplayValue(50, 100, null, 'indeterminate')).toBe('')
|
95
|
-
|
96
|
-
const customFormatter = (value, max) => `${value}/${max}`
|
97
|
-
expect(formatDisplayValue(50, 100, customFormatter, 'determinate')).toBe('50/100')
|
98
|
-
})
|
99
|
-
|
100
|
-
test('generates CSS classes correctly', () => {
|
101
|
-
const generateClasses = (size, variant, color, disabled, isComplete, animated, className) => {
|
102
|
-
return [
|
103
|
-
'circular-progress',
|
104
|
-
`circular-progress--${size}`,
|
105
|
-
`circular-progress--${variant}`,
|
106
|
-
`circular-progress--${color}`,
|
107
|
-
disabled && 'circular-progress--disabled',
|
108
|
-
isComplete && 'circular-progress--complete',
|
109
|
-
animated && 'circular-progress--animated',
|
110
|
-
className
|
111
|
-
].filter(Boolean).join(' ')
|
112
|
-
}
|
113
|
-
|
114
|
-
expect(generateClasses('medium', 'determinate', 'primary', false, false, true, ''))
|
115
|
-
.toBe('circular-progress circular-progress--medium circular-progress--determinate circular-progress--primary circular-progress--animated')
|
116
|
-
|
117
|
-
expect(generateClasses('large', 'indeterminate', 'success', true, false, false, 'custom'))
|
118
|
-
.toBe('circular-progress circular-progress--large circular-progress--indeterminate circular-progress--success circular-progress--disabled custom')
|
119
|
-
})
|
120
|
-
})
|
121
|
-
|
122
|
-
describe('LinearProgress Component', () => {
|
123
|
-
test('component exports correctly', () => {
|
124
|
-
expect(LinearProgress).toBeDefined()
|
125
|
-
expect(typeof LinearProgress).toBe('function')
|
126
|
-
})
|
127
|
-
|
128
|
-
test('component has correct PropTypes', () => {
|
129
|
-
expect(LinearProgress.propTypes).toBeDefined()
|
130
|
-
expect(LinearProgress.propTypes.value).toBeDefined()
|
131
|
-
expect(LinearProgress.propTypes.max).toBeDefined()
|
132
|
-
expect(LinearProgress.propTypes.variant).toBeDefined()
|
133
|
-
expect(LinearProgress.propTypes.color).toBeDefined()
|
134
|
-
expect(LinearProgress.propTypes.size).toBeDefined()
|
135
|
-
expect(LinearProgress.propTypes.showValue).toBeDefined()
|
136
|
-
expect(LinearProgress.propTypes.buffer).toBeDefined()
|
137
|
-
expect(LinearProgress.propTypes.striped).toBeDefined()
|
138
|
-
})
|
139
|
-
|
140
|
-
test('component has correct defaultProps', () => {
|
141
|
-
expect(LinearProgress.defaultProps).toBeDefined()
|
142
|
-
expect(LinearProgress.defaultProps.value).toBe(0)
|
143
|
-
expect(LinearProgress.defaultProps.max).toBe(100)
|
144
|
-
expect(LinearProgress.defaultProps.variant).toBe('determinate')
|
145
|
-
expect(LinearProgress.defaultProps.color).toBe('primary')
|
146
|
-
expect(LinearProgress.defaultProps.size).toBe('medium')
|
147
|
-
expect(LinearProgress.defaultProps.striped).toBe(false)
|
148
|
-
})
|
149
|
-
|
150
|
-
test('calculates percentages correctly', () => {
|
151
|
-
const calculatePercentages = (value, max, buffer) => {
|
152
|
-
const progressPercent = (value / max) * 100
|
153
|
-
const bufferPercent = buffer !== undefined ? (buffer / max) * 100 : 0
|
154
|
-
return { progressPercent, bufferPercent }
|
155
|
-
}
|
156
|
-
|
157
|
-
expect(calculatePercentages(50, 100, 75)).toEqual({ progressPercent: 50, bufferPercent: 75 })
|
158
|
-
expect(calculatePercentages(25, 100, undefined)).toEqual({ progressPercent: 25, bufferPercent: 0 })
|
159
|
-
expect(calculatePercentages(0, 100, 0)).toEqual({ progressPercent: 0, bufferPercent: 0 })
|
160
|
-
})
|
161
|
-
|
162
|
-
test('formats time remaining correctly', () => {
|
163
|
-
const formatTimeRemaining = (timeRemaining) => {
|
164
|
-
if (!timeRemaining) return ''
|
165
|
-
|
166
|
-
const minutes = Math.floor(timeRemaining / 60)
|
167
|
-
const seconds = Math.floor(timeRemaining % 60)
|
168
|
-
|
169
|
-
if (minutes > 0) {
|
170
|
-
return `${minutes}m ${seconds}s remaining`
|
171
|
-
}
|
172
|
-
return `${seconds}s remaining`
|
173
|
-
}
|
174
|
-
|
175
|
-
expect(formatTimeRemaining(null)).toBe('')
|
176
|
-
expect(formatTimeRemaining(30)).toBe('30s remaining')
|
177
|
-
expect(formatTimeRemaining(90)).toBe('1m 30s remaining')
|
178
|
-
expect(formatTimeRemaining(125)).toBe('2m 5s remaining')
|
179
|
-
})
|
180
|
-
})
|
181
|
-
|
182
|
-
describe('StepProgress Component', () => {
|
183
|
-
test('component exports correctly', () => {
|
184
|
-
expect(StepProgress).toBeDefined()
|
185
|
-
expect(typeof StepProgress).toBe('function')
|
186
|
-
})
|
187
|
-
|
188
|
-
test('component has correct PropTypes', () => {
|
189
|
-
expect(StepProgress.propTypes).toBeDefined()
|
190
|
-
expect(StepProgress.propTypes.steps).toBeDefined()
|
191
|
-
expect(StepProgress.propTypes.currentStep).toBeDefined()
|
192
|
-
expect(StepProgress.propTypes.variant).toBeDefined()
|
193
|
-
expect(StepProgress.propTypes.allowClickNavigation).toBeDefined()
|
194
|
-
})
|
195
|
-
|
196
|
-
test('determines step states correctly', () => {
|
197
|
-
const determineStepState = (stepIndex, currentStep) => {
|
198
|
-
return {
|
199
|
-
isCompleted: stepIndex < currentStep,
|
200
|
-
isCurrent: stepIndex === currentStep,
|
201
|
-
isClickable: stepIndex <= currentStep
|
202
|
-
}
|
203
|
-
}
|
204
|
-
|
205
|
-
expect(determineStepState(0, 2)).toEqual({ isCompleted: true, isCurrent: false, isClickable: true })
|
206
|
-
expect(determineStepState(2, 2)).toEqual({ isCompleted: false, isCurrent: true, isClickable: true })
|
207
|
-
expect(determineStepState(3, 2)).toEqual({ isCompleted: false, isCurrent: false, isClickable: false })
|
208
|
-
})
|
209
|
-
})
|
210
|
-
|
211
|
-
describe('RadialProgress Component', () => {
|
212
|
-
test('component exports correctly', () => {
|
213
|
-
expect(RadialProgress).toBeDefined()
|
214
|
-
expect(typeof RadialProgress).toBe('function')
|
215
|
-
})
|
216
|
-
|
217
|
-
test('component has correct PropTypes', () => {
|
218
|
-
expect(RadialProgress.propTypes).toBeDefined()
|
219
|
-
expect(RadialProgress.propTypes.value).toBeDefined()
|
220
|
-
expect(RadialProgress.propTypes.size).toBeDefined()
|
221
|
-
expect(RadialProgress.propTypes.thickness).toBeDefined()
|
222
|
-
expect(RadialProgress.propTypes.gradient).toBeDefined()
|
223
|
-
})
|
224
|
-
|
225
|
-
test('calculates circle properties correctly', () => {
|
226
|
-
const calculateRadialProps = (size, thickness, value, max) => {
|
227
|
-
const radius = (size - thickness) / 2
|
228
|
-
const circumference = 2 * Math.PI * radius
|
229
|
-
const strokeDasharray = circumference
|
230
|
-
const strokeDashoffset = circumference - (value / max) * circumference
|
231
|
-
const percentage = Math.round((value / max) * 100)
|
232
|
-
|
233
|
-
return { radius, circumference, strokeDasharray, strokeDashoffset, percentage }
|
234
|
-
}
|
235
|
-
|
236
|
-
const result = calculateRadialProps(120, 8, 75, 100)
|
237
|
-
expect(result.radius).toBe(56)
|
238
|
-
expect(result.circumference).toBeCloseTo(351.86, 1)
|
239
|
-
expect(result.strokeDashoffset).toBeCloseTo(87.96, 1)
|
240
|
-
expect(result.percentage).toBe(75)
|
241
|
-
})
|
242
|
-
})
|
243
|
-
|
244
|
-
describe('MultiProgress Component', () => {
|
245
|
-
test('component exports correctly', () => {
|
246
|
-
expect(MultiProgress).toBeDefined()
|
247
|
-
expect(typeof MultiProgress).toBe('function')
|
248
|
-
})
|
249
|
-
|
250
|
-
test('component has correct PropTypes', () => {
|
251
|
-
expect(MultiProgress.propTypes).toBeDefined()
|
252
|
-
expect(MultiProgress.propTypes.items).toBeDefined()
|
253
|
-
expect(MultiProgress.propTypes.showLabels).toBeDefined()
|
254
|
-
expect(MultiProgress.propTypes.showValues).toBeDefined()
|
255
|
-
})
|
256
|
-
|
257
|
-
test('formats item values correctly', () => {
|
258
|
-
const formatItemValue = (item) => {
|
259
|
-
return item.formatValue ?
|
260
|
-
item.formatValue(item.value, item.max) :
|
261
|
-
`${Math.round((item.value / item.max) * 100)}%`
|
262
|
-
}
|
263
|
-
|
264
|
-
const item1 = { value: 50, max: 100 }
|
265
|
-
const item2 = { value: 75, max: 100, formatValue: (v, m) => `${v}/${m}` }
|
266
|
-
|
267
|
-
expect(formatItemValue(item1)).toBe('50%')
|
268
|
-
expect(formatItemValue(item2)).toBe('75/100')
|
269
|
-
})
|
270
|
-
})
|
271
|
-
|
272
|
-
describe('Accessibility', () => {
|
273
|
-
test('generates correct ARIA attributes', () => {
|
274
|
-
const generateAriaAttributes = (variant, value, max, ariaLabel) => {
|
275
|
-
return {
|
276
|
-
'aria-label': ariaLabel || (variant === 'determinate' ? `Progress: ${Math.round((value / max) * 100)}%` : 'Loading'),
|
277
|
-
'aria-valuenow': variant === 'determinate' ? value : undefined,
|
278
|
-
'aria-valuemin': variant === 'determinate' ? 0 : undefined,
|
279
|
-
'aria-valuemax': variant === 'determinate' ? max : undefined,
|
280
|
-
'aria-valuetext': variant === 'determinate' ? `${Math.round((value / max) * 100)}%` : 'Loading',
|
281
|
-
role: 'progressbar'
|
282
|
-
}
|
283
|
-
}
|
284
|
-
|
285
|
-
const result1 = generateAriaAttributes('determinate', 50, 100, null)
|
286
|
-
expect(result1['aria-label']).toBe('Progress: 50%')
|
287
|
-
expect(result1['aria-valuenow']).toBe(50)
|
288
|
-
expect(result1['aria-valuemin']).toBe(0)
|
289
|
-
expect(result1['aria-valuemax']).toBe(100)
|
290
|
-
expect(result1.role).toBe('progressbar')
|
291
|
-
|
292
|
-
const result2 = generateAriaAttributes('indeterminate', 0, 100, 'Custom loading')
|
293
|
-
expect(result2['aria-label']).toBe('Custom loading')
|
294
|
-
expect(result2['aria-valuenow']).toBeUndefined()
|
295
|
-
expect(result2['aria-valuetext']).toBe('Loading')
|
296
|
-
})
|
297
|
-
})
|
298
|
-
|
299
|
-
describe('Animation Logic', () => {
|
300
|
-
test('calculates easing functions correctly', () => {
|
301
|
-
const easeOutQuart = (progress) => 1 - Math.pow(1 - progress, 4)
|
302
|
-
const easeOutCubic = (progress) => 1 - Math.pow(1 - progress, 3)
|
303
|
-
|
304
|
-
expect(easeOutQuart(0)).toBe(0)
|
305
|
-
expect(easeOutQuart(1)).toBe(1)
|
306
|
-
expect(easeOutQuart(0.5)).toBeCloseTo(0.9375, 4)
|
307
|
-
|
308
|
-
expect(easeOutCubic(0)).toBe(0)
|
309
|
-
expect(easeOutCubic(1)).toBe(1)
|
310
|
-
expect(easeOutCubic(0.5)).toBeCloseTo(0.875, 3)
|
311
|
-
})
|
312
|
-
})
|
313
|
-
})
|