@@ -131,10 +131,10 @@ describe('ColorArea', () => {
131
131
Name | props | actions | result
132
132
${ 'left/right' } | ${ { defaultValue : parseColor ( '#ff00ff' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowLeft' } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowRight' } ) } } | ${ parseColor ( '#ff00fe' ) }
133
133
${ 'up/down' } | ${ { defaultValue : parseColor ( '#ff00ff' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowUp' } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowDown' } ) } } | ${ parseColor ( '#ff01ff' ) }
134
- ${ 'shiftleft/shiftright' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowLeft' , shiftKey : true } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowRight' , shiftKey : true } ) } } | ${ parseColor ( '#f000e0 ' ) }
135
- ${ 'shiftup/shiftdown' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowUp' , shiftKey : true } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowDown' , shiftKey : true } ) } } | ${ parseColor ( '#f010f0 ' ) }
136
- ${ 'pageup/pagedown' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'PageUp' } ) , backward : ( elem ) => pressKey ( elem , { key : 'PageDown' } ) } } | ${ parseColor ( '#f010f0 ' ) }
137
- ${ 'home/end' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'Home' } ) , backward : ( elem ) => pressKey ( elem , { key : 'End' } ) } } | ${ parseColor ( '#f000e0 ' ) }
134
+ ${ 'shiftleft/shiftright' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowLeft' , shiftKey : true } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowRight' , shiftKey : true } ) } } | ${ parseColor ( '#f000df ' ) }
135
+ ${ 'shiftup/shiftdown' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowUp' , shiftKey : true } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowDown' , shiftKey : true } ) } } | ${ parseColor ( '#f011f0 ' ) }
136
+ ${ 'pageup/pagedown' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'PageUp' } ) , backward : ( elem ) => pressKey ( elem , { key : 'PageDown' } ) } } | ${ parseColor ( '#f011f0 ' ) }
137
+ ${ 'home/end' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'Home' } ) , backward : ( elem ) => pressKey ( elem , { key : 'End' } ) } } | ${ parseColor ( '#f000df ' ) }
138
138
` ( '$Name' , ( { props, actions : { forward, backward} , result} ) => {
139
139
let { getAllByRole} = render (
140
140
< Component
@@ -162,10 +162,10 @@ describe('ColorArea', () => {
162
162
Name | props | actions | result
163
163
${ 'left/right' } | ${ { defaultValue : parseColor ( '#ff00ff' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowRight' } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowLeft' } ) } } | ${ parseColor ( '#ff00fe' ) }
164
164
${ 'up/down' } | ${ { defaultValue : parseColor ( '#ff00ff' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowUp' } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowDown' } ) } } | ${ parseColor ( '#ff01ff' ) }
165
- ${ 'shiftleft/shiftright' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowRight' , shiftKey : true } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowLeft' , shiftKey : true } ) } } | ${ parseColor ( '#f000e0 ' ) }
166
- ${ 'shiftup/shiftdown' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowUp' , shiftKey : true } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowDown' , shiftKey : true } ) } } | ${ parseColor ( '#f010f0 ' ) }
167
- ${ 'pageup/pagedown' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'PageUp' } ) , backward : ( elem ) => pressKey ( elem , { key : 'PageDown' } ) } } | ${ parseColor ( '#f010f0 ' ) }
168
- ${ 'home/end' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'End' } ) , backward : ( elem ) => pressKey ( elem , { key : 'Home' } ) } } | ${ parseColor ( '#f000e0 ' ) }
165
+ ${ 'shiftleft/shiftright' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowRight' , shiftKey : true } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowLeft' , shiftKey : true } ) } } | ${ parseColor ( '#f000df ' ) }
166
+ ${ 'shiftup/shiftdown' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowUp' , shiftKey : true } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowDown' , shiftKey : true } ) } } | ${ parseColor ( '#f011f0 ' ) }
167
+ ${ 'pageup/pagedown' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'PageUp' } ) , backward : ( elem ) => pressKey ( elem , { key : 'PageDown' } ) } } | ${ parseColor ( '#f011f0 ' ) }
168
+ ${ 'home/end' } | ${ { defaultValue : parseColor ( '#f000f0' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'End' } ) , backward : ( elem ) => pressKey ( elem , { key : 'Home' } ) } } | ${ parseColor ( '#f000df ' ) }
169
169
` ( '$Name RTL' , ( { props, actions : { forward, backward} , result} ) => {
170
170
let { getAllByRole} = render (
171
171
< Provider locale = "ar-AE" theme = { defaultTheme } >
@@ -213,35 +213,6 @@ describe('ColorArea', () => {
213
213
expect ( onChangeSpy ) . not . toHaveBeenCalled ( ) ;
214
214
expect ( onChangeEndSpy ) . not . toHaveBeenCalled ( ) ;
215
215
} ) ;
216
-
217
- it . each `
218
- Name | props | actions | result
219
- ${ 'left/right' } | ${ { defaultValue : parseColor ( '#ff00ff' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowLeft' } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowRight' } ) } } | ${ parseColor ( '#ff00f0' ) }
220
- ${ 'up/down' } | ${ { defaultValue : parseColor ( '#ff00ff' ) } } | ${ { forward : ( elem ) => pressKey ( elem , { key : 'ArrowUp' } ) , backward : ( elem ) => pressKey ( elem , { key : 'ArrowDown' } ) } } | ${ parseColor ( '#ff0fff' ) }
221
- ` ( '$Name with step' , ( { props, actions : { forward, backward} , result} ) => {
222
- let { getAllByRole} = render (
223
- < Component
224
- { ...props }
225
- xChannelStep = { 0xf }
226
- yChannelStep = { 0xf }
227
- onChange = { onChangeSpy }
228
- onChangeEnd = { onChangeEndSpy } />
229
- ) ;
230
- let sliders = getAllByRole ( 'slider' ) ;
231
- userEvent . tab ( ) ;
232
-
233
- forward ( sliders [ 0 ] ) ;
234
- expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 1 ) ;
235
- expect ( onChangeSpy . mock . calls [ 0 ] [ 0 ] . toString ( 'rgba' ) ) . toBe ( result . toString ( 'rgba' ) ) ;
236
- expect ( onChangeEndSpy ) . toHaveBeenCalledTimes ( 1 ) ;
237
- expect ( onChangeEndSpy . mock . calls [ 0 ] [ 0 ] . toString ( 'rgba' ) ) . toBe ( result . toString ( 'rgba' ) ) ;
238
-
239
- backward ( sliders [ 0 ] ) ;
240
- expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 2 ) ;
241
- expect ( onChangeSpy . mock . calls [ 1 ] [ 0 ] . toString ( 'rgba' ) ) . toBe ( props . defaultValue . toString ( 'rgba' ) ) ;
242
- expect ( onChangeEndSpy ) . toHaveBeenCalledTimes ( 2 ) ;
243
- expect ( onChangeEndSpy . mock . calls [ 1 ] [ 0 ] . toString ( 'rgba' ) ) . toBe ( props . defaultValue . toString ( 'rgba' ) ) ;
244
- } ) ;
245
216
} ) ;
246
217
247
218
describe . each `
@@ -351,34 +322,6 @@ describe('ColorArea', () => {
351
322
expect ( onChangeEndSpy ) . toHaveBeenCalledTimes ( 0 ) ;
352
323
} ) ;
353
324
354
- // TODO: Should it?
355
- it ( 'dragging the thumb respects the step' , ( ) => {
356
- let defaultColor = parseColor ( '#ff00ff' ) ;
357
- let { getAllByRole} = render (
358
- < Component
359
- xChannelStep = { 16 }
360
- yChannelStep = { 16 }
361
- defaultValue = { defaultColor }
362
- onChange = { onChangeSpy }
363
- onChangeEnd = { onChangeEndSpy } />
364
- ) ;
365
- let sliders = getAllByRole ( 'slider' ) ;
366
- let groups = getAllByRole ( 'group' ) ;
367
- let thumb = sliders [ 0 ] . parentElement ;
368
- let container = groups [ groupIndex ] ;
369
- container . getBoundingClientRect = getBoundingClientRect ;
370
-
371
- start ( thumb , { pageX : CENTER + THUMB_RADIUS , pageY : CENTER } ) ;
372
- expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 0 ) ;
373
-
374
- move ( thumb , { pageX : CENTER , pageY : CENTER + THUMB_RADIUS } ) ;
375
- expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 1 ) ;
376
- expect ( onChangeSpy . mock . calls [ 0 ] [ 0 ] . toString ( 'rgba' ) ) . toBe ( parseColor ( '#ff0090' ) . toString ( 'rgba' ) ) ;
377
-
378
- end ( thumb , { pageX : CENTER , pageY : CENTER + THUMB_RADIUS } ) ;
379
- expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 1 ) ;
380
- } ) ;
381
-
382
325
it ( 'clicking and dragging on the track works' , ( ) => {
383
326
let defaultColor = parseColor ( '#ff00ff' ) ;
384
327
let { getAllByRole} = render (
@@ -438,31 +381,6 @@ describe('ColorArea', () => {
438
381
expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 0 ) ;
439
382
expect ( document . activeElement ) . not . toBe ( sliders [ 0 ] ) ;
440
383
} ) ;
441
-
442
- it ( 'clicking and dragging on the track respects the step' , ( ) => {
443
- let defaultColor = parseColor ( '#ff00ff' ) ;
444
- let { getAllByRole} = render (
445
- < Component
446
- xChannelStep = { 16 }
447
- yChannelStep = { 16 }
448
- defaultValue = { defaultColor }
449
- onChange = { onChangeSpy }
450
- onChangeEnd = { onChangeEndSpy } />
451
- ) ;
452
- let groups = getAllByRole ( 'group' ) ;
453
- let container = groups [ groupIndex ] ;
454
- container . getBoundingClientRect = getBoundingClientRect ;
455
-
456
- start ( container , { pageX : CENTER + THUMB_RADIUS , pageY : CENTER } ) ;
457
- expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 1 ) ;
458
-
459
- move ( container , { pageX : CENTER , pageY : CENTER + THUMB_RADIUS } ) ;
460
- expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 2 ) ;
461
- expect ( onChangeSpy . mock . calls [ 0 ] [ 0 ] . toString ( 'rgba' ) ) . toBe ( parseColor ( '#ff80f0' ) . toString ( 'rgba' ) ) ;
462
-
463
- end ( container , { pageX : CENTER , pageY : CENTER + THUMB_RADIUS } ) ;
464
- expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 2 ) ;
465
- } ) ;
466
384
} ) ;
467
385
} ) ;
468
386
} ) ;
0 commit comments