diff --git a/src/components/common/AddressInput/index.test.tsx b/src/components/common/AddressInput/index.test.tsx index 0dc6d25f49..88bb005b95 100644 --- a/src/components/common/AddressInput/index.test.tsx +++ b/src/components/common/AddressInput/index.test.tsx @@ -124,6 +124,31 @@ describe('AddressInput tests', () => { await waitFor(() => expect(utils.getByLabelText(`${TEST_ADDRESS_B} is wrong`, { exact: false })).toBeDefined()) }) + it('should show a spinner when validation is in progress', async () => { + const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)) + + const { input, utils } = setup('', async (val) => { + await sleep(2000) + return `${val} is wrong` + }) + + act(() => { + fireEvent.change(input, { target: { value: `gor:${TEST_ADDRESS_A}` } }) + jest.advanceTimersByTime(1000) + }) + + await waitFor(() => { + expect(utils.getByRole('progressbar')).toBeDefined() + expect(utils.queryByLabelText(`${TEST_ADDRESS_A} is wrong`, { exact: false })).toBeNull() + }) + + act(() => { + jest.advanceTimersByTime(1000) + }) + + await waitFor(() => expect(utils.getByLabelText(`${TEST_ADDRESS_A} is wrong`, { exact: false })).toBeDefined()) + }) + it('should resolve ENS names', async () => { const { input } = setup('') diff --git a/src/components/common/AddressInput/index.tsx b/src/components/common/AddressInput/index.tsx index 211cfb43df..aa63b220d0 100644 --- a/src/components/common/AddressInput/index.tsx +++ b/src/components/common/AddressInput/index.tsx @@ -18,7 +18,7 @@ const AddressInput = ({ name, validate, required = true, deps, ...props }: Addre register, setValue, control, - formState: { errors }, + formState: { errors, isValidating }, trigger, } = useFormContext() const currentChain = useCurrentChain() @@ -72,7 +72,7 @@ const AddressInput = ({ name, validate, required = true, deps, ...props }: Addre {currentShortName}: ), - endAdornment: resolving && ( + endAdornment: (resolving || isValidating) && (