From ceee605c551e7959b29b16896faef18b2ae3e538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Thu, 28 Sep 2023 14:52:38 +0800 Subject: [PATCH] test: add test case --- tests/count.test.tsx | 26 ++++++++++++++++++++++++++ tsconfig.json | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/count.test.tsx b/tests/count.test.tsx index bc20473..a6c22e4 100644 --- a/tests/count.test.tsx +++ b/tests/count.test.tsx @@ -83,6 +83,32 @@ describe('Input.Count', () => { expect(onCompositionEnd).toHaveBeenCalled(); }); + it('exceedFormatter selection', () => { + const { container } = render( + val.slice(0, max), + }} + defaultValue={'123'} + />, + ); + + const input = container.querySelector('input')!; + const setSelectionRange = jest.spyOn(input, 'setSelectionRange'); + + fireEvent.change(input, { + target: { + selectionStart: 2, + selectionEnd: 2, + value: '1a23', + }, + }); + + expect(setSelectionRange).toHaveBeenCalledWith(2, 2); + }); + describe('cls', () => { it('raw', () => { const { container } = render( diff --git a/tsconfig.json b/tsconfig.json index 540895d..26311e3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "module": "ESNext", "moduleResolution": "node", "baseUrl": "./", - "lib": ["dom", "es2017", "es2022"], + "lib": ["dom", "es2017", "es2022", "ES2023", "ESNext"], "jsx": "react", "strict": true, "esModuleInterop": true,