@yh-ui/components 0.1.21 → 0.1.23
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/README.md +2 -0
- package/dist/breadcrumb/src/breadcrumb-item.vue +10 -6
- package/dist/form/index.cjs +1 -1
- package/dist/form/index.d.ts +1 -1
- package/dist/form/index.mjs +1 -1
- package/dist/icon/index.cjs +1 -1
- package/dist/icon/index.d.ts +1 -1
- package/dist/icon/index.mjs +1 -1
- package/dist/loading/index.cjs +1 -1
- package/dist/loading/index.d.ts +1 -1
- package/dist/loading/index.mjs +1 -1
- package/dist/message/src/method.cjs +1 -1
- package/dist/message/src/method.d.ts +1 -1
- package/dist/message/src/method.mjs +1 -1
- package/dist/message-box/index.cjs +1 -1
- package/dist/message-box/index.d.ts +1 -1
- package/dist/message-box/index.mjs +1 -1
- package/dist/notification/src/method.cjs +1 -1
- package/dist/notification/src/method.d.ts +1 -1
- package/dist/notification/src/method.mjs +1 -1
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.d.ts +7 -5
- package/dist/resolver.mjs +1 -1
- package/dist/style.css +584 -0
- package/package.json +9 -8
- package/dist/affix/__tests__/affix.bottom.test.cjs +0 -101
- package/dist/affix/__tests__/affix.bottom.test.mjs +0 -88
- package/dist/affix/__tests__/affix.ssr.test.cjs +0 -38
- package/dist/affix/__tests__/affix.ssr.test.mjs +0 -51
- package/dist/affix/__tests__/affix.test.cjs +0 -185
- package/dist/affix/__tests__/affix.test.mjs +0 -180
- package/dist/ai-action-group/__tests__/ai-action-group.ssr.test.cjs +0 -55
- package/dist/ai-action-group/__tests__/ai-action-group.ssr.test.mjs +0 -39
- package/dist/ai-action-group/__tests__/ai-action-group.test.cjs +0 -235
- package/dist/ai-action-group/__tests__/ai-action-group.test.mjs +0 -157
- package/dist/ai-agent-card/__tests__/ai-agent-card.ssr.test.cjs +0 -61
- package/dist/ai-agent-card/__tests__/ai-agent-card.ssr.test.mjs +0 -65
- package/dist/ai-agent-card/__tests__/ai-agent-card.test.cjs +0 -205
- package/dist/ai-agent-card/__tests__/ai-agent-card.test.mjs +0 -133
- package/dist/ai-artifacts/__tests__/ai-artifacts.ssr.test.cjs +0 -73
- package/dist/ai-artifacts/__tests__/ai-artifacts.ssr.test.mjs +0 -68
- package/dist/ai-artifacts/__tests__/ai-artifacts.test.cjs +0 -128
- package/dist/ai-artifacts/__tests__/ai-artifacts.test.mjs +0 -109
- package/dist/ai-attachments/__tests__/ai-attachments.ssr.test.cjs +0 -50
- package/dist/ai-attachments/__tests__/ai-attachments.ssr.test.mjs +0 -33
- package/dist/ai-attachments/__tests__/ai-attachments.test.cjs +0 -113
- package/dist/ai-attachments/__tests__/ai-attachments.test.mjs +0 -81
- package/dist/ai-bubble/__tests__/ai-bubble.ssr.test.cjs +0 -95
- package/dist/ai-bubble/__tests__/ai-bubble.ssr.test.mjs +0 -66
- package/dist/ai-bubble/__tests__/ai-bubble.test.cjs +0 -624
- package/dist/ai-bubble/__tests__/ai-bubble.test.mjs +0 -393
- package/dist/ai-bubble-list/__tests__/ai-bubble-list.ssr.test.cjs +0 -51
- package/dist/ai-bubble-list/__tests__/ai-bubble-list.ssr.test.mjs +0 -51
- package/dist/ai-bubble-list/__tests__/ai-bubble-list.test.cjs +0 -138
- package/dist/ai-bubble-list/__tests__/ai-bubble-list.test.mjs +0 -112
- package/dist/ai-chat/__tests__/ai-chat.ssr.test.cjs +0 -90
- package/dist/ai-chat/__tests__/ai-chat.ssr.test.mjs +0 -77
- package/dist/ai-chat/__tests__/ai-chat.test.cjs +0 -177
- package/dist/ai-chat/__tests__/ai-chat.test.mjs +0 -129
- package/dist/ai-code-block/__tests__/ai-code-block.ssr.test.cjs +0 -75
- package/dist/ai-code-block/__tests__/ai-code-block.ssr.test.mjs +0 -57
- package/dist/ai-code-block/__tests__/ai-code-block.test.cjs +0 -174
- package/dist/ai-code-block/__tests__/ai-code-block.test.mjs +0 -108
- package/dist/ai-code-editor/__tests__/ai-code-editor.ssr.test.cjs +0 -46
- package/dist/ai-code-editor/__tests__/ai-code-editor.ssr.test.mjs +0 -39
- package/dist/ai-code-editor/__tests__/ai-code-editor.test.cjs +0 -90
- package/dist/ai-code-editor/__tests__/ai-code-editor.test.mjs +0 -78
- package/dist/ai-code-runner/__tests__/ai-code-runner.ssr.test.cjs +0 -28
- package/dist/ai-code-runner/__tests__/ai-code-runner.ssr.test.mjs +0 -26
- package/dist/ai-code-runner/__tests__/ai-code-runner.test.cjs +0 -69
- package/dist/ai-code-runner/__tests__/ai-code-runner.test.mjs +0 -66
- package/dist/ai-conversations/__tests__/ai-conversations.ssr.test.cjs +0 -50
- package/dist/ai-conversations/__tests__/ai-conversations.ssr.test.mjs +0 -42
- package/dist/ai-conversations/__tests__/ai-conversations.test.cjs +0 -67
- package/dist/ai-conversations/__tests__/ai-conversations.test.mjs +0 -51
- package/dist/ai-editor-sender/__tests__/ai-editor-sender.ssr.test.cjs +0 -62
- package/dist/ai-editor-sender/__tests__/ai-editor-sender.ssr.test.mjs +0 -50
- package/dist/ai-editor-sender/__tests__/ai-editor-sender.test.cjs +0 -315
- package/dist/ai-editor-sender/__tests__/ai-editor-sender.test.mjs +0 -226
- package/dist/ai-file-card/__tests__/ai-file-card.ssr.test.cjs +0 -45
- package/dist/ai-file-card/__tests__/ai-file-card.ssr.test.mjs +0 -29
- package/dist/ai-file-card/__tests__/ai-file-card.test.cjs +0 -160
- package/dist/ai-file-card/__tests__/ai-file-card.test.mjs +0 -109
- package/dist/ai-mention/__tests__/ai-mention.ssr.test.cjs +0 -38
- package/dist/ai-mention/__tests__/ai-mention.ssr.test.mjs +0 -37
- package/dist/ai-mention/__tests__/ai-mention.test.cjs +0 -113
- package/dist/ai-mention/__tests__/ai-mention.test.mjs +0 -84
- package/dist/ai-mermaid/__tests__/ai-mermaid.ssr.test.cjs +0 -43
- package/dist/ai-mermaid/__tests__/ai-mermaid.ssr.test.mjs +0 -33
- package/dist/ai-mermaid/__tests__/ai-mermaid.test.cjs +0 -113
- package/dist/ai-mermaid/__tests__/ai-mermaid.test.mjs +0 -92
- package/dist/ai-prompts/__tests__/ai-prompts.ssr.test.cjs +0 -49
- package/dist/ai-prompts/__tests__/ai-prompts.ssr.test.mjs +0 -41
- package/dist/ai-prompts/__tests__/ai-prompts.test.cjs +0 -54
- package/dist/ai-prompts/__tests__/ai-prompts.test.mjs +0 -38
- package/dist/ai-provider/__tests__/ai-provider.ssr.test.cjs +0 -33
- package/dist/ai-provider/__tests__/ai-provider.ssr.test.mjs +0 -34
- package/dist/ai-provider/__tests__/ai-provider.test.cjs +0 -38
- package/dist/ai-provider/__tests__/ai-provider.test.mjs +0 -33
- package/dist/ai-sender/__tests__/ai-sender.ssr.test.cjs +0 -46
- package/dist/ai-sender/__tests__/ai-sender.ssr.test.mjs +0 -37
- package/dist/ai-sender/__tests__/ai-sender.test.cjs +0 -511
- package/dist/ai-sender/__tests__/ai-sender.test.mjs +0 -322
- package/dist/ai-sources/__tests__/ai-sources.ssr.test.cjs +0 -72
- package/dist/ai-sources/__tests__/ai-sources.ssr.test.mjs +0 -82
- package/dist/ai-sources/__tests__/ai-sources.test.cjs +0 -200
- package/dist/ai-sources/__tests__/ai-sources.test.mjs +0 -160
- package/dist/ai-thinking/__tests__/ai-thinking.ssr.test.cjs +0 -56
- package/dist/ai-thinking/__tests__/ai-thinking.ssr.test.mjs +0 -42
- package/dist/ai-thinking/__tests__/ai-thinking.test.cjs +0 -151
- package/dist/ai-thinking/__tests__/ai-thinking.test.mjs +0 -96
- package/dist/ai-thought-chain/__tests__/ai-thought-chain.ssr.test.cjs +0 -88
- package/dist/ai-thought-chain/__tests__/ai-thought-chain.ssr.test.mjs +0 -55
- package/dist/ai-thought-chain/__tests__/ai-thought-chain.test.cjs +0 -344
- package/dist/ai-thought-chain/__tests__/ai-thought-chain.test.mjs +0 -237
- package/dist/ai-voice-trigger/__tests__/ai-voice-trigger.ssr.test.cjs +0 -32
- package/dist/ai-voice-trigger/__tests__/ai-voice-trigger.ssr.test.mjs +0 -25
- package/dist/ai-voice-trigger/__tests__/ai-voice-trigger.test.cjs +0 -130
- package/dist/ai-voice-trigger/__tests__/ai-voice-trigger.test.mjs +0 -103
- package/dist/ai-welcome/__tests__/ai-welcome.ssr.test.cjs +0 -57
- package/dist/ai-welcome/__tests__/ai-welcome.ssr.test.mjs +0 -39
- package/dist/ai-welcome/__tests__/ai-welcome.test.cjs +0 -169
- package/dist/ai-welcome/__tests__/ai-welcome.test.mjs +0 -113
- package/dist/alert/__tests__/alert.ssr.test.cjs +0 -28
- package/dist/alert/__tests__/alert.ssr.test.mjs +0 -29
- package/dist/alert/__tests__/alert.test.cjs +0 -123
- package/dist/alert/__tests__/alert.test.mjs +0 -110
- package/dist/autocomplete/__tests__/autocomplete.ssr.test.cjs +0 -54
- package/dist/autocomplete/__tests__/autocomplete.ssr.test.mjs +0 -47
- package/dist/autocomplete/__tests__/autocomplete.test.cjs +0 -299
- package/dist/autocomplete/__tests__/autocomplete.test.mjs +0 -263
- package/dist/avatar/__tests__/avatar.ssr.test.cjs +0 -103
- package/dist/avatar/__tests__/avatar.ssr.test.mjs +0 -108
- package/dist/avatar/__tests__/avatar.test.cjs +0 -146
- package/dist/avatar/__tests__/avatar.test.mjs +0 -125
- package/dist/back-top/__tests__/back-top.ssr.test.cjs +0 -13
- package/dist/back-top/__tests__/back-top.ssr.test.mjs +0 -10
- package/dist/back-top/__tests__/back-top.test.cjs +0 -88
- package/dist/back-top/__tests__/back-top.test.mjs +0 -76
- package/dist/badge/__tests__/badge.ssr.test.cjs +0 -36
- package/dist/badge/__tests__/badge.ssr.test.mjs +0 -33
- package/dist/badge/__tests__/badge.test.cjs +0 -115
- package/dist/badge/__tests__/badge.test.mjs +0 -112
- package/dist/breadcrumb/__tests__/breadcrumb.ssr.test.cjs +0 -22
- package/dist/breadcrumb/__tests__/breadcrumb.ssr.test.mjs +0 -20
- package/dist/breadcrumb/__tests__/breadcrumb.test.cjs +0 -64
- package/dist/breadcrumb/__tests__/breadcrumb.test.mjs +0 -51
- package/dist/button/__tests__/button.ssr.test.cjs +0 -52
- package/dist/button/__tests__/button.ssr.test.mjs +0 -55
- package/dist/button/__tests__/button.test.cjs +0 -207
- package/dist/button/__tests__/button.test.mjs +0 -141
- package/dist/calendar/__tests__/calendar.ssr.test.cjs +0 -65
- package/dist/calendar/__tests__/calendar.ssr.test.mjs +0 -63
- package/dist/calendar/__tests__/calendar.test.cjs +0 -263
- package/dist/calendar/__tests__/calendar.test.mjs +0 -255
- package/dist/card/__tests__/card.ssr.test.cjs +0 -37
- package/dist/card/__tests__/card.ssr.test.mjs +0 -40
- package/dist/card/__tests__/card.test.cjs +0 -131
- package/dist/card/__tests__/card.test.mjs +0 -124
- package/dist/carousel/__tests__/carousel.ssr.test.cjs +0 -27
- package/dist/carousel/__tests__/carousel.ssr.test.mjs +0 -27
- package/dist/carousel/__tests__/carousel.test.cjs +0 -115
- package/dist/carousel/__tests__/carousel.test.mjs +0 -98
- package/dist/cascader/__tests__/cascader-panel.test.cjs +0 -162
- package/dist/cascader/__tests__/cascader-panel.test.mjs +0 -151
- package/dist/cascader/__tests__/cascader.ssr.test.cjs +0 -61
- package/dist/cascader/__tests__/cascader.ssr.test.mjs +0 -55
- package/dist/cascader/__tests__/cascader.test.cjs +0 -342
- package/dist/cascader/__tests__/cascader.test.mjs +0 -316
- package/dist/category-nav/__tests__/category-nav.ssr.test.cjs +0 -35
- package/dist/category-nav/__tests__/category-nav.ssr.test.mjs +0 -21
- package/dist/category-nav/__tests__/category-nav.test.cjs +0 -53
- package/dist/category-nav/__tests__/category-nav.test.mjs +0 -33
- package/dist/checkbox/__tests__/checkbox.ssr.test.cjs +0 -52
- package/dist/checkbox/__tests__/checkbox.ssr.test.mjs +0 -57
- package/dist/checkbox/__tests__/checkbox.test.cjs +0 -173
- package/dist/checkbox/__tests__/checkbox.test.mjs +0 -133
- package/dist/col/__tests__/col.ssr.test.cjs +0 -44
- package/dist/col/__tests__/col.ssr.test.mjs +0 -42
- package/dist/col/__tests__/col.test.cjs +0 -128
- package/dist/col/__tests__/col.test.mjs +0 -116
- package/dist/color-picker/__tests__/color-picker.ssr.test.cjs +0 -34
- package/dist/color-picker/__tests__/color-picker.ssr.test.mjs +0 -39
- package/dist/color-picker/__tests__/color-picker.test.cjs +0 -227
- package/dist/color-picker/__tests__/color-picker.test.mjs +0 -176
- package/dist/config-provider/__tests__/config-provider.ssr.test.cjs +0 -43
- package/dist/config-provider/__tests__/config-provider.ssr.test.mjs +0 -42
- package/dist/config-provider/__tests__/config-provider.test.cjs +0 -75
- package/dist/config-provider/__tests__/config-provider.test.mjs +0 -64
- package/dist/container/__tests__/container.ssr.test.cjs +0 -71
- package/dist/container/__tests__/container.ssr.test.mjs +0 -50
- package/dist/container/__tests__/container.test.cjs +0 -111
- package/dist/container/__tests__/container.test.mjs +0 -84
- package/dist/countdown/__tests__/countdown.ssr.test.cjs +0 -86
- package/dist/countdown/__tests__/countdown.ssr.test.mjs +0 -78
- package/dist/countdown/__tests__/countdown.test.cjs +0 -767
- package/dist/countdown/__tests__/countdown.test.mjs +0 -722
- package/dist/coupon-card/__tests__/coupon-card.ssr.test.cjs +0 -21
- package/dist/coupon-card/__tests__/coupon-card.ssr.test.mjs +0 -18
- package/dist/coupon-card/__tests__/coupon-card.test.cjs +0 -67
- package/dist/coupon-card/__tests__/coupon-card.test.mjs +0 -64
- package/dist/date-picker/__tests__/date-picker-extended.test.cjs +0 -581
- package/dist/date-picker/__tests__/date-picker-extended.test.mjs +0 -455
- package/dist/date-picker/__tests__/date-picker.ssr.test.cjs +0 -26
- package/dist/date-picker/__tests__/date-picker.ssr.test.mjs +0 -23
- package/dist/date-picker/__tests__/date-picker.test.cjs +0 -170
- package/dist/date-picker/__tests__/date-picker.test.mjs +0 -136
- package/dist/descriptions/__tests__/descriptions.ssr.test.cjs +0 -67
- package/dist/descriptions/__tests__/descriptions.ssr.test.mjs +0 -72
- package/dist/descriptions/__tests__/descriptions.test.cjs +0 -150
- package/dist/descriptions/__tests__/descriptions.test.mjs +0 -130
- package/dist/dialog/__tests__/dialog.functional.test.cjs +0 -49
- package/dist/dialog/__tests__/dialog.functional.test.mjs +0 -49
- package/dist/dialog/__tests__/dialog.ssr.test.cjs +0 -31
- package/dist/dialog/__tests__/dialog.ssr.test.mjs +0 -29
- package/dist/dialog/__tests__/dialog.test.cjs +0 -561
- package/dist/dialog/__tests__/dialog.test.mjs +0 -388
- package/dist/divider/__tests__/divider.ssr.test.cjs +0 -41
- package/dist/divider/__tests__/divider.ssr.test.mjs +0 -44
- package/dist/divider/__tests__/divider.test.cjs +0 -71
- package/dist/divider/__tests__/divider.test.mjs +0 -68
- package/dist/drawer/__tests__/drawer.ssr.test.cjs +0 -25
- package/dist/drawer/__tests__/drawer.ssr.test.mjs +0 -23
- package/dist/drawer/__tests__/drawer.test.cjs +0 -145
- package/dist/drawer/__tests__/drawer.test.mjs +0 -122
- package/dist/dropdown/__tests__/dropdown.ssr.test.cjs +0 -49
- package/dist/dropdown/__tests__/dropdown.ssr.test.mjs +0 -64
- package/dist/dropdown/__tests__/dropdown.test.cjs +0 -310
- package/dist/dropdown/__tests__/dropdown.test.mjs +0 -269
- package/dist/empty/__tests__/empty.ssr.test.cjs +0 -96
- package/dist/empty/__tests__/empty.ssr.test.mjs +0 -99
- package/dist/empty/__tests__/empty.test.cjs +0 -110
- package/dist/empty/__tests__/empty.test.mjs +0 -101
- package/dist/filter-bar/__tests__/filter-bar.ssr.test.cjs +0 -29
- package/dist/filter-bar/__tests__/filter-bar.ssr.test.mjs +0 -16
- package/dist/filter-bar/__tests__/filter-bar.test.cjs +0 -51
- package/dist/filter-bar/__tests__/filter-bar.test.mjs +0 -29
- package/dist/form/__tests__/form-schema.test.cjs +0 -636
- package/dist/form/__tests__/form-schema.test.mjs +0 -366
- package/dist/form/__tests__/form.ssr.test.cjs +0 -74
- package/dist/form/__tests__/form.ssr.test.mjs +0 -73
- package/dist/form/__tests__/form.test.cjs +0 -208
- package/dist/form/__tests__/form.test.mjs +0 -128
- package/dist/gantt-chart/__tests__/debug_ssr.test.cjs +0 -51
- package/dist/gantt-chart/__tests__/debug_ssr.test.mjs +0 -37
- package/dist/gantt-chart/__tests__/gantt-chart.ssr.test.cjs +0 -95
- package/dist/gantt-chart/__tests__/gantt-chart.ssr.test.mjs +0 -94
- package/dist/gantt-chart/__tests__/gantt-chart.test.cjs +0 -86
- package/dist/gantt-chart/__tests__/gantt-chart.test.mjs +0 -79
- package/dist/grid/__tests__/grid.ssr.test.cjs +0 -81
- package/dist/grid/__tests__/grid.ssr.test.mjs +0 -63
- package/dist/grid/__tests__/grid.test.cjs +0 -142
- package/dist/grid/__tests__/grid.test.mjs +0 -89
- package/dist/icon/__tests__/icon.ssr.test.cjs +0 -35
- package/dist/icon/__tests__/icon.ssr.test.mjs +0 -26
- package/dist/icon/__tests__/icon.test.cjs +0 -144
- package/dist/icon/__tests__/icon.test.mjs +0 -123
- package/dist/image/__tests__/image-viewer.test.cjs +0 -101
- package/dist/image/__tests__/image-viewer.test.mjs +0 -94
- package/dist/image/__tests__/image.ssr.test.cjs +0 -73
- package/dist/image/__tests__/image.ssr.test.mjs +0 -72
- package/dist/image/__tests__/image.test.cjs +0 -171
- package/dist/image/__tests__/image.test.mjs +0 -159
- package/dist/image-magnifier/__tests__/image-magnifier.ssr.test.cjs +0 -54
- package/dist/image-magnifier/__tests__/image-magnifier.ssr.test.mjs +0 -35
- package/dist/image-magnifier/__tests__/image-magnifier.test.cjs +0 -257
- package/dist/image-magnifier/__tests__/image-magnifier.test.mjs +0 -177
- package/dist/infinite-scroll/__tests__/infinite-scroll.ssr.test.cjs +0 -59
- package/dist/infinite-scroll/__tests__/infinite-scroll.ssr.test.mjs +0 -84
- package/dist/infinite-scroll/__tests__/infinite-scroll.test.cjs +0 -255
- package/dist/infinite-scroll/__tests__/infinite-scroll.test.mjs +0 -187
- package/dist/input/__tests__/input-utils.test.cjs +0 -77
- package/dist/input/__tests__/input-utils.test.mjs +0 -75
- package/dist/input/__tests__/input.ssr.test.cjs +0 -100
- package/dist/input/__tests__/input.ssr.test.mjs +0 -85
- package/dist/input/__tests__/input.test.cjs +0 -127
- package/dist/input/__tests__/input.test.mjs +0 -112
- package/dist/input-number/__tests__/input-number.hydration.test.cjs +0 -24
- package/dist/input-number/__tests__/input-number.hydration.test.mjs +0 -21
- package/dist/input-number/__tests__/input-number.ssr.test.cjs +0 -95
- package/dist/input-number/__tests__/input-number.ssr.test.mjs +0 -92
- package/dist/input-number/__tests__/input-number.test.cjs +0 -199
- package/dist/input-number/__tests__/input-number.test.mjs +0 -173
- package/dist/input-tag/__tests__/input-tag.ssr.test.cjs +0 -47
- package/dist/input-tag/__tests__/input-tag.ssr.test.mjs +0 -41
- package/dist/input-tag/__tests__/input-tag.test.cjs +0 -268
- package/dist/input-tag/__tests__/input-tag.test.mjs +0 -201
- package/dist/loading/__tests__/loading.ssr.test.cjs +0 -37
- package/dist/loading/__tests__/loading.ssr.test.mjs +0 -27
- package/dist/loading/__tests__/loading.test.cjs +0 -91
- package/dist/loading/__tests__/loading.test.mjs +0 -75
- package/dist/lucky-draw/__tests__/lucky-draw.ssr.test.cjs +0 -33
- package/dist/lucky-draw/__tests__/lucky-draw.ssr.test.mjs +0 -31
- package/dist/lucky-draw/__tests__/lucky-draw.test.cjs +0 -56
- package/dist/lucky-draw/__tests__/lucky-draw.test.mjs +0 -48
- package/dist/marquee/__tests__/marquee.ssr.test.cjs +0 -59
- package/dist/marquee/__tests__/marquee.ssr.test.mjs +0 -60
- package/dist/marquee/__tests__/marquee.test.cjs +0 -94
- package/dist/marquee/__tests__/marquee.test.mjs +0 -92
- package/dist/mention/__tests__/mention.ssr.test.cjs +0 -92
- package/dist/mention/__tests__/mention.ssr.test.mjs +0 -70
- package/dist/mention/__tests__/mention.test.cjs +0 -650
- package/dist/mention/__tests__/mention.test.mjs +0 -523
- package/dist/menu/__tests__/menu.ssr.test.cjs +0 -92
- package/dist/menu/__tests__/menu.ssr.test.mjs +0 -124
- package/dist/menu/__tests__/menu.test.cjs +0 -209
- package/dist/menu/__tests__/menu.test.mjs +0 -182
- package/dist/message/__tests__/message.ssr.test.cjs +0 -29
- package/dist/message/__tests__/message.ssr.test.mjs +0 -23
- package/dist/message/__tests__/message.test.cjs +0 -170
- package/dist/message/__tests__/message.test.mjs +0 -154
- package/dist/message-box/__tests__/message-box.ssr.test.cjs +0 -33
- package/dist/message-box/__tests__/message-box.ssr.test.mjs +0 -30
- package/dist/message-box/__tests__/message-box.test.cjs +0 -100
- package/dist/message-box/__tests__/message-box.test.mjs +0 -95
- package/dist/notification/__tests__/notification.ssr.test.cjs +0 -31
- package/dist/notification/__tests__/notification.ssr.test.mjs +0 -25
- package/dist/notification/__tests__/notification.test.cjs +0 -248
- package/dist/notification/__tests__/notification.test.mjs +0 -206
- package/dist/pagination/__tests__/pagination.ssr.test.cjs +0 -61
- package/dist/pagination/__tests__/pagination.ssr.test.mjs +0 -59
- package/dist/pagination/__tests__/pagination.test.cjs +0 -135
- package/dist/pagination/__tests__/pagination.test.mjs +0 -131
- package/dist/popconfirm/__tests__/popconfirm.ssr.test.cjs +0 -48
- package/dist/popconfirm/__tests__/popconfirm.ssr.test.mjs +0 -63
- package/dist/popconfirm/__tests__/popconfirm.test.cjs +0 -62
- package/dist/popconfirm/__tests__/popconfirm.test.mjs +0 -56
- package/dist/popover/__tests__/popover.ssr.test.cjs +0 -48
- package/dist/popover/__tests__/popover.ssr.test.mjs +0 -63
- package/dist/popover/__tests__/popover.test.cjs +0 -107
- package/dist/popover/__tests__/popover.test.mjs +0 -93
- package/dist/price/__tests__/price.ssr.test.cjs +0 -20
- package/dist/price/__tests__/price.ssr.test.mjs +0 -19
- package/dist/price/__tests__/price.test.cjs +0 -45
- package/dist/price/__tests__/price.test.mjs +0 -42
- package/dist/product-card/__tests__/product-card.ssr.test.cjs +0 -21
- package/dist/product-card/__tests__/product-card.ssr.test.mjs +0 -18
- package/dist/product-card/__tests__/product-card.test.cjs +0 -54
- package/dist/product-card/__tests__/product-card.test.mjs +0 -53
- package/dist/progress/__tests__/progress.ssr.test.cjs +0 -31
- package/dist/progress/__tests__/progress.ssr.test.mjs +0 -29
- package/dist/progress/__tests__/progress.test.cjs +0 -119
- package/dist/progress/__tests__/progress.test.mjs +0 -77
- package/dist/radio/__tests__/radio-button.test.cjs +0 -99
- package/dist/radio/__tests__/radio-button.test.mjs +0 -83
- package/dist/radio/__tests__/radio.ssr.test.cjs +0 -132
- package/dist/radio/__tests__/radio.ssr.test.mjs +0 -165
- package/dist/radio/__tests__/radio.test.cjs +0 -170
- package/dist/radio/__tests__/radio.test.mjs +0 -143
- package/dist/rate/__tests__/rate.ssr.test.cjs +0 -106
- package/dist/rate/__tests__/rate.ssr.test.mjs +0 -103
- package/dist/rate/__tests__/rate.test.cjs +0 -88
- package/dist/rate/__tests__/rate.test.mjs +0 -85
- package/dist/result/__tests__/result.ssr.test.cjs +0 -62
- package/dist/result/__tests__/result.ssr.test.mjs +0 -51
- package/dist/result/__tests__/result.test.cjs +0 -135
- package/dist/result/__tests__/result.test.mjs +0 -92
- package/dist/row/__tests__/row.ssr.test.cjs +0 -29
- package/dist/row/__tests__/row.ssr.test.mjs +0 -30
- package/dist/row/__tests__/row.test.cjs +0 -89
- package/dist/row/__tests__/row.test.mjs +0 -86
- package/dist/row/__tests__/row_ts.test.cjs +0 -31
- package/dist/row/__tests__/row_ts.test.mjs +0 -28
- package/dist/scrollbar/__tests__/scrollbar.ssr.test.cjs +0 -49
- package/dist/scrollbar/__tests__/scrollbar.ssr.test.mjs +0 -54
- package/dist/scrollbar/__tests__/scrollbar.test.cjs +0 -43
- package/dist/scrollbar/__tests__/scrollbar.test.mjs +0 -40
- package/dist/select/__tests__/select.perf.test.cjs +0 -191
- package/dist/select/__tests__/select.perf.test.mjs +0 -185
- package/dist/select/__tests__/select.ssr.test.cjs +0 -58
- package/dist/select/__tests__/select.ssr.test.mjs +0 -52
- package/dist/select/__tests__/select.test.cjs +0 -414
- package/dist/select/__tests__/select.test.mjs +0 -345
- package/dist/skeleton/__tests__/skeleton.ssr.test.cjs +0 -81
- package/dist/skeleton/__tests__/skeleton.ssr.test.mjs +0 -83
- package/dist/skeleton/__tests__/skeleton.test.cjs +0 -72
- package/dist/skeleton/__tests__/skeleton.test.mjs +0 -65
- package/dist/sku-selector/__tests__/sku-selector.ssr.test.cjs +0 -32
- package/dist/sku-selector/__tests__/sku-selector.ssr.test.mjs +0 -19
- package/dist/sku-selector/__tests__/sku-selector.test.cjs +0 -64
- package/dist/sku-selector/__tests__/sku-selector.test.mjs +0 -53
- package/dist/slider/__tests__/repro.test.cjs +0 -25
- package/dist/slider/__tests__/repro.test.mjs +0 -22
- package/dist/slider/__tests__/slider.ssr.test.cjs +0 -118
- package/dist/slider/__tests__/slider.ssr.test.mjs +0 -115
- package/dist/slider/__tests__/slider.test.cjs +0 -155
- package/dist/slider/__tests__/slider.test.mjs +0 -120
- package/dist/smart-address/__tests__/smart-address.ssr.test.cjs +0 -28
- package/dist/smart-address/__tests__/smart-address.ssr.test.mjs +0 -25
- package/dist/smart-address/__tests__/smart-address.test.cjs +0 -68
- package/dist/smart-address/__tests__/smart-address.test.mjs +0 -56
- package/dist/space/__tests__/space.ssr.test.cjs +0 -115
- package/dist/space/__tests__/space.ssr.test.mjs +0 -150
- package/dist/space/__tests__/space.test.cjs +0 -227
- package/dist/space/__tests__/space.test.mjs +0 -187
- package/dist/spin/__tests__/spin.ssr.test.cjs +0 -46
- package/dist/spin/__tests__/spin.ssr.test.mjs +0 -43
- package/dist/spin/__tests__/spin.test.cjs +0 -65
- package/dist/spin/__tests__/spin.test.mjs +0 -63
- package/dist/steps/__tests__/steps.ssr.test.cjs +0 -73
- package/dist/steps/__tests__/steps.ssr.test.mjs +0 -55
- package/dist/steps/__tests__/steps.test.cjs +0 -152
- package/dist/steps/__tests__/steps.test.mjs +0 -123
- package/dist/submit-bar/__tests__/submit-bar.ssr.test.cjs +0 -21
- package/dist/submit-bar/__tests__/submit-bar.ssr.test.mjs +0 -18
- package/dist/submit-bar/__tests__/submit-bar.test.cjs +0 -50
- package/dist/submit-bar/__tests__/submit-bar.test.mjs +0 -36
- package/dist/switch/__tests__/switch.ssr.test.cjs +0 -105
- package/dist/switch/__tests__/switch.ssr.test.mjs +0 -102
- package/dist/switch/__tests__/switch.test.cjs +0 -251
- package/dist/switch/__tests__/switch.test.mjs +0 -193
- package/dist/table/__tests__/table-advance.test.cjs +0 -180
- package/dist/table/__tests__/table-advance.test.mjs +0 -118
- package/dist/table/__tests__/table-interaction.test.cjs +0 -236
- package/dist/table/__tests__/table-interaction.test.mjs +0 -162
- package/dist/table/__tests__/table-utils.test.cjs +0 -690
- package/dist/table/__tests__/table-utils.test.mjs +0 -485
- package/dist/table/__tests__/table.perf.test.cjs +0 -231
- package/dist/table/__tests__/table.perf.test.mjs +0 -225
- package/dist/table/__tests__/table.ssr.test.cjs +0 -296
- package/dist/table/__tests__/table.ssr.test.mjs +0 -265
- package/dist/table/__tests__/table.test.cjs +0 -682
- package/dist/table/__tests__/table.test.mjs +0 -617
- package/dist/table/__tests__/use-column-drag.test.cjs +0 -238
- package/dist/table/__tests__/use-column-drag.test.mjs +0 -150
- package/dist/table/__tests__/use-table-export.test.cjs +0 -179
- package/dist/table/__tests__/use-table-export.test.mjs +0 -105
- package/dist/table/__tests__/use-table-import.test.cjs +0 -206
- package/dist/table/__tests__/use-table-import.test.mjs +0 -144
- package/dist/table/__tests__/use-table-print.test.cjs +0 -190
- package/dist/table/__tests__/use-table-print.test.mjs +0 -134
- package/dist/table/__tests__/use-virtual-scroll.test.cjs +0 -286
- package/dist/table/__tests__/use-virtual-scroll.test.mjs +0 -196
- package/dist/tabs/__tests__/tabs.ssr.test.cjs +0 -57
- package/dist/tabs/__tests__/tabs.ssr.test.mjs +0 -41
- package/dist/tabs/__tests__/tabs.test.cjs +0 -171
- package/dist/tabs/__tests__/tabs.test.mjs +0 -134
- package/dist/tag/__tests__/tag.ssr.test.cjs +0 -45
- package/dist/tag/__tests__/tag.ssr.test.mjs +0 -48
- package/dist/tag/__tests__/tag.test.cjs +0 -194
- package/dist/tag/__tests__/tag.test.mjs +0 -167
- package/dist/time-picker/__tests__/time-picker.ssr.test.cjs +0 -46
- package/dist/time-picker/__tests__/time-picker.ssr.test.mjs +0 -43
- package/dist/time-picker/__tests__/time-picker.test.cjs +0 -228
- package/dist/time-picker/__tests__/time-picker.test.mjs +0 -218
- package/dist/time-picker/__tests__/time-spinner.test.cjs +0 -196
- package/dist/time-picker/__tests__/time-spinner.test.mjs +0 -162
- package/dist/time-select/__tests__/time-select.ssr.test.cjs +0 -42
- package/dist/time-select/__tests__/time-select.ssr.test.mjs +0 -37
- package/dist/time-select/__tests__/time-select.test.cjs +0 -390
- package/dist/time-select/__tests__/time-select.test.mjs +0 -374
- package/dist/tooltip/__tests__/tooltip.ssr.test.cjs +0 -55
- package/dist/tooltip/__tests__/tooltip.ssr.test.mjs +0 -76
- package/dist/tooltip/__tests__/tooltip.test.cjs +0 -132
- package/dist/tooltip/__tests__/tooltip.test.mjs +0 -121
- package/dist/transfer/__tests__/transfer.ssr.test.cjs +0 -47
- package/dist/transfer/__tests__/transfer.ssr.test.mjs +0 -44
- package/dist/transfer/__tests__/transfer.test.cjs +0 -422
- package/dist/transfer/__tests__/transfer.test.mjs +0 -405
- package/dist/tree/__tests__/tree.perf.test.cjs +0 -182
- package/dist/tree/__tests__/tree.perf.test.mjs +0 -198
- package/dist/tree/__tests__/tree.ssr.test.cjs +0 -56
- package/dist/tree/__tests__/tree.ssr.test.mjs +0 -45
- package/dist/tree/__tests__/tree.test.cjs +0 -488
- package/dist/tree/__tests__/tree.test.mjs +0 -333
- package/dist/tree-select/__tests__/tree-select.ssr.test.cjs +0 -52
- package/dist/tree-select/__tests__/tree-select.ssr.test.mjs +0 -55
- package/dist/tree-select/__tests__/tree-select.test.cjs +0 -231
- package/dist/tree-select/__tests__/tree-select.test.mjs +0 -189
- package/dist/typography/__tests__/typography.ssr.test.cjs +0 -85
- package/dist/typography/__tests__/typography.ssr.test.mjs +0 -63
- package/dist/typography/__tests__/typography.test.cjs +0 -362
- package/dist/typography/__tests__/typography.test.mjs +0 -161
- package/dist/upload/__tests__/upload.ssr.test.cjs +0 -28
- package/dist/upload/__tests__/upload.ssr.test.mjs +0 -26
- package/dist/upload/__tests__/upload.test.cjs +0 -467
- package/dist/upload/__tests__/upload.test.mjs +0 -336
- package/dist/waterfall/__tests__/waterfall.ssr.test.cjs +0 -38
- package/dist/waterfall/__tests__/waterfall.ssr.test.mjs +0 -39
- package/dist/waterfall/__tests__/waterfall.test.cjs +0 -122
- package/dist/waterfall/__tests__/waterfall.test.mjs +0 -85
- package/dist/watermark/__tests__/watermark.ssr.test.cjs +0 -32
- package/dist/watermark/__tests__/watermark.ssr.test.mjs +0 -30
- package/dist/watermark/__tests__/watermark.test.cjs +0 -127
- package/dist/watermark/__tests__/watermark.test.mjs +0 -124
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _vue = require("vue");
|
|
5
|
-
var _useTableImport = require("../src/use-table-import.cjs");
|
|
6
|
-
_vitest.vi.mock("@yh-ui/hooks", () => ({
|
|
7
|
-
useLocale: () => ({
|
|
8
|
-
t: key => key
|
|
9
|
-
})
|
|
10
|
-
}));
|
|
11
|
-
(0, _vitest.describe)("useTableImport hook", () => {
|
|
12
|
-
const mockData = (0, _vue.ref)([]);
|
|
13
|
-
const mockColumns = (0, _vue.ref)([{
|
|
14
|
-
prop: "id",
|
|
15
|
-
label: "ID"
|
|
16
|
-
}, {
|
|
17
|
-
prop: "name",
|
|
18
|
-
label: "Name"
|
|
19
|
-
}, {
|
|
20
|
-
prop: "age",
|
|
21
|
-
label: "Age"
|
|
22
|
-
}]);
|
|
23
|
-
(0, _vitest.beforeEach)(() => {
|
|
24
|
-
_vitest.vi.spyOn(console, "error").mockImplementation(() => {});
|
|
25
|
-
});
|
|
26
|
-
(0, _vitest.afterEach)(() => {
|
|
27
|
-
_vitest.vi.restoreAllMocks();
|
|
28
|
-
});
|
|
29
|
-
(0, _vitest.it)("parseCSV / parseTXT should map rows correctly", () => {
|
|
30
|
-
const {
|
|
31
|
-
parseCSV,
|
|
32
|
-
parseTXT
|
|
33
|
-
} = (0, _useTableImport.useTableImport)(mockData, mockColumns);
|
|
34
|
-
const csvContent = `ID,Name,Age
|
|
35
|
-
1,Alice,20
|
|
36
|
-
2,"Bob, Jr.",`;
|
|
37
|
-
const rows = parseCSV(csvContent, {
|
|
38
|
-
numberFields: ["id", "age"]
|
|
39
|
-
});
|
|
40
|
-
(0, _vitest.expect)(rows.length).toBe(2);
|
|
41
|
-
(0, _vitest.expect)(rows[0].id).toBe(1);
|
|
42
|
-
(0, _vitest.expect)(rows[0].name).toBe("Alice");
|
|
43
|
-
(0, _vitest.expect)(rows[0].age).toBe(20);
|
|
44
|
-
(0, _vitest.expect)(rows[1].id).toBe(2);
|
|
45
|
-
(0, _vitest.expect)(rows[1].name).toBe("Bob, Jr.");
|
|
46
|
-
(0, _vitest.expect)(rows[1].age).toBe(0);
|
|
47
|
-
const txtContent = `ID Name Age
|
|
48
|
-
1 Alice 20`;
|
|
49
|
-
const rowsTxt = parseTXT(txtContent);
|
|
50
|
-
(0, _vitest.expect)(rowsTxt.length).toBe(1);
|
|
51
|
-
(0, _vitest.expect)(rowsTxt[0].id).toBe("1");
|
|
52
|
-
});
|
|
53
|
-
(0, _vitest.it)("parseJSON should handle arrays and objects", () => {
|
|
54
|
-
const {
|
|
55
|
-
parseJSON
|
|
56
|
-
} = (0, _useTableImport.useTableImport)(mockData, mockColumns);
|
|
57
|
-
let rows = parseJSON('[{"ID": 1, "Name": "Alice"}]', {
|
|
58
|
-
autoMapping: true
|
|
59
|
-
});
|
|
60
|
-
(0, _vitest.expect)(rows[0].id).toBe(1);
|
|
61
|
-
rows = parseJSON('{"ID": 2, "Name": "Bob"}', {
|
|
62
|
-
fieldMapping: {
|
|
63
|
-
ID: "id",
|
|
64
|
-
Name: "name"
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
(0, _vitest.expect)(rows[0].id).toBe(2);
|
|
68
|
-
rows = parseJSON("invalid-json");
|
|
69
|
-
(0, _vitest.expect)(rows.length).toBe(0);
|
|
70
|
-
});
|
|
71
|
-
(0, _vitest.it)("parseXML should parse standard format", () => {
|
|
72
|
-
const {
|
|
73
|
-
parseXML
|
|
74
|
-
} = (0, _useTableImport.useTableImport)(mockData, mockColumns);
|
|
75
|
-
const xml = `
|
|
76
|
-
<table>
|
|
77
|
-
<columns>
|
|
78
|
-
<column name="ID"/>
|
|
79
|
-
<column name="Name"/>
|
|
80
|
-
</columns>
|
|
81
|
-
<rows>
|
|
82
|
-
<row><cell>1</cell><cell>Alice</cell></row>
|
|
83
|
-
</rows>
|
|
84
|
-
</table>
|
|
85
|
-
`;
|
|
86
|
-
const rows = parseXML(xml);
|
|
87
|
-
(0, _vitest.expect)(rows.length).toBe(1);
|
|
88
|
-
(0, _vitest.expect)(rows[0].id).toBe("1");
|
|
89
|
-
(0, _vitest.expect)(rows[0].name).toBe("Alice");
|
|
90
|
-
const domParserSpy = _vitest.vi.spyOn(DOMParser.prototype, "parseFromString").mockImplementationOnce(() => {
|
|
91
|
-
throw new Error("error");
|
|
92
|
-
});
|
|
93
|
-
(0, _vitest.expect)(parseXML("bad")).toEqual([]);
|
|
94
|
-
domParserSpy.mockRestore();
|
|
95
|
-
});
|
|
96
|
-
(0, _vitest.it)("parseHTML should parse standard format", () => {
|
|
97
|
-
const {
|
|
98
|
-
parseHTML
|
|
99
|
-
} = (0, _useTableImport.useTableImport)(mockData, mockColumns);
|
|
100
|
-
const html = `
|
|
101
|
-
<table>
|
|
102
|
-
<thead><tr><th>ID</th><th>Name</th></tr></thead>
|
|
103
|
-
<tbody>
|
|
104
|
-
<tr><td>1</td><td>Alice</td></tr>
|
|
105
|
-
</tbody>
|
|
106
|
-
</table>
|
|
107
|
-
`;
|
|
108
|
-
const rows = parseHTML(html);
|
|
109
|
-
(0, _vitest.expect)(rows.length).toBe(1);
|
|
110
|
-
(0, _vitest.expect)(rows[0].id).toBe("1");
|
|
111
|
-
(0, _vitest.expect)(rows[0].name).toBe("Alice");
|
|
112
|
-
const domParserSpy = _vitest.vi.spyOn(DOMParser.prototype, "parseFromString").mockImplementationOnce(() => {
|
|
113
|
-
throw new Error("error");
|
|
114
|
-
});
|
|
115
|
-
(0, _vitest.expect)(parseHTML("bad")).toEqual([]);
|
|
116
|
-
domParserSpy.mockRestore();
|
|
117
|
-
});
|
|
118
|
-
(0, _vitest.it)("parseXLSX should handle ArrayBuffer", () => {
|
|
119
|
-
const {
|
|
120
|
-
parseXLSX
|
|
121
|
-
} = (0, _useTableImport.useTableImport)(mockData, mockColumns);
|
|
122
|
-
const result = parseXLSX(new ArrayBuffer(10));
|
|
123
|
-
(0, _vitest.expect)(result).toEqual([]);
|
|
124
|
-
});
|
|
125
|
-
(0, _vitest.it)("importData should apply rows", async () => {
|
|
126
|
-
const dataRef = (0, _vue.ref)([{
|
|
127
|
-
existing: true
|
|
128
|
-
}]);
|
|
129
|
-
const {
|
|
130
|
-
importData
|
|
131
|
-
} = (0, _useTableImport.useTableImport)(dataRef, mockColumns);
|
|
132
|
-
await importData([{
|
|
133
|
-
added: true
|
|
134
|
-
}]);
|
|
135
|
-
(0, _vitest.expect)(dataRef.value.length).toBe(2);
|
|
136
|
-
(0, _vitest.expect)(dataRef.value[1].added).toBe(true);
|
|
137
|
-
await importData("ID,Name\n1,Alice", {
|
|
138
|
-
type: "csv"
|
|
139
|
-
});
|
|
140
|
-
(0, _vitest.expect)(dataRef.value.length).toBe(3);
|
|
141
|
-
(0, _vitest.expect)(dataRef.value[2].id).toBe("1");
|
|
142
|
-
await importData([{
|
|
143
|
-
top: true
|
|
144
|
-
}], {
|
|
145
|
-
mode: "insertTop"
|
|
146
|
-
});
|
|
147
|
-
(0, _vitest.expect)(dataRef.value[0].top).toBe(true);
|
|
148
|
-
await importData([{
|
|
149
|
-
cover: true
|
|
150
|
-
}], {
|
|
151
|
-
mode: "covering"
|
|
152
|
-
});
|
|
153
|
-
(0, _vitest.expect)(dataRef.value.length).toBe(1);
|
|
154
|
-
(0, _vitest.expect)(dataRef.value[0].cover).toBe(true);
|
|
155
|
-
const beforeImport = _vitest.vi.fn().mockResolvedValue([{
|
|
156
|
-
changed: true
|
|
157
|
-
}]);
|
|
158
|
-
await importData([{
|
|
159
|
-
original: true
|
|
160
|
-
}], {
|
|
161
|
-
beforeImport
|
|
162
|
-
});
|
|
163
|
-
(0, _vitest.expect)(dataRef.value[1].changed).toBe(true);
|
|
164
|
-
});
|
|
165
|
-
(0, _vitest.it)("importFile using FileReader", async () => {
|
|
166
|
-
const dataRef = (0, _vue.ref)([]);
|
|
167
|
-
const {
|
|
168
|
-
importFile
|
|
169
|
-
} = (0, _useTableImport.useTableImport)(dataRef, mockColumns);
|
|
170
|
-
const fakeFile = new File(["ID,Name\n1,Alice"], "test.csv", {
|
|
171
|
-
type: "text/csv"
|
|
172
|
-
});
|
|
173
|
-
const prom = importFile(fakeFile);
|
|
174
|
-
const rows = await prom;
|
|
175
|
-
(0, _vitest.expect)(rows.length).toBe(1);
|
|
176
|
-
(0, _vitest.expect)(rows[0].id).toBe("1");
|
|
177
|
-
(0, _vitest.expect)(dataRef.value.length).toBe(1);
|
|
178
|
-
});
|
|
179
|
-
(0, _vitest.it)("openImport should open file dialog", async () => {
|
|
180
|
-
const {
|
|
181
|
-
openImport
|
|
182
|
-
} = (0, _useTableImport.useTableImport)(mockData, mockColumns);
|
|
183
|
-
const oldCreate = document.createElement;
|
|
184
|
-
document.createElement = _vitest.vi.fn().mockImplementation(tag => {
|
|
185
|
-
if (tag === "input") {
|
|
186
|
-
return {
|
|
187
|
-
click() {
|
|
188
|
-
if (this.onchange) {
|
|
189
|
-
this.onchange({
|
|
190
|
-
target: {
|
|
191
|
-
files: []
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
return oldCreate.call(document, tag);
|
|
199
|
-
});
|
|
200
|
-
const res = await openImport({
|
|
201
|
-
type: "csv"
|
|
202
|
-
});
|
|
203
|
-
(0, _vitest.expect)(res).toEqual([]);
|
|
204
|
-
document.createElement = oldCreate;
|
|
205
|
-
});
|
|
206
|
-
});
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { ref } from "vue";
|
|
3
|
-
import { useTableImport } from "../src/use-table-import.mjs";
|
|
4
|
-
vi.mock("@yh-ui/hooks", () => ({
|
|
5
|
-
useLocale: () => ({ t: (key) => key })
|
|
6
|
-
}));
|
|
7
|
-
describe("useTableImport hook", () => {
|
|
8
|
-
const mockData = ref([]);
|
|
9
|
-
const mockColumns = ref([
|
|
10
|
-
{ prop: "id", label: "ID" },
|
|
11
|
-
{ prop: "name", label: "Name" },
|
|
12
|
-
{ prop: "age", label: "Age" }
|
|
13
|
-
]);
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
vi.spyOn(console, "error").mockImplementation(() => {
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
vi.restoreAllMocks();
|
|
20
|
-
});
|
|
21
|
-
it("parseCSV / parseTXT should map rows correctly", () => {
|
|
22
|
-
const { parseCSV, parseTXT } = useTableImport(mockData, mockColumns);
|
|
23
|
-
const csvContent = `ID,Name,Age
|
|
24
|
-
1,Alice,20
|
|
25
|
-
2,"Bob, Jr.",`;
|
|
26
|
-
const rows = parseCSV(csvContent, { numberFields: ["id", "age"] });
|
|
27
|
-
expect(rows.length).toBe(2);
|
|
28
|
-
expect(rows[0].id).toBe(1);
|
|
29
|
-
expect(rows[0].name).toBe("Alice");
|
|
30
|
-
expect(rows[0].age).toBe(20);
|
|
31
|
-
expect(rows[1].id).toBe(2);
|
|
32
|
-
expect(rows[1].name).toBe("Bob, Jr.");
|
|
33
|
-
expect(rows[1].age).toBe(0);
|
|
34
|
-
const txtContent = `ID Name Age
|
|
35
|
-
1 Alice 20`;
|
|
36
|
-
const rowsTxt = parseTXT(txtContent);
|
|
37
|
-
expect(rowsTxt.length).toBe(1);
|
|
38
|
-
expect(rowsTxt[0].id).toBe("1");
|
|
39
|
-
});
|
|
40
|
-
it("parseJSON should handle arrays and objects", () => {
|
|
41
|
-
const { parseJSON } = useTableImport(mockData, mockColumns);
|
|
42
|
-
let rows = parseJSON('[{"ID": 1, "Name": "Alice"}]', { autoMapping: true });
|
|
43
|
-
expect(rows[0].id).toBe(1);
|
|
44
|
-
rows = parseJSON('{"ID": 2, "Name": "Bob"}', { fieldMapping: { ID: "id", Name: "name" } });
|
|
45
|
-
expect(rows[0].id).toBe(2);
|
|
46
|
-
rows = parseJSON("invalid-json");
|
|
47
|
-
expect(rows.length).toBe(0);
|
|
48
|
-
});
|
|
49
|
-
it("parseXML should parse standard format", () => {
|
|
50
|
-
const { parseXML } = useTableImport(mockData, mockColumns);
|
|
51
|
-
const xml = `
|
|
52
|
-
<table>
|
|
53
|
-
<columns>
|
|
54
|
-
<column name="ID"/>
|
|
55
|
-
<column name="Name"/>
|
|
56
|
-
</columns>
|
|
57
|
-
<rows>
|
|
58
|
-
<row><cell>1</cell><cell>Alice</cell></row>
|
|
59
|
-
</rows>
|
|
60
|
-
</table>
|
|
61
|
-
`;
|
|
62
|
-
const rows = parseXML(xml);
|
|
63
|
-
expect(rows.length).toBe(1);
|
|
64
|
-
expect(rows[0].id).toBe("1");
|
|
65
|
-
expect(rows[0].name).toBe("Alice");
|
|
66
|
-
const domParserSpy = vi.spyOn(DOMParser.prototype, "parseFromString").mockImplementationOnce(() => {
|
|
67
|
-
throw new Error("error");
|
|
68
|
-
});
|
|
69
|
-
expect(parseXML("bad")).toEqual([]);
|
|
70
|
-
domParserSpy.mockRestore();
|
|
71
|
-
});
|
|
72
|
-
it("parseHTML should parse standard format", () => {
|
|
73
|
-
const { parseHTML } = useTableImport(mockData, mockColumns);
|
|
74
|
-
const html = `
|
|
75
|
-
<table>
|
|
76
|
-
<thead><tr><th>ID</th><th>Name</th></tr></thead>
|
|
77
|
-
<tbody>
|
|
78
|
-
<tr><td>1</td><td>Alice</td></tr>
|
|
79
|
-
</tbody>
|
|
80
|
-
</table>
|
|
81
|
-
`;
|
|
82
|
-
const rows = parseHTML(html);
|
|
83
|
-
expect(rows.length).toBe(1);
|
|
84
|
-
expect(rows[0].id).toBe("1");
|
|
85
|
-
expect(rows[0].name).toBe("Alice");
|
|
86
|
-
const domParserSpy = vi.spyOn(DOMParser.prototype, "parseFromString").mockImplementationOnce(() => {
|
|
87
|
-
throw new Error("error");
|
|
88
|
-
});
|
|
89
|
-
expect(parseHTML("bad")).toEqual([]);
|
|
90
|
-
domParserSpy.mockRestore();
|
|
91
|
-
});
|
|
92
|
-
it("parseXLSX should handle ArrayBuffer", () => {
|
|
93
|
-
const { parseXLSX } = useTableImport(mockData, mockColumns);
|
|
94
|
-
const result = parseXLSX(new ArrayBuffer(10));
|
|
95
|
-
expect(result).toEqual([]);
|
|
96
|
-
});
|
|
97
|
-
it("importData should apply rows", async () => {
|
|
98
|
-
const dataRef = ref([{ existing: true }]);
|
|
99
|
-
const { importData } = useTableImport(dataRef, mockColumns);
|
|
100
|
-
await importData([{ added: true }]);
|
|
101
|
-
expect(dataRef.value.length).toBe(2);
|
|
102
|
-
expect(dataRef.value[1].added).toBe(true);
|
|
103
|
-
await importData("ID,Name\n1,Alice", { type: "csv" });
|
|
104
|
-
expect(dataRef.value.length).toBe(3);
|
|
105
|
-
expect(dataRef.value[2].id).toBe("1");
|
|
106
|
-
await importData([{ top: true }], { mode: "insertTop" });
|
|
107
|
-
expect(dataRef.value[0].top).toBe(true);
|
|
108
|
-
await importData([{ cover: true }], { mode: "covering" });
|
|
109
|
-
expect(dataRef.value.length).toBe(1);
|
|
110
|
-
expect(dataRef.value[0].cover).toBe(true);
|
|
111
|
-
const beforeImport = vi.fn().mockResolvedValue([{ changed: true }]);
|
|
112
|
-
await importData([{ original: true }], { beforeImport });
|
|
113
|
-
expect(dataRef.value[1].changed).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
it("importFile using FileReader", async () => {
|
|
116
|
-
const dataRef = ref([]);
|
|
117
|
-
const { importFile } = useTableImport(dataRef, mockColumns);
|
|
118
|
-
const fakeFile = new File(["ID,Name\n1,Alice"], "test.csv", { type: "text/csv" });
|
|
119
|
-
const prom = importFile(fakeFile);
|
|
120
|
-
const rows = await prom;
|
|
121
|
-
expect(rows.length).toBe(1);
|
|
122
|
-
expect(rows[0].id).toBe("1");
|
|
123
|
-
expect(dataRef.value.length).toBe(1);
|
|
124
|
-
});
|
|
125
|
-
it("openImport should open file dialog", async () => {
|
|
126
|
-
const { openImport } = useTableImport(mockData, mockColumns);
|
|
127
|
-
const oldCreate = document.createElement;
|
|
128
|
-
document.createElement = vi.fn().mockImplementation((tag) => {
|
|
129
|
-
if (tag === "input") {
|
|
130
|
-
return {
|
|
131
|
-
click() {
|
|
132
|
-
if (this.onchange) {
|
|
133
|
-
this.onchange({ target: { files: [] } });
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
return oldCreate.call(document, tag);
|
|
139
|
-
});
|
|
140
|
-
const res = await openImport({ type: "csv" });
|
|
141
|
-
expect(res).toEqual([]);
|
|
142
|
-
document.createElement = oldCreate;
|
|
143
|
-
});
|
|
144
|
-
});
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _vue = require("vue");
|
|
5
|
-
var _useTablePrint = require("../src/use-table-print.cjs");
|
|
6
|
-
_vitest.vi.mock("@yh-ui/hooks", () => ({
|
|
7
|
-
useLocale: () => ({
|
|
8
|
-
t: key => key
|
|
9
|
-
})
|
|
10
|
-
}));
|
|
11
|
-
(0, _vitest.describe)("useTablePrint hook", () => {
|
|
12
|
-
const mockData = (0, _vue.ref)([{
|
|
13
|
-
id: 1,
|
|
14
|
-
name: "Alice",
|
|
15
|
-
role: "Admin"
|
|
16
|
-
}, {
|
|
17
|
-
id: 2,
|
|
18
|
-
name: "Bob",
|
|
19
|
-
role: "User"
|
|
20
|
-
}, {
|
|
21
|
-
id: 3,
|
|
22
|
-
name: "Carol",
|
|
23
|
-
role: "Guest"
|
|
24
|
-
}]);
|
|
25
|
-
const mockColumns = (0, _vue.ref)([{
|
|
26
|
-
prop: "id",
|
|
27
|
-
label: "ID",
|
|
28
|
-
align: "center"
|
|
29
|
-
}, {
|
|
30
|
-
prop: "name",
|
|
31
|
-
label: "Name"
|
|
32
|
-
}, {
|
|
33
|
-
prop: "role",
|
|
34
|
-
label: "Role",
|
|
35
|
-
visible: false
|
|
36
|
-
}, {
|
|
37
|
-
label: "Action"
|
|
38
|
-
}]);
|
|
39
|
-
let mockWin;
|
|
40
|
-
(0, _vitest.beforeEach)(() => {
|
|
41
|
-
_vitest.vi.clearAllMocks();
|
|
42
|
-
mockWin = {
|
|
43
|
-
document: {
|
|
44
|
-
write: _vitest.vi.fn(),
|
|
45
|
-
close: _vitest.vi.fn()
|
|
46
|
-
},
|
|
47
|
-
print: _vitest.vi.fn(),
|
|
48
|
-
onload: null
|
|
49
|
-
};
|
|
50
|
-
_vitest.vi.spyOn(window, "open").mockImplementation(() => mockWin);
|
|
51
|
-
});
|
|
52
|
-
(0, _vitest.it)("getPrintColumns checks visibility and includes/excludes", () => {
|
|
53
|
-
const {
|
|
54
|
-
getPrintColumns
|
|
55
|
-
} = (0, _useTablePrint.useTablePrint)(mockData, mockColumns);
|
|
56
|
-
let cols = getPrintColumns();
|
|
57
|
-
(0, _vitest.expect)(cols.length).toBe(2);
|
|
58
|
-
(0, _vitest.expect)(cols[0].prop).toBe("id");
|
|
59
|
-
(0, _vitest.expect)(cols[1].prop).toBe("name");
|
|
60
|
-
cols = getPrintColumns({
|
|
61
|
-
columns: ["id", "role"]
|
|
62
|
-
});
|
|
63
|
-
(0, _vitest.expect)(cols.length).toBe(1);
|
|
64
|
-
cols = getPrintColumns({
|
|
65
|
-
excludeColumns: ["name"]
|
|
66
|
-
});
|
|
67
|
-
(0, _vitest.expect)(cols.length).toBe(1);
|
|
68
|
-
(0, _vitest.expect)(cols[0].prop).toBe("id");
|
|
69
|
-
});
|
|
70
|
-
(0, _vitest.it)("print should handle different configs", async () => {
|
|
71
|
-
const {
|
|
72
|
-
print
|
|
73
|
-
} = (0, _useTablePrint.useTablePrint)(mockData, mockColumns);
|
|
74
|
-
await print({
|
|
75
|
-
title: "Report",
|
|
76
|
-
showIndex: true,
|
|
77
|
-
pageSize: 2,
|
|
78
|
-
showPageNumber: true,
|
|
79
|
-
extraCss: ".custom { color: red }",
|
|
80
|
-
tableStyle: "border: 1px solid black",
|
|
81
|
-
headerHtml: "<p>Header</p>",
|
|
82
|
-
footerHtml: "<p>Footer</p>",
|
|
83
|
-
formatCell: (val, col) => col.prop === "id" ? `ID-${val}` : String(val),
|
|
84
|
-
columnTitles: {
|
|
85
|
-
name: "Full Name"
|
|
86
|
-
},
|
|
87
|
-
autoPrint: true
|
|
88
|
-
});
|
|
89
|
-
(0, _vitest.expect)(window.open).toHaveBeenCalled();
|
|
90
|
-
(0, _vitest.expect)(mockWin.document.write).toHaveBeenCalled();
|
|
91
|
-
const html = mockWin.document.write.mock.calls[0][0];
|
|
92
|
-
(0, _vitest.expect)(html).toContain("Full Name");
|
|
93
|
-
(0, _vitest.expect)(html).toContain("ID-1");
|
|
94
|
-
(0, _vitest.expect)(html).toContain("Report");
|
|
95
|
-
(0, _vitest.expect)(html).toContain("Header");
|
|
96
|
-
(0, _vitest.expect)(html).toContain("Footer");
|
|
97
|
-
(0, _vitest.expect)(html).toContain("page-break");
|
|
98
|
-
if (mockWin.onload) {
|
|
99
|
-
mockWin.onload();
|
|
100
|
-
(0, _vitest.expect)(mockWin.print).toHaveBeenCalled();
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
(0, _vitest.it)("print aborted if beforePrint returns false", async () => {
|
|
104
|
-
const {
|
|
105
|
-
print
|
|
106
|
-
} = (0, _useTablePrint.useTablePrint)(mockData, mockColumns);
|
|
107
|
-
const beforePrint = _vitest.vi.fn().mockReturnValue(false);
|
|
108
|
-
await print({
|
|
109
|
-
beforePrint
|
|
110
|
-
});
|
|
111
|
-
(0, _vitest.expect)(window.open).not.toHaveBeenCalled();
|
|
112
|
-
});
|
|
113
|
-
(0, _vitest.it)("printMultiple handles multiple tables", async () => {
|
|
114
|
-
const {
|
|
115
|
-
printMultiple
|
|
116
|
-
} = (0, _useTablePrint.useTablePrint)(mockData, mockColumns);
|
|
117
|
-
const afterPrint = _vitest.vi.fn();
|
|
118
|
-
await printMultiple([{
|
|
119
|
-
title: "Table 1",
|
|
120
|
-
data: [{
|
|
121
|
-
a: 1
|
|
122
|
-
}],
|
|
123
|
-
columns: [{
|
|
124
|
-
prop: "a",
|
|
125
|
-
label: "A"
|
|
126
|
-
}]
|
|
127
|
-
}, {
|
|
128
|
-
title: "Table 2",
|
|
129
|
-
data: [{
|
|
130
|
-
b: 2
|
|
131
|
-
}]
|
|
132
|
-
// Use fallback columns from hook
|
|
133
|
-
}], {
|
|
134
|
-
orientation: "landscape",
|
|
135
|
-
margin: {
|
|
136
|
-
top: "5mm",
|
|
137
|
-
bottom: "5mm",
|
|
138
|
-
left: "5mm",
|
|
139
|
-
right: "5mm"
|
|
140
|
-
},
|
|
141
|
-
showTime: false,
|
|
142
|
-
showCount: false,
|
|
143
|
-
afterPrint
|
|
144
|
-
});
|
|
145
|
-
(0, _vitest.expect)(window.open).toHaveBeenCalled();
|
|
146
|
-
const html = mockWin.document.write.mock.calls[0][0];
|
|
147
|
-
(0, _vitest.expect)(html).toContain("Table 1");
|
|
148
|
-
(0, _vitest.expect)(html).toContain("Table 2");
|
|
149
|
-
(0, _vitest.expect)(html).toContain("landscape");
|
|
150
|
-
(0, _vitest.expect)(afterPrint).toHaveBeenCalled();
|
|
151
|
-
});
|
|
152
|
-
(0, _vitest.it)("printMultiple aborted if global beforePrint returns false", async () => {
|
|
153
|
-
const {
|
|
154
|
-
printMultiple
|
|
155
|
-
} = (0, _useTablePrint.useTablePrint)(mockData, mockColumns);
|
|
156
|
-
await printMultiple([], {
|
|
157
|
-
beforePrint: () => false
|
|
158
|
-
});
|
|
159
|
-
(0, _vitest.expect)(window.open).not.toHaveBeenCalled();
|
|
160
|
-
});
|
|
161
|
-
(0, _vitest.it)("printTemplate pushes raw html", async () => {
|
|
162
|
-
const {
|
|
163
|
-
printTemplate
|
|
164
|
-
} = (0, _useTablePrint.useTablePrint)(mockData, mockColumns);
|
|
165
|
-
await printTemplate('<div id="custom-template">OK</div>', {
|
|
166
|
-
autoPrint: true
|
|
167
|
-
});
|
|
168
|
-
(0, _vitest.expect)(window.open).toHaveBeenCalled();
|
|
169
|
-
const html = mockWin.document.write.mock.calls[0][0];
|
|
170
|
-
(0, _vitest.expect)(html).toContain("custom-template");
|
|
171
|
-
if (mockWin.onload) mockWin.onload();
|
|
172
|
-
(0, _vitest.expect)(mockWin.print).toHaveBeenCalled();
|
|
173
|
-
});
|
|
174
|
-
(0, _vitest.it)("printTemplate aborted if beforePrint returns false", async () => {
|
|
175
|
-
const {
|
|
176
|
-
printTemplate
|
|
177
|
-
} = (0, _useTablePrint.useTablePrint)(mockData, mockColumns);
|
|
178
|
-
await printTemplate('<div id="custom-template">OK</div>', {
|
|
179
|
-
beforePrint: () => false
|
|
180
|
-
});
|
|
181
|
-
(0, _vitest.expect)(window.open).not.toHaveBeenCalled();
|
|
182
|
-
});
|
|
183
|
-
(0, _vitest.it)("covers null window.open", async () => {
|
|
184
|
-
_vitest.vi.spyOn(window, "open").mockReturnValueOnce(null);
|
|
185
|
-
const {
|
|
186
|
-
print
|
|
187
|
-
} = (0, _useTablePrint.useTablePrint)(mockData, mockColumns);
|
|
188
|
-
await print();
|
|
189
|
-
});
|
|
190
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { ref } from "vue";
|
|
3
|
-
import { useTablePrint } from "../src/use-table-print.mjs";
|
|
4
|
-
vi.mock("@yh-ui/hooks", () => ({
|
|
5
|
-
useLocale: () => ({ t: (key) => key })
|
|
6
|
-
}));
|
|
7
|
-
describe("useTablePrint hook", () => {
|
|
8
|
-
const mockData = ref([
|
|
9
|
-
{ id: 1, name: "Alice", role: "Admin" },
|
|
10
|
-
{ id: 2, name: "Bob", role: "User" },
|
|
11
|
-
{ id: 3, name: "Carol", role: "Guest" }
|
|
12
|
-
]);
|
|
13
|
-
const mockColumns = ref([
|
|
14
|
-
{ prop: "id", label: "ID", align: "center" },
|
|
15
|
-
{ prop: "name", label: "Name" },
|
|
16
|
-
{ prop: "role", label: "Role", visible: false },
|
|
17
|
-
{ label: "Action" }
|
|
18
|
-
]);
|
|
19
|
-
let mockWin;
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
vi.clearAllMocks();
|
|
22
|
-
mockWin = {
|
|
23
|
-
document: {
|
|
24
|
-
write: vi.fn(),
|
|
25
|
-
close: vi.fn()
|
|
26
|
-
},
|
|
27
|
-
print: vi.fn(),
|
|
28
|
-
onload: null
|
|
29
|
-
};
|
|
30
|
-
vi.spyOn(window, "open").mockImplementation(() => mockWin);
|
|
31
|
-
});
|
|
32
|
-
it("getPrintColumns checks visibility and includes/excludes", () => {
|
|
33
|
-
const { getPrintColumns } = useTablePrint(mockData, mockColumns);
|
|
34
|
-
let cols = getPrintColumns();
|
|
35
|
-
expect(cols.length).toBe(2);
|
|
36
|
-
expect(cols[0].prop).toBe("id");
|
|
37
|
-
expect(cols[1].prop).toBe("name");
|
|
38
|
-
cols = getPrintColumns({ columns: ["id", "role"] });
|
|
39
|
-
expect(cols.length).toBe(1);
|
|
40
|
-
cols = getPrintColumns({ excludeColumns: ["name"] });
|
|
41
|
-
expect(cols.length).toBe(1);
|
|
42
|
-
expect(cols[0].prop).toBe("id");
|
|
43
|
-
});
|
|
44
|
-
it("print should handle different configs", async () => {
|
|
45
|
-
const { print } = useTablePrint(mockData, mockColumns);
|
|
46
|
-
await print({
|
|
47
|
-
title: "Report",
|
|
48
|
-
showIndex: true,
|
|
49
|
-
pageSize: 2,
|
|
50
|
-
showPageNumber: true,
|
|
51
|
-
extraCss: ".custom { color: red }",
|
|
52
|
-
tableStyle: "border: 1px solid black",
|
|
53
|
-
headerHtml: "<p>Header</p>",
|
|
54
|
-
footerHtml: "<p>Footer</p>",
|
|
55
|
-
formatCell: (val, col) => col.prop === "id" ? `ID-${val}` : String(val),
|
|
56
|
-
columnTitles: { name: "Full Name" },
|
|
57
|
-
autoPrint: true
|
|
58
|
-
});
|
|
59
|
-
expect(window.open).toHaveBeenCalled();
|
|
60
|
-
expect(mockWin.document.write).toHaveBeenCalled();
|
|
61
|
-
const html = mockWin.document.write.mock.calls[0][0];
|
|
62
|
-
expect(html).toContain("Full Name");
|
|
63
|
-
expect(html).toContain("ID-1");
|
|
64
|
-
expect(html).toContain("Report");
|
|
65
|
-
expect(html).toContain("Header");
|
|
66
|
-
expect(html).toContain("Footer");
|
|
67
|
-
expect(html).toContain("page-break");
|
|
68
|
-
if (mockWin.onload) {
|
|
69
|
-
mockWin.onload();
|
|
70
|
-
expect(mockWin.print).toHaveBeenCalled();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
it("print aborted if beforePrint returns false", async () => {
|
|
74
|
-
const { print } = useTablePrint(mockData, mockColumns);
|
|
75
|
-
const beforePrint = vi.fn().mockReturnValue(false);
|
|
76
|
-
await print({ beforePrint });
|
|
77
|
-
expect(window.open).not.toHaveBeenCalled();
|
|
78
|
-
});
|
|
79
|
-
it("printMultiple handles multiple tables", async () => {
|
|
80
|
-
const { printMultiple } = useTablePrint(mockData, mockColumns);
|
|
81
|
-
const afterPrint = vi.fn();
|
|
82
|
-
await printMultiple(
|
|
83
|
-
[
|
|
84
|
-
{
|
|
85
|
-
title: "Table 1",
|
|
86
|
-
data: [{ a: 1 }],
|
|
87
|
-
columns: [{ prop: "a", label: "A" }]
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
title: "Table 2",
|
|
91
|
-
data: [{ b: 2 }]
|
|
92
|
-
// Use fallback columns from hook
|
|
93
|
-
}
|
|
94
|
-
],
|
|
95
|
-
{
|
|
96
|
-
orientation: "landscape",
|
|
97
|
-
margin: { top: "5mm", bottom: "5mm", left: "5mm", right: "5mm" },
|
|
98
|
-
showTime: false,
|
|
99
|
-
showCount: false,
|
|
100
|
-
afterPrint
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
expect(window.open).toHaveBeenCalled();
|
|
104
|
-
const html = mockWin.document.write.mock.calls[0][0];
|
|
105
|
-
expect(html).toContain("Table 1");
|
|
106
|
-
expect(html).toContain("Table 2");
|
|
107
|
-
expect(html).toContain("landscape");
|
|
108
|
-
expect(afterPrint).toHaveBeenCalled();
|
|
109
|
-
});
|
|
110
|
-
it("printMultiple aborted if global beforePrint returns false", async () => {
|
|
111
|
-
const { printMultiple } = useTablePrint(mockData, mockColumns);
|
|
112
|
-
await printMultiple([], { beforePrint: () => false });
|
|
113
|
-
expect(window.open).not.toHaveBeenCalled();
|
|
114
|
-
});
|
|
115
|
-
it("printTemplate pushes raw html", async () => {
|
|
116
|
-
const { printTemplate } = useTablePrint(mockData, mockColumns);
|
|
117
|
-
await printTemplate('<div id="custom-template">OK</div>', { autoPrint: true });
|
|
118
|
-
expect(window.open).toHaveBeenCalled();
|
|
119
|
-
const html = mockWin.document.write.mock.calls[0][0];
|
|
120
|
-
expect(html).toContain("custom-template");
|
|
121
|
-
if (mockWin.onload) mockWin.onload();
|
|
122
|
-
expect(mockWin.print).toHaveBeenCalled();
|
|
123
|
-
});
|
|
124
|
-
it("printTemplate aborted if beforePrint returns false", async () => {
|
|
125
|
-
const { printTemplate } = useTablePrint(mockData, mockColumns);
|
|
126
|
-
await printTemplate('<div id="custom-template">OK</div>', { beforePrint: () => false });
|
|
127
|
-
expect(window.open).not.toHaveBeenCalled();
|
|
128
|
-
});
|
|
129
|
-
it("covers null window.open", async () => {
|
|
130
|
-
vi.spyOn(window, "open").mockReturnValueOnce(null);
|
|
131
|
-
const { print } = useTablePrint(mockData, mockColumns);
|
|
132
|
-
await print();
|
|
133
|
-
});
|
|
134
|
-
});
|