Skip to content

Commit

Permalink
fix: missing maxLength (#51)
Browse files Browse the repository at this point in the history
* fix: missing maxLength

* test: update snapshot
  • Loading branch information
zombieJ authored Nov 9, 2023
1 parent 8242173 commit e364621
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ const TextArea = React.forwardRef<TextAreaRef, TextAreaProps>(
inputElement={
<ResizableTextArea
{...rest}
maxLength={maxLength}
onKeyDown={handleKeyDown}
onChange={onInternalChange}
onFocus={handleFocus}
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ exports[`TextArea should support disabled 1`] = `
exports[`TextArea should support maxLength 1`] = `
<textarea
class="rc-textarea"
maxlength="10"
/>
`;
26 changes: 17 additions & 9 deletions tests/count.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ describe('TextArea.Count', () => {
const { container } = render(
<TextArea count={{ show: true }} value="πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦" />,
);
expect(
container.querySelector('.rc-textarea-suffix')?.textContent,
).toEqual('11');
expect(container.querySelector('.rc-textarea-suffix')?.textContent).toEqual(
'11',
);
});

it('strategy', () => {
Expand All @@ -21,9 +21,9 @@ describe('TextArea.Count', () => {
value="πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦"
/>,
);
expect(
container.querySelector('.rc-textarea-suffix')?.textContent,
).toEqual('1');
expect(container.querySelector('.rc-textarea-suffix')?.textContent).toEqual(
'1',
);
});

it('exceed style', () => {
Expand All @@ -44,9 +44,9 @@ describe('TextArea.Count', () => {
maxLength={5}
/>,
);
expect(
container.querySelector('.rc-textarea-suffix')?.textContent,
).toEqual('πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦_11_5');
expect(container.querySelector('.rc-textarea-suffix')?.textContent).toEqual(
'πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦_11_5',
);
});

it('exceedFormatter', () => {
Expand Down Expand Up @@ -139,4 +139,12 @@ describe('TextArea.Count', () => {
expect(container.querySelector('.rc-textarea-out-of-range')).toBeTruthy();
});
});

it('native maxLength', () => {
const { container } = render(<TextArea maxLength={33} />);

expect(
container.querySelector('textarea')?.getAttribute('maxlength'),
).toEqual('33');
});
});

0 comments on commit e364621

Please sign in to comment.