From 06d16fd080f89eda76f396c65e952eddf1834211 Mon Sep 17 00:00:00 2001 From: Mitchell Austin Date: Thu, 28 Apr 2022 10:13:10 -0700 Subject: [PATCH] Add more reset unit tests for `RangeControl` --- .../src/range-control/test/index.js | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/components/src/range-control/test/index.js b/packages/components/src/range-control/test/index.js index 6124d9bc34b7f..803b0dd9c92ff 100644 --- a/packages/components/src/range-control/test/index.js +++ b/packages/components/src/range-control/test/index.js @@ -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( ); @@ -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 ] )(