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
package/src/html/radio.test.js
DELETED
@@ -1,318 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { RadioButton, RadioGroup } from './radio'
|
3
|
-
|
4
|
-
// Pruebas unitarias para los componentes Radio
|
5
|
-
describe('Radio Components', () => {
|
6
|
-
// Mock del componente Text
|
7
|
-
const mockText = jest.fn()
|
8
|
-
|
9
|
-
beforeEach(() => {
|
10
|
-
jest.clearAllMocks()
|
11
|
-
|
12
|
-
// Mock del componente Text
|
13
|
-
jest.doMock('./text', () => ({
|
14
|
-
Text: mockText
|
15
|
-
}))
|
16
|
-
|
17
|
-
// Mock de console.warn para las pruebas
|
18
|
-
jest.spyOn(console, 'warn').mockImplementation(() => {})
|
19
|
-
})
|
20
|
-
|
21
|
-
afterEach(() => {
|
22
|
-
console.warn.mockRestore()
|
23
|
-
})
|
24
|
-
|
25
|
-
describe('RadioButton Component', () => {
|
26
|
-
test('component exports correctly', () => {
|
27
|
-
expect(RadioButton).toBeDefined()
|
28
|
-
expect(typeof RadioButton).toBe('function')
|
29
|
-
})
|
30
|
-
|
31
|
-
test('component has correct PropTypes', () => {
|
32
|
-
expect(RadioButton.propTypes).toBeDefined()
|
33
|
-
expect(RadioButton.propTypes.id).toBeDefined()
|
34
|
-
expect(RadioButton.propTypes.name).toBeDefined()
|
35
|
-
expect(RadioButton.propTypes.label).toBeDefined()
|
36
|
-
expect(RadioButton.propTypes.value).toBeDefined()
|
37
|
-
expect(RadioButton.propTypes.checked).toBeDefined()
|
38
|
-
expect(RadioButton.propTypes.disabled).toBeDefined()
|
39
|
-
expect(RadioButton.propTypes.readOnly).toBeDefined()
|
40
|
-
expect(RadioButton.propTypes.error).toBeDefined()
|
41
|
-
expect(RadioButton.propTypes.required).toBeDefined()
|
42
|
-
expect(RadioButton.propTypes.className).toBeDefined()
|
43
|
-
expect(RadioButton.propTypes.ariaLabel).toBeDefined()
|
44
|
-
expect(RadioButton.propTypes.onChange).toBeDefined()
|
45
|
-
})
|
46
|
-
|
47
|
-
test('component has correct defaultProps', () => {
|
48
|
-
expect(RadioButton.defaultProps).toBeDefined()
|
49
|
-
expect(RadioButton.defaultProps.checked).toBe(false)
|
50
|
-
expect(RadioButton.defaultProps.disabled).toBe(false)
|
51
|
-
expect(RadioButton.defaultProps.readOnly).toBe(false)
|
52
|
-
expect(RadioButton.defaultProps.error).toBe(false)
|
53
|
-
expect(RadioButton.defaultProps.required).toBe(false)
|
54
|
-
expect(RadioButton.defaultProps.className).toBe('')
|
55
|
-
})
|
56
|
-
|
57
|
-
test('warns when id prop is missing', () => {
|
58
|
-
const validateId = (id) => {
|
59
|
-
if (!id) {
|
60
|
-
console.warn('RadioButton component: id prop is required')
|
61
|
-
return null
|
62
|
-
}
|
63
|
-
return true
|
64
|
-
}
|
65
|
-
|
66
|
-
const result = validateId(undefined)
|
67
|
-
expect(result).toBeNull()
|
68
|
-
expect(console.warn).toHaveBeenCalledWith('RadioButton component: id prop is required')
|
69
|
-
})
|
70
|
-
|
71
|
-
test('warns when name prop is missing', () => {
|
72
|
-
const validateName = (name) => {
|
73
|
-
if (!name) {
|
74
|
-
console.warn('RadioButton component: name prop is required for radio button groups')
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
validateName(undefined)
|
79
|
-
expect(console.warn).toHaveBeenCalledWith('RadioButton component: name prop is required for radio button groups')
|
80
|
-
})
|
81
|
-
|
82
|
-
test('generates correct CSS classes for different states', () => {
|
83
|
-
const generateClasses = (disabled, readOnly, error, className) => {
|
84
|
-
return [
|
85
|
-
'radio',
|
86
|
-
disabled && 'disabled',
|
87
|
-
readOnly && 'readonly',
|
88
|
-
error && 'error',
|
89
|
-
className || ''
|
90
|
-
].filter(Boolean).join(' ')
|
91
|
-
}
|
92
|
-
|
93
|
-
expect(generateClasses(false, false, false, '')).toBe('radio')
|
94
|
-
expect(generateClasses(true, false, false, '')).toBe('radio disabled')
|
95
|
-
expect(generateClasses(false, true, false, '')).toBe('radio readonly')
|
96
|
-
expect(generateClasses(false, false, true, '')).toBe('radio error')
|
97
|
-
expect(generateClasses(false, false, false, 'custom')).toBe('radio custom')
|
98
|
-
expect(generateClasses(true, true, true, 'custom')).toBe('radio disabled readonly error custom')
|
99
|
-
})
|
100
|
-
|
101
|
-
test('change handler works correctly', () => {
|
102
|
-
const mockOnChange = jest.fn()
|
103
|
-
|
104
|
-
const simulateChange = (disabled, readOnly, onChange, id, value) => {
|
105
|
-
const event = { target: { value } }
|
106
|
-
|
107
|
-
if (!disabled && !readOnly && onChange) {
|
108
|
-
onChange(id, value || id, event)
|
109
|
-
}
|
110
|
-
}
|
111
|
-
|
112
|
-
// Change normal
|
113
|
-
simulateChange(false, false, mockOnChange, 'test', 'value1')
|
114
|
-
expect(mockOnChange).toHaveBeenCalledWith('test', 'value1', { target: { value: 'value1' } })
|
115
|
-
|
116
|
-
mockOnChange.mockClear()
|
117
|
-
|
118
|
-
// Change con disabled
|
119
|
-
simulateChange(true, false, mockOnChange, 'test', 'value1')
|
120
|
-
expect(mockOnChange).not.toHaveBeenCalled()
|
121
|
-
|
122
|
-
// Change con readOnly
|
123
|
-
simulateChange(false, true, mockOnChange, 'test', 'value1')
|
124
|
-
expect(mockOnChange).not.toHaveBeenCalled()
|
125
|
-
})
|
126
|
-
|
127
|
-
test('keyboard event handling works correctly', () => {
|
128
|
-
const mockChange = jest.fn()
|
129
|
-
|
130
|
-
const simulateKeyDown = (key, change) => {
|
131
|
-
const event = {
|
132
|
-
key,
|
133
|
-
preventDefault: jest.fn()
|
134
|
-
}
|
135
|
-
|
136
|
-
if (event.key === ' ') {
|
137
|
-
event.preventDefault()
|
138
|
-
change(event)
|
139
|
-
}
|
140
|
-
|
141
|
-
return event
|
142
|
-
}
|
143
|
-
|
144
|
-
// Space key
|
145
|
-
const spaceEvent = simulateKeyDown(' ', mockChange)
|
146
|
-
expect(spaceEvent.preventDefault).toHaveBeenCalled()
|
147
|
-
expect(mockChange).toHaveBeenCalledWith(spaceEvent)
|
148
|
-
|
149
|
-
mockChange.mockClear()
|
150
|
-
|
151
|
-
// Other key (should not trigger)
|
152
|
-
const otherEvent = simulateKeyDown('Enter', mockChange)
|
153
|
-
expect(otherEvent.preventDefault).not.toHaveBeenCalled()
|
154
|
-
expect(mockChange).not.toHaveBeenCalled()
|
155
|
-
})
|
156
|
-
|
157
|
-
test('accessibility attributes generation works correctly', () => {
|
158
|
-
const generateAriaAttributes = (ariaLabel, label, required, error, id) => {
|
159
|
-
return {
|
160
|
-
'aria-label': ariaLabel || label,
|
161
|
-
'aria-required': required,
|
162
|
-
'aria-invalid': error,
|
163
|
-
'aria-describedby': error && typeof error === 'string' ? `${id}-error` : undefined
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
const basic = generateAriaAttributes(null, 'Test Label', false, false, 'test')
|
168
|
-
expect(basic['aria-label']).toBe('Test Label')
|
169
|
-
expect(basic['aria-required']).toBe(false)
|
170
|
-
expect(basic['aria-invalid']).toBe(false)
|
171
|
-
expect(basic['aria-describedby']).toBeUndefined()
|
172
|
-
|
173
|
-
const withError = generateAriaAttributes(null, 'Test Label', false, 'Error message', 'test')
|
174
|
-
expect(withError['aria-invalid']).toBe('Error message')
|
175
|
-
expect(withError['aria-describedby']).toBe('test-error')
|
176
|
-
})
|
177
|
-
})
|
178
|
-
|
179
|
-
describe('RadioGroup Component', () => {
|
180
|
-
test('component exports correctly', () => {
|
181
|
-
expect(RadioGroup).toBeDefined()
|
182
|
-
expect(typeof RadioGroup).toBe('function')
|
183
|
-
})
|
184
|
-
|
185
|
-
test('component has correct PropTypes', () => {
|
186
|
-
expect(RadioGroup.propTypes).toBeDefined()
|
187
|
-
expect(RadioGroup.propTypes.id).toBeDefined()
|
188
|
-
expect(RadioGroup.propTypes.label).toBeDefined()
|
189
|
-
expect(RadioGroup.propTypes.value).toBeDefined()
|
190
|
-
expect(RadioGroup.propTypes.options).toBeDefined()
|
191
|
-
expect(RadioGroup.propTypes.disabled).toBeDefined()
|
192
|
-
expect(RadioGroup.propTypes.readOnly).toBeDefined()
|
193
|
-
expect(RadioGroup.propTypes.error).toBeDefined()
|
194
|
-
expect(RadioGroup.propTypes.required).toBeDefined()
|
195
|
-
expect(RadioGroup.propTypes.className).toBeDefined()
|
196
|
-
expect(RadioGroup.propTypes.ariaLabel).toBeDefined()
|
197
|
-
expect(RadioGroup.propTypes.onChange).toBeDefined()
|
198
|
-
})
|
199
|
-
|
200
|
-
test('component has correct defaultProps', () => {
|
201
|
-
expect(RadioGroup.defaultProps).toBeDefined()
|
202
|
-
expect(RadioGroup.defaultProps.options).toEqual([])
|
203
|
-
expect(RadioGroup.defaultProps.disabled).toBe(false)
|
204
|
-
expect(RadioGroup.defaultProps.readOnly).toBe(false)
|
205
|
-
expect(RadioGroup.defaultProps.error).toBe(false)
|
206
|
-
expect(RadioGroup.defaultProps.required).toBe(false)
|
207
|
-
expect(RadioGroup.defaultProps.className).toBe('')
|
208
|
-
})
|
209
|
-
|
210
|
-
test('generates unique group name when id is not provided', () => {
|
211
|
-
const generateGroupName = (id) => {
|
212
|
-
return id || `radiogroup-${Math.random().toString(36).substring(2, 11)}`
|
213
|
-
}
|
214
|
-
|
215
|
-
const name1 = generateGroupName(undefined)
|
216
|
-
const name2 = generateGroupName(undefined)
|
217
|
-
|
218
|
-
expect(name1).toMatch(/^radiogroup-/)
|
219
|
-
expect(name2).toMatch(/^radiogroup-/)
|
220
|
-
expect(name1).not.toBe(name2) // Should be different
|
221
|
-
})
|
222
|
-
|
223
|
-
test('state synchronization works correctly', () => {
|
224
|
-
let internalState = null
|
225
|
-
|
226
|
-
const syncState = (externalValue) => {
|
227
|
-
internalState = externalValue
|
228
|
-
}
|
229
|
-
|
230
|
-
syncState('option1')
|
231
|
-
expect(internalState).toBe('option1')
|
232
|
-
|
233
|
-
syncState('option2')
|
234
|
-
expect(internalState).toBe('option2')
|
235
|
-
})
|
236
|
-
|
237
|
-
test('change handler works correctly', () => {
|
238
|
-
const mockOnChange = jest.fn()
|
239
|
-
let selectedValue = null
|
240
|
-
|
241
|
-
const simulateChange = (disabled, readOnly, onChange, id, optionValue) => {
|
242
|
-
if (!disabled && !readOnly) {
|
243
|
-
selectedValue = optionValue
|
244
|
-
if (onChange) {
|
245
|
-
onChange(id || 'radiogroup', optionValue, {})
|
246
|
-
}
|
247
|
-
}
|
248
|
-
}
|
249
|
-
|
250
|
-
// Normal change
|
251
|
-
simulateChange(false, false, mockOnChange, 'test-group', 'option1')
|
252
|
-
expect(selectedValue).toBe('option1')
|
253
|
-
expect(mockOnChange).toHaveBeenCalledWith('test-group', 'option1', {})
|
254
|
-
|
255
|
-
mockOnChange.mockClear()
|
256
|
-
|
257
|
-
// Disabled group
|
258
|
-
simulateChange(true, false, mockOnChange, 'test-group', 'option2')
|
259
|
-
expect(selectedValue).toBe('option1') // Should not change
|
260
|
-
expect(mockOnChange).not.toHaveBeenCalled()
|
261
|
-
|
262
|
-
// ReadOnly group
|
263
|
-
simulateChange(false, true, mockOnChange, 'test-group', 'option2')
|
264
|
-
expect(selectedValue).toBe('option1') // Should not change
|
265
|
-
expect(mockOnChange).not.toHaveBeenCalled()
|
266
|
-
})
|
267
|
-
|
268
|
-
test('CSS classes generation works correctly', () => {
|
269
|
-
const generateClasses = (disabled, readOnly, error, className) => {
|
270
|
-
return [
|
271
|
-
'radio-group',
|
272
|
-
disabled && 'disabled',
|
273
|
-
readOnly && 'readonly',
|
274
|
-
error && 'error',
|
275
|
-
className || ''
|
276
|
-
].filter(Boolean).join(' ')
|
277
|
-
}
|
278
|
-
|
279
|
-
expect(generateClasses(false, false, false, '')).toBe('radio-group')
|
280
|
-
expect(generateClasses(true, false, false, '')).toBe('radio-group disabled')
|
281
|
-
expect(generateClasses(false, true, false, '')).toBe('radio-group readonly')
|
282
|
-
expect(generateClasses(false, false, true, '')).toBe('radio-group error')
|
283
|
-
expect(generateClasses(false, false, false, 'custom')).toBe('radio-group custom')
|
284
|
-
})
|
285
|
-
|
286
|
-
test('options mapping works correctly', () => {
|
287
|
-
const options = [
|
288
|
-
{ id: 'opt1', label: 'Option 1', value: 'value1' },
|
289
|
-
{ id: 'opt2', label: 'Option 2', value: 'value2' },
|
290
|
-
{ label: 'Option 3' } // Without id or value
|
291
|
-
]
|
292
|
-
|
293
|
-
const mapOptions = (options, groupName) => {
|
294
|
-
return options.map((option, index) => ({
|
295
|
-
key: option.value || option.id || index,
|
296
|
-
id: option.id || `${groupName}-${index}`,
|
297
|
-
name: groupName,
|
298
|
-
label: option.label,
|
299
|
-
value: option.value || option.id
|
300
|
-
}))
|
301
|
-
}
|
302
|
-
|
303
|
-
const mapped = mapOptions(options, 'test-group')
|
304
|
-
|
305
|
-
expect(mapped[0].key).toBe('value1')
|
306
|
-
expect(mapped[0].id).toBe('opt1')
|
307
|
-
expect(mapped[0].value).toBe('value1')
|
308
|
-
|
309
|
-
expect(mapped[1].key).toBe('value2')
|
310
|
-
expect(mapped[1].id).toBe('opt2')
|
311
|
-
expect(mapped[1].value).toBe('value2')
|
312
|
-
|
313
|
-
expect(mapped[2].key).toBe(2)
|
314
|
-
expect(mapped[2].id).toBe('test-group-2')
|
315
|
-
expect(mapped[2].value).toBeUndefined()
|
316
|
-
})
|
317
|
-
})
|
318
|
-
})
|
@@ -1,99 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { Section } from './section'
|
3
|
-
import { Button } from './button'
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Ejemplos de uso del componente Section mejorado
|
7
|
-
*/
|
8
|
-
export const SectionExamples = () => {
|
9
|
-
return (
|
10
|
-
<div style={{ padding: '2rem', maxWidth: '800px' }}>
|
11
|
-
<h1>Ejemplos del Componente Section Mejorado</h1>
|
12
|
-
|
13
|
-
{/* Ejemplo básico */}
|
14
|
-
<Section title="Sección Básica" icon="info">
|
15
|
-
<p>Esta es una sección básica que está cerrada por defecto.</p>
|
16
|
-
<p>Haz clic en el icono de expansión para abrirla.</p>
|
17
|
-
</Section>
|
18
|
-
|
19
|
-
{/* Sección abierta por defecto */}
|
20
|
-
<Section title="Sección Abierta" icon="folder_open" open={true}>
|
21
|
-
<p>Esta sección está abierta por defecto.</p>
|
22
|
-
<p>El icono cambia dinámicamente según el estado.</p>
|
23
|
-
<ul>
|
24
|
-
<li>✅ Icono dinámico (expand_more/expand_less)</li>
|
25
|
-
<li>✅ Tooltip informativo</li>
|
26
|
-
<li>✅ Atributos de accesibilidad</li>
|
27
|
-
</ul>
|
28
|
-
</Section>
|
29
|
-
|
30
|
-
{/* Sección con acciones */}
|
31
|
-
<Section
|
32
|
-
title="Sección con Acciones"
|
33
|
-
icon="settings"
|
34
|
-
actions={
|
35
|
-
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
36
|
-
<Button label="Editar" icon="edit" outlined />
|
37
|
-
<Button label="Eliminar" icon="delete" outlined />
|
38
|
-
</div>
|
39
|
-
}
|
40
|
-
>
|
41
|
-
<p>Esta sección incluye botones de acción en el header.</p>
|
42
|
-
<p>Las acciones se muestran junto al botón de colapsar.</p>
|
43
|
-
</Section>
|
44
|
-
|
45
|
-
{/* Sección no colapsable */}
|
46
|
-
<Section
|
47
|
-
title="Sección No Colapsable"
|
48
|
-
icon="lock"
|
49
|
-
canCollapse={false}
|
50
|
-
className="always-open"
|
51
|
-
>
|
52
|
-
<p>Esta sección no puede colapsarse.</p>
|
53
|
-
<p>No muestra el icono de expansión/contracción.</p>
|
54
|
-
<p>Útil para contenido que siempre debe estar visible.</p>
|
55
|
-
</Section>
|
56
|
-
|
57
|
-
{/* Sección con clase personalizada */}
|
58
|
-
<Section
|
59
|
-
title="Sección Personalizada"
|
60
|
-
icon="palette"
|
61
|
-
className="custom-section"
|
62
|
-
open={true}
|
63
|
-
>
|
64
|
-
<p>Esta sección tiene una clase CSS personalizada.</p>
|
65
|
-
<p>El manejo de className es seguro y no causa errores.</p>
|
66
|
-
<div style={{
|
67
|
-
background: '#f0f8ff',
|
68
|
-
padding: '1rem',
|
69
|
-
borderRadius: '4px',
|
70
|
-
border: '1px solid #e0e0e0'
|
71
|
-
}}>
|
72
|
-
<strong>Mejoras implementadas:</strong>
|
73
|
-
<ul>
|
74
|
-
<li>🔧 Icono dinámico corregido</li>
|
75
|
-
<li>🛡️ Manejo seguro de className</li>
|
76
|
-
<li>📝 PropTypes y documentación</li>
|
77
|
-
<li>♿ Atributos de accesibilidad</li>
|
78
|
-
<li>💬 Tooltips informativos</li>
|
79
|
-
<li>✅ Pruebas unitarias</li>
|
80
|
-
</ul>
|
81
|
-
</div>
|
82
|
-
</Section>
|
83
|
-
|
84
|
-
{/* Sección sin título */}
|
85
|
-
<Section icon="description">
|
86
|
-
<p>Esta sección no tiene título, solo icono.</p>
|
87
|
-
<p>Demuestra la flexibilidad del componente.</p>
|
88
|
-
</Section>
|
89
|
-
|
90
|
-
{/* Sección mínima */}
|
91
|
-
<Section>
|
92
|
-
<p>Sección mínima sin título ni icono.</p>
|
93
|
-
<p>Solo con el contenido y funcionalidad de colapsar.</p>
|
94
|
-
</Section>
|
95
|
-
</div>
|
96
|
-
)
|
97
|
-
}
|
98
|
-
|
99
|
-
export default SectionExamples
|
package/src/html/section.test.js
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { Section } from './section'
|
3
|
-
|
4
|
-
// Pruebas unitarias simples para el componente Section
|
5
|
-
describe('Section Component', () => {
|
6
|
-
// Mock de los componentes dependientes
|
7
|
-
const mockIcon = jest.fn()
|
8
|
-
const mockHeader = jest.fn()
|
9
|
-
|
10
|
-
beforeEach(() => {
|
11
|
-
jest.clearAllMocks()
|
12
|
-
|
13
|
-
// Mock del componente Icon
|
14
|
-
jest.doMock('./icon', () => ({
|
15
|
-
Icon: mockIcon
|
16
|
-
}))
|
17
|
-
|
18
|
-
// Mock del componente Header
|
19
|
-
jest.doMock('./header', () => ({
|
20
|
-
Header: mockHeader
|
21
|
-
}))
|
22
|
-
})
|
23
|
-
|
24
|
-
test('component exports correctly', () => {
|
25
|
-
expect(Section).toBeDefined()
|
26
|
-
expect(typeof Section).toBe('function')
|
27
|
-
})
|
28
|
-
|
29
|
-
test('component has correct PropTypes', () => {
|
30
|
-
expect(Section.propTypes).toBeDefined()
|
31
|
-
expect(Section.propTypes.title).toBeDefined()
|
32
|
-
expect(Section.propTypes.canCollapse).toBeDefined()
|
33
|
-
expect(Section.propTypes.open).toBeDefined()
|
34
|
-
expect(Section.propTypes.icon).toBeDefined()
|
35
|
-
expect(Section.propTypes.actions).toBeDefined()
|
36
|
-
expect(Section.propTypes.children).toBeDefined()
|
37
|
-
expect(Section.propTypes.className).toBeDefined()
|
38
|
-
})
|
39
|
-
|
40
|
-
test('component has correct defaultProps', () => {
|
41
|
-
expect(Section.defaultProps).toBeDefined()
|
42
|
-
expect(Section.defaultProps.title).toBe('')
|
43
|
-
expect(Section.defaultProps.canCollapse).toBe(true)
|
44
|
-
expect(Section.defaultProps.open).toBe(false)
|
45
|
-
expect(Section.defaultProps.className).toBe('')
|
46
|
-
})
|
47
|
-
|
48
|
-
test('component structure is correct', () => {
|
49
|
-
// Verificar que el componente es una función
|
50
|
-
expect(typeof Section).toBe('function')
|
51
|
-
|
52
|
-
// Verificar que el componente tiene las propiedades esperadas
|
53
|
-
expect(Section.propTypes).toBeDefined()
|
54
|
-
expect(Section.defaultProps).toBeDefined()
|
55
|
-
|
56
|
-
// Verificar que el componente puede ser instanciado como elemento React
|
57
|
-
const element = React.createElement(Section, {
|
58
|
-
title: 'Test Title',
|
59
|
-
icon: 'test-icon',
|
60
|
-
canCollapse: true,
|
61
|
-
open: false,
|
62
|
-
className: 'test-class'
|
63
|
-
})
|
64
|
-
|
65
|
-
expect(element).toBeDefined()
|
66
|
-
expect(element.type).toBe(Section)
|
67
|
-
})
|
68
|
-
|
69
|
-
test('toggle function works correctly', () => {
|
70
|
-
const props = {
|
71
|
-
title: 'Test Title',
|
72
|
-
open: false
|
73
|
-
}
|
74
|
-
|
75
|
-
// Simular el comportamiento del toggle
|
76
|
-
let isOpen = props.open
|
77
|
-
const toggle = () => {
|
78
|
-
isOpen = !isOpen
|
79
|
-
}
|
80
|
-
|
81
|
-
expect(isOpen).toBe(false)
|
82
|
-
toggle()
|
83
|
-
expect(isOpen).toBe(true)
|
84
|
-
toggle()
|
85
|
-
expect(isOpen).toBe(false)
|
86
|
-
})
|
87
|
-
|
88
|
-
test('className handling works correctly', () => {
|
89
|
-
// Simular el manejo de className
|
90
|
-
const testClassName = (className) => {
|
91
|
-
return `section ${className || ''}`
|
92
|
-
}
|
93
|
-
|
94
|
-
expect(testClassName('custom-class')).toBe('section custom-class')
|
95
|
-
expect(testClassName(undefined)).toBe('section ')
|
96
|
-
expect(testClassName('')).toBe('section ')
|
97
|
-
})
|
98
|
-
|
99
|
-
test('icon logic works correctly', () => {
|
100
|
-
// Simular la lógica del icono
|
101
|
-
const getIconName = (isOpen) => {
|
102
|
-
return isOpen ? "expand_less" : "expand_more"
|
103
|
-
}
|
104
|
-
|
105
|
-
expect(getIconName(false)).toBe('expand_more')
|
106
|
-
expect(getIconName(true)).toBe('expand_less')
|
107
|
-
})
|
108
|
-
|
109
|
-
test('tooltip text and positioning logic works correctly', () => {
|
110
|
-
// Simular la lógica del tooltip
|
111
|
-
const getTooltipConfig = (isOpen) => {
|
112
|
-
return {
|
113
|
-
text: isOpen ? 'Contraer sección' : 'Expandir sección',
|
114
|
-
top: '-3rem',
|
115
|
-
left: '-2rem'
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
119
|
-
const closedTooltip = getTooltipConfig(false)
|
120
|
-
const openTooltip = getTooltipConfig(true)
|
121
|
-
|
122
|
-
expect(closedTooltip.text).toBe('Expandir sección')
|
123
|
-
expect(openTooltip.text).toBe('Contraer sección')
|
124
|
-
|
125
|
-
// Verificar que el posicionamiento evita superposición
|
126
|
-
expect(closedTooltip.top).toBe('-3rem')
|
127
|
-
expect(closedTooltip.left).toBe('-2rem')
|
128
|
-
expect(openTooltip.top).toBe('-3rem')
|
129
|
-
expect(openTooltip.left).toBe('-2rem')
|
130
|
-
})
|
131
|
-
})
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { MultiSelector } from './selector'
|
3
|
-
|
4
|
-
export const SelectorTest = (props) => {
|
5
|
-
|
6
|
-
return (
|
7
|
-
<div>
|
8
|
-
<MultiSelector options={[
|
9
|
-
{label: 'Red', value: 'red', selected: true},
|
10
|
-
{label: 'Green', value: 'green', selected: false},
|
11
|
-
{label: 'Blue', value: 'blue', selected: false},
|
12
|
-
{label: 'Yellow', value: 'yellow', selected: false},
|
13
|
-
{label: 'Black', value: 'black', selected: false},
|
14
|
-
{label: 'White', value: 'white', selected: false},
|
15
|
-
{label: 'Gray', value: 'gray', selected: false},
|
16
|
-
|
17
|
-
]} />
|
18
|
-
</div>
|
19
|
-
)
|
20
|
-
}
|