@@ -2,7 +2,7 @@ import { beforeAll, beforeEach, describe, test, expect, vi } from 'vitest'
2
2
import { shallowMount , flushPromises , ComponentMountingOptions } from '@vue/test-utils'
3
3
4
4
import ColorPicker from './ColorPicker.vue'
5
- import { ColorPickerProps } from './types.js'
5
+ import { ColorChangeDetail , ColorPickerProps } from './types.js'
6
6
7
7
type MountingOptions = ComponentMountingOptions < ColorPickerProps > & {
8
8
// Overrides the props in `ComponentMountingOptions` to be more accurate.
@@ -31,7 +31,7 @@ describe('ColorPicker', () => {
31
31
expect ( wrapper . html ( ) ) . toBeTruthy ( )
32
32
} )
33
33
34
- test . each ( [
34
+ test . each < ColorPickerProps > ( [
35
35
{ } ,
36
36
{
37
37
color : '#ffffffff' ,
@@ -65,7 +65,7 @@ describe('ColorPicker', () => {
65
65
color : 'hsl(0, 0%, 100%, 1)' ,
66
66
alphaChannel : 'hide' ,
67
67
} ,
68
- ] as const ) ( 'initializes color space and thumb correctly with default color value' , ( props : ColorPickerProps ) => {
68
+ ] ) ( 'initializes color space and thumb correctly with default color value' , ( props ) => {
69
69
const wrapper = createWrapper ( {
70
70
props : {
71
71
defaultFormat : 'hex' ,
@@ -115,7 +115,7 @@ describe('ColorPicker', () => {
115
115
} )
116
116
117
117
describe ( 'props & attributes' , ( ) => {
118
- test . each ( [
118
+ test . each < [ ColorPickerProps , string ] > ( [
119
119
[
120
120
{ color : '#f00' } ,
121
121
'#f00' ,
@@ -132,7 +132,7 @@ describe('ColorPicker', () => {
132
132
{ color : { h : 180 , w : 33 , b : 50 , a : 1 } } ,
133
133
'#548080ff' ,
134
134
] ,
135
- ] as const ) ( 'mounts correctly with a valid color prop' , async ( props : ColorPickerProps , expectedHexInputValue ) => {
135
+ ] ) ( 'mounts correctly with a valid color prop' , async ( props , expectedHexInputValue ) => {
136
136
const wrapper = createWrapper ( {
137
137
props : {
138
138
defaultFormat : 'hex' ,
@@ -172,7 +172,7 @@ describe('ColorPicker', () => {
172
172
expect ( input . value ) . toBe ( '#ffffffff' )
173
173
} )
174
174
175
- test . each ( [
175
+ test . each < [ ColorPickerProps , string [ ] ] > ( [
176
176
[
177
177
{ defaultFormat : undefined } ,
178
178
[ 'H' , 'S' , 'L' ] ,
@@ -193,7 +193,7 @@ describe('ColorPicker', () => {
193
193
{ defaultFormat : 'rgb' } ,
194
194
[ 'R' , 'G' , 'B' ] ,
195
195
] ,
196
- ] as const ) ( 'sets active color format to “%s” when providing default format prop' , ( props : ColorPickerProps , expectedLabels ) => {
196
+ ] ) ( 'sets active color format to “%s” when providing default format prop' , ( props , expectedLabels ) => {
197
197
const wrapper = createWrapper ( { props } )
198
198
199
199
const inputGroupMarkup = wrapper . find ( '.vacp-color-input-group' ) . html ( )
@@ -261,10 +261,10 @@ describe('ColorPicker', () => {
261
261
}
262
262
} )
263
263
264
- test . each ( [
264
+ test . each < [ ColorPickerProps , boolean , string ] > ( [
265
265
[ { alphaChannel : 'show' } , true , 'hsl(180 0% 100% / 1)' ] ,
266
266
[ { alphaChannel : 'hide' } , false , 'hsl(180 0% 100%)' ] ,
267
- ] as const ) ( 'shows/hides correct elements when setting alphaChannel' , async ( props : ColorPickerProps , isElementVisible , expectedCssColor ) => {
267
+ ] ) ( 'shows/hides correct elements when setting alphaChannel' , async ( props , isElementVisible , expectedCssColor ) => {
268
268
const id = 'test-color-picker'
269
269
const wrapper = createWrapper ( {
270
270
attachTo : document . body ,
@@ -525,7 +525,7 @@ describe('ColorPicker', () => {
525
525
} )
526
526
} )
527
527
528
- test . each ( [
528
+ test . each < [ ColorPickerProps , string ] > ( [
529
529
[
530
530
{ defaultFormat : 'rgb' , alphaChannel : 'show' } ,
531
531
'rgb(255 255 255 / 1)' ,
@@ -546,7 +546,7 @@ describe('ColorPicker', () => {
546
546
{ defaultFormat : 'hex' , alphaChannel : 'hide' } ,
547
547
'#ffffff' ,
548
548
] ,
549
- ] as const ) ( 'copy button copies %s format as %s' , async ( props : ColorPickerProps , cssColor ) => {
549
+ ] ) ( 'copy button copies %s format as %s' , async ( props , cssColor ) => {
550
550
vi . spyOn ( global . navigator . clipboard , 'writeText' ) . mockImplementation ( vi . fn ( ( ) => Promise . resolve ( ) ) )
551
551
552
552
const wrapper = createWrapper ( { props } )
@@ -580,7 +580,7 @@ describe('ColorPicker', () => {
580
580
} )
581
581
582
582
describe ( 'color value inputs' , ( ) => {
583
- test . each ( [
583
+ test . each < [ ColorPickerProps , string , string ] > ( [
584
584
[
585
585
{ id : 'color-picker' , defaultFormat : 'rgb' } ,
586
586
'r' ,
@@ -596,7 +596,7 @@ describe('ColorPicker', () => {
596
596
'b' ,
597
597
'25.%' ,
598
598
] ,
599
- ] as const ) ( 'updating a color input with an invalid value does not update the internal color data' , async ( props : ColorPickerProps , channel , channelValue ) => {
599
+ ] ) ( 'updating a color input with an invalid value does not update the internal color data' , async ( props , channel , channelValue ) => {
600
600
const wrapper = createWrapper ( { props } )
601
601
602
602
const input = wrapper . find < HTMLInputElement > ( `#${ props . id } -color-${ props . defaultFormat } -${ channel } ` )
@@ -630,7 +630,7 @@ describe('ColorPicker', () => {
630
630
expect ( emittedColorChangeEvents ) . toBe ( undefined )
631
631
} )
632
632
633
- test . each ( [
633
+ test . each < [ ColorPickerProps , string , string ] > ( [
634
634
[
635
635
{ id : 'color-picker' , defaultFormat : 'rgb' } ,
636
636
'r' ,
@@ -646,7 +646,7 @@ describe('ColorPicker', () => {
646
646
'b' ,
647
647
'25.5%' ,
648
648
] ,
649
- ] as const ) ( 'updating a %s color input with a valid value updates the internal color data' , async ( props : ColorPickerProps , channel , channelValue ) => {
649
+ ] ) ( 'updating a %s color input with a valid value updates the internal color data' , async ( props , channel , channelValue ) => {
650
650
const wrapper = createWrapper ( { props } )
651
651
652
652
const input = wrapper . find < HTMLInputElement > ( `#${ props . id } -color-${ props . defaultFormat } -${ channel } ` )
@@ -681,7 +681,7 @@ describe('ColorPicker', () => {
681
681
} )
682
682
683
683
describe ( 'color-change event' , ( ) => {
684
- test . each ( [
684
+ test . each < [ ColorPickerProps , ColorChangeDetail ] > ( [
685
685
[
686
686
{ color : '#ff99aacc' , defaultFormat : 'hsl' , alphaChannel : 'show' } ,
687
687
{
@@ -799,7 +799,7 @@ describe('ColorPicker', () => {
799
799
} ,
800
800
} ,
801
801
] ,
802
- ] as const ) ( 'emits correct data' , async ( props : ColorPickerProps , expectedData ) => {
802
+ ] ) ( 'emits correct data' , async ( props , expectedData ) => {
803
803
const wrapper = createWrapper ( { props } )
804
804
805
805
await wrapper . setProps ( { color : props . color } )
@@ -812,7 +812,7 @@ describe('ColorPicker', () => {
812
812
} )
813
813
814
814
describe ( 'color inputs' , ( ) => {
815
- test . each ( [
815
+ test . each < [ ColorPickerProps , string ] > ( [
816
816
[
817
817
{ color : '#12345678' , alphaChannel : 'show' } ,
818
818
'#12345678' ,
@@ -845,7 +845,7 @@ describe('ColorPicker', () => {
845
845
{ color : '#123' , alphaChannel : 'hide' } ,
846
846
'#123' ,
847
847
] ,
848
- ] as const ) ( 'shows expected color for hex colors' , async ( props : ColorPickerProps , expectedHexColor ) => {
848
+ ] ) ( 'shows expected color for hex colors' , async ( props , expectedHexColor ) => {
849
849
const wrapper = createWrapper ( {
850
850
props : {
851
851
defaultFormat : 'hex' ,
0 commit comments