Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f943b5b
Update `RangeControl` to play nice with revised `InputControl`
stokesman Apr 23, 2022
e662bde
Update `UnitControl` to play nice with revised `InputControl`
stokesman Apr 23, 2022
0077735
Restore controlled mode to `RangeControl`
stokesman Apr 25, 2022
295035c
Add missing ;
ciampo Apr 25, 2022
739372f
Add comment after deleting `onChange`
ciampo Apr 25, 2022
cd1b4df
Update test of `RangeControl` to also test controlled mode
stokesman Apr 25, 2022
9a3804f
Remove separate onChange call from reset handling in `RangeControl`
stokesman Apr 25, 2022
4dc4674
Refine RESET logic of `InputControl` reducer
stokesman Apr 25, 2022
302096d
Simplify refined RESET logic of `InputControl` reducer
stokesman Apr 26, 2022
f3c881f
Restore initial position of `RangeControl` when without value
stokesman Apr 26, 2022
19fd100
Differentiate state sync effect hooks by event existence
stokesman Apr 26, 2022
68a02ea
Add and use type `SecondaryReducer`
stokesman Apr 26, 2022
d6b43bb
Cleanup legacy `event.perist()`
stokesman Apr 26, 2022
b3e9d88
Simplify update from props in reducer
stokesman Apr 26, 2022
547a7c7
Ensure event is cleared after drag actions
stokesman Apr 26, 2022
89affab
Avoid declaration of potential unused variable
stokesman Apr 26, 2022
06d16fd
Add more reset unit tests for `RangeControl`
stokesman Apr 28, 2022
ce0ac42
Run `RangeControl` unit test in both controlled/uncontrolled modes
stokesman Apr 28, 2022
3800d28
Make “keep invaid values” test async
stokesman May 2, 2022
ff6e10a
Prevent interference of value entry in number input
stokesman May 2, 2022
e427a0e
Remove unused `floatClamp` function
stokesman May 2, 2022
38c0158
Fix reset to `initialPosition`
stokesman May 2, 2022
8930905
Fix a couple tests for controlled `RangeControl`
stokesman May 2, 2022
cb00749
Fix `RangeControl` reset
stokesman May 2, 2022
fa2723d
Ensure `InputControl`’s state syncing works after focus changes
stokesman May 2, 2022
085fd03
Comment
stokesman May 10, 2022
29634d7
Ignore NaN values in `useUnimpededRangedNumberEntry`
stokesman May 10, 2022
2b14b0f
Refine use of event existence in state syncing effect hooks
stokesman May 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more reset unit tests for RangeControl
  • Loading branch information
stokesman committed Apr 28, 2022
commit 06d16fd080f89eda76f396c65e952eddf1834211
27 changes: 22 additions & 5 deletions packages/components/src/range-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,31 @@ describe( 'RangeControl', () => {
} );

describe( 'reset', () => {
it( 'should reset to a custom fallback value, defined by a parent component', () => {
it.concurrent.each( [
[
'initialPosition if it is defined',
{ initialPosition: 21 },
[ '21', undefined ],
],
[
'resetFallbackValue if it is defined',
{ resetFallbackValue: 34 },
[ '34', 34 ],
],
[
'resetFallbackValue if both it and initialPosition are defined',
{ initialPosition: 21, resetFallbackValue: 34 },
[ '34', 34 ],
],
] )( 'should reset to %s', ( ...all ) => {
const [ , propsForReset, [ expectedValue, expectedChange ] ] = all;
const spy = jest.fn();
const { container } = render(
<RangeControl
initialPosition={ 10 }
allowReset={ true }
onChange={ spy }
resetFallbackValue={ 33 }
{ ...propsForReset }
/>
);

Expand All @@ -305,9 +322,9 @@ describe( 'RangeControl', () => {

fireEvent.click( resetButton );

expect( rangeInput.value ).toBe( '33' );
expect( numberInput.value ).toBe( '33' );
expect( spy ).toHaveBeenCalledWith( 33 );
expect( rangeInput.value ).toBe( expectedValue );
expect( numberInput.value ).toBe( expectedValue );
expect( spy ).toHaveBeenCalledWith( expectedChange );
} );

it.concurrent.each( [ RangeControl, ControlledRangeControl ] )(
Expand Down