Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Sep 28, 2023
1 parent c2f4a60 commit ceee605
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions tests/count.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,32 @@ describe('Input.Count', () => {
expect(onCompositionEnd).toHaveBeenCalled();
});

it('exceedFormatter selection', () => {
const { container } = render(
<Input
count={{
show: true,
max: 3,
exceedFormatter: (val, { max }) => 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(
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ceee605

Please sign in to comment.