From e664dba1eb5ad564b98eb833fffeb3eecdc5468e Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Thu, 3 Mar 2022 14:15:51 +0100 Subject: [PATCH] Add unit test --- .../components/src/number-control/test/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/components/src/number-control/test/index.js b/packages/components/src/number-control/test/index.js index db51a66681c67..90123669c03ac 100644 --- a/packages/components/src/number-control/test/index.js +++ b/packages/components/src/number-control/test/index.js @@ -82,6 +82,22 @@ describe( 'NumberControl', () => { expect( input.value ).toBe( '0' ); } ); + it( 'should clamp value within range on blur', () => { + render( ); + + const input = getInput(); + input.focus(); + fireEvent.change( input, { target: { value: 41 } } ); + + // Before blurring, the value is still un-clamped + expect( input.value ).toBe( '41' ); + + input.blur(); + + // After blur, value is clamped + expect( input.value ).toBe( '10' ); + } ); + it( 'should parse to number value on ENTER keypress when required', () => { render( );