Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Mar 3, 2022
1 parent b5736e0 commit e664dba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/components/src/number-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ describe( 'NumberControl', () => {
expect( input.value ).toBe( '0' );
} );

it( 'should clamp value within range on blur', () => {
render( <NumberControl value={ 5 } min={ 0 } max={ 10 } /> );

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( <NumberControl value={ 5 } required={ true } /> );

Expand Down

0 comments on commit e664dba

Please sign in to comment.