import { create } from 'react-test-renderer'; import TextCompact from './TextCompact'; test('TextCompact renders', () => { const tree = create().toJSON(); expect(tree).toMatchSnapshot(); }); test('TextCompact warning adds the warning color class', () => { const tree = create().toJSON(); expect(tree).toMatchSnapshot(); }); test('TextCompact error adds the error color class', () => { const tree = create().toJSON(); expect(tree).toMatchSnapshot(); }); test('TextCompact emphasis style renders', () => { const tree = create().toJSON(); expect(tree).toMatchSnapshot(); }); test('TextCompact lineClamp should add a title when the children are text only', () => { const tree = create( Shall I compare thee to a summer's day - William Shakespeare , ).toJSON(); expect(tree).toMatchSnapshot(); }); test('TextCompact lineClamp should not add a title when the children are objects', () => { const tree = create(
Summer reading:
Shall I compare thee to a summer's day - William Shakespeare
, ).toJSON(); expect(tree).toMatchSnapshot(); }); test('validate data test id for text', () => { const component = create(Testing).root; expect( component .findAll((element) => element.type === 'div') .filter((node) => node.props['data-test-id'] === 'test-text'), ).toHaveLength(1); });