diff --git a/test/library/input.spec.jsx b/test/library/input.spec.jsx index 99f1475..a866c79 100644 --- a/test/library/input.spec.jsx +++ b/test/library/input.spec.jsx @@ -25,17 +25,17 @@ describe('NumberFormat as input', () => { }); it('should render input as type text by default', async () => { - const { input, user } = await render(); + const { input } = await render(); expect(input.getAttribute('type')).toBe('text'); }); it('should render input as defined type', async () => { - const { input, user } = await render(); + const { input } = await render(); expect(input.getAttribute('type')).toBe('tel'); }); it('should add inputMode numeric to non Iphone/IPad device by default to input element', async () => { - const { input, user, rerender } = await render(); + const { input, rerender } = await render(); expect(input.getAttribute('inputmode')).toBe('numeric'); //should allow updating the inputMode value @@ -60,14 +60,14 @@ describe('NumberFormat as input', () => { }); it('should have initial value', async () => { - const { input, user } = await render( + const { input } = await render( , ); expect(input).toHaveValue('$2,456,981'); }); it('should load the default value when initial value is null', async () => { - const { input, user } = await render(); + const { input } = await render(); expect(input).toHaveValue('89'); }); @@ -82,7 +82,7 @@ describe('NumberFormat as input', () => { }); it('should use defaultValue as initial value', async () => { - const { input, user } = await render( + const { input } = await render( , ); expect(input).toHaveValue('$2,456,981'); @@ -331,7 +331,7 @@ describe('NumberFormat as input', () => { it('should format value when input value is empty and allowEmptyFormatting is true', async () => { expect(async () => { - const { input, user } = await render(); + const { input } = await render(); expect(input).toHaveValue(' / / '); }); @@ -339,14 +339,14 @@ describe('NumberFormat as input', () => { it('should format value when input value is not set and allowEmptyFormatting is true', async () => { expect(async () => { - const { input, user } = await render(); + const { input } = await render(); expect(input).toHaveValue(' / / '); }); }); it('should not convert empty string to 0 if valueIsNumericString is true', async () => { - const { input, user } = await render( + const { input } = await render( , ); @@ -354,7 +354,7 @@ describe('NumberFormat as input', () => { }); it('should not break if null or NaN is provided as value', async () => { - const { input, user, rerender } = await render(); + const { input, rerender } = await render(); expect(input).toHaveValue(''); rerender(); @@ -442,9 +442,7 @@ describe('NumberFormat as input', () => { it('should not call onValueChange if no formatting is applied', async () => { const mockOnValueChange = vi.fn(); - const { input, user, rerender } = await render( - , - ); + const { rerender } = await render(); expect(mockOnValueChange).not.toHaveBeenCalled(); @@ -552,7 +550,7 @@ describe('NumberFormat as input', () => { }); it('should treat Infinity value as empty string', async () => { - const { input, user } = await render(); + const { input } = await render(); expect(input).toHaveValue(''); }); @@ -760,7 +758,7 @@ describe('NumberFormat as input', () => { }); it('should correctly show the decimal values', async () => { - const { input, user, rerender } = await render( + const { input, rerender } = await render( { it('should show the initial value as $0 when number 0 is passed', async () => { - const { input, user } = await render( + const { input } = await render( , ); expect(input).toHaveValue('$0'); }); it('should show the initial value as empty string when empty string is passed and decimalScale is set', async () => { - const { input, user } = await render( + const { input } = await render( , ); expect(input).toHaveValue(''); }); it('should show the initial value as empty string when empty string is passed and decimalScale is not set', async () => { - const { input, user } = await render(); + const { input } = await render(); expect(input).toHaveValue(''); }); @@ -146,7 +146,7 @@ describe('Test NumberFormat as input with numeric format options', () => { }); it('should update formatted value if any of the props changes', async () => { - const { input, user, rerender } = await render(); + const { input, rerender } = await render(); expect(input).toHaveValue('12345.67'); rerender(); @@ -220,9 +220,7 @@ describe('Test NumberFormat as input with numeric format options', () => { }); it('should not add zeros to fixedDecimalScale is not set', async () => { - const { input, user, rerender } = await render( - , - ); + const { input, rerender } = await render(); expect(input).toHaveValue('24.45'); rerender(); @@ -230,14 +228,14 @@ describe('Test NumberFormat as input with numeric format options', () => { }); it('should handle fixedDecimalScale correctly #670', async () => { - const { input, user } = await render( + const { input } = await render( , ); expect(input).toHaveValue('12.00'); }); it('should not round the initial if decimalScale is not provided', async () => { - const { input, user, rerender } = await render(); + const { input, rerender } = await render(); expect(input).toHaveValue('123213.7535'); rerender(); @@ -255,7 +253,7 @@ describe('Test NumberFormat as input with numeric format options', () => { }); it('should round the initial value to given decimalScale', async () => { - const { input, user, rerender } = await render( + const { input, rerender } = await render( , ); expect(input).toHaveValue('123213.8'); @@ -438,7 +436,7 @@ describe('Test NumberFormat as input with numeric format options', () => { }); it('should allow decimal separator and thousand separator on suffix prefix', async () => { - const { input, user, rerender } = await render( + const { input, rerender } = await render( { //Issue #140 it('should not give NaN zeros, when decimalScale is 0 and roundedValue will be multiple of 10s, Issue #140', async () => { - const { input, user, rerender } = await render(); + const { input, rerender } = await render(); expect(input).toHaveValue('-10'); rerender(); @@ -677,7 +675,7 @@ describe('Test NumberFormat as input with numeric format options', () => { it(`should give correct formatted value when decimal value is passed as prop and decimal scale is set to zero and fixedDecimalScale is true, issue #183`, async () => { - const { input, user } = await render( + const { input } = await render( , ); expect(input).toHaveValue('1'); @@ -760,7 +758,7 @@ describe('Test NumberFormat as input with numeric format options', () => { }); it('should handle exponential value as prop correctly #506', async () => { - const { input, user } = await render(); + const { input } = await render(); expect(input).toHaveValue('0.00000001'); }); diff --git a/test/library/keypress_and_caret.spec.jsx b/test/library/keypress_and_caret.spec.jsx index 84243dc..48bebfb 100644 --- a/test/library/keypress_and_caret.spec.jsx +++ b/test/library/keypress_and_caret.spec.jsx @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, vi } from 'vitest'; +import { vi } from 'vitest'; import React, { useState } from 'react'; import NumericFormat from '../../src/numeric_format'; import PatternFormat from '../../src/pattern_format'; @@ -10,10 +10,8 @@ import { simulateBlurEvent, simulateKeyInput, simulateMouseUpEvent, - simulateClickToFocus, render, simulatePaste, - clearInput, simulateTripleClick, simulateFocus, } from '../test_util'; @@ -56,7 +54,7 @@ describe('Test keypress and caret position changes', () => { }); it('should maintain caret position when isAllowed returns false', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( { return floatValue < 100; @@ -73,7 +71,7 @@ describe('Test keypress and caret position changes', () => { }); it('should update caret position when any of the decimal separator is pressed just before the decimal separator #711', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( { }); it('should bring caret to correct position if user types same number used in format pattern', async () => { - const { input, rerender, user } = await render( - , - ); + const { input, user } = await render(); await simulateKeyInput(user, input, '1', 0, 0); expect(input.selectionStart).toEqual(5); @@ -346,7 +342,7 @@ describe('Test keypress and caret position changes', () => { }); it('caret position should not change if its on end of input area', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( , ); await simulateKeyInput(user, input, '{Delete}', 17, 17); @@ -355,7 +351,7 @@ describe('Test keypress and caret position changes', () => { }); it('should remove the numeric part irrespective of the cursor position', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( , ); await simulateKeyInput(user, input, '{Backspace}', 10, 10); @@ -378,7 +374,7 @@ describe('Test keypress and caret position changes', () => { describe('Test delete/backspace with numeric format', () => { it('should not remove prefix', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( { }); it('should not remove suffix', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( { }); it('should remove number, irrespective of the cursor position', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( { }); it('should maintain correct caret positon while removing the last character and suffix is not defined. Issue #105', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( , ); @@ -448,7 +444,7 @@ describe('Test keypress and caret position changes', () => { }); it('should maintain correct caret position while removing the second last character and suffix is not defined, Issue #116', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( , ); @@ -460,7 +456,7 @@ describe('Test keypress and caret position changes', () => { it('should allow removing negation(-), even if its before prefix', async () => { const spy = vi.fn(); - const { input, rerender, user } = await render( + const { input, user } = await render( { }); it('should maintain correct caret position if one of thousand separator is removed due to backspace. #695', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( , ); @@ -490,7 +486,7 @@ describe('Test keypress and caret position changes', () => { describe('Test arrow keys', () => { it('should keep caret position between the prefix and suffix', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( { }); it('should always keep caret position between suffix and prefix', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( { }); it('should correct wrong caret position on focus', async () => { - const { input, rerender, user } = await render( + const { input, user } = await render( { const onFocus = vi.fn(); - const { input, user, unmount } = await render(); + const { input, unmount } = await render(); // Fails if input receives focus by clicking. // await simulateClickToFocus(user, input);