fix: textarea handle undefined
This commit is contained in:
@@ -4,6 +4,7 @@ import { render } from '@testing-library/react';
|
||||
import BlocksCell from './field-types/Blocks';
|
||||
import DateCell from './field-types/Date';
|
||||
import Checkbox from './field-types/Checkbox';
|
||||
import Textarea from './field-types/Textarea';
|
||||
|
||||
describe('Cell Types', () => {
|
||||
describe('Blocks', () => {
|
||||
@@ -87,4 +88,17 @@ describe('Cell Types', () => {
|
||||
expect(el).toHaveTextContent('false');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Textarea', () => {
|
||||
it('renders data', () => {
|
||||
const { container } = render(<Textarea data="data" />);
|
||||
const el = container.querySelector('span');
|
||||
expect(el).toHaveTextContent('data');
|
||||
});
|
||||
it('handle undefined - bug/13', () => {
|
||||
const { container } = render(<Textarea data={undefined} />);
|
||||
const el = container.querySelector('span');
|
||||
expect(el).toHaveTextContent('');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
const TextareaCell = ({ data }) => {
|
||||
const textToShow = data.length > 100 ? `${data.substr(0, 100)}\u2026` : data;
|
||||
const textToShow = data?.length > 100 ? `${data.substr(0, 100)}\u2026` : data;
|
||||
return (
|
||||
<span>{textToShow}</span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user