UNPKG

@wordpress/components

Version:
44 lines (38 loc) 1.11 kB
/** * External dependencies */ import { render } from '@testing-library/react'; /** * Internal dependencies */ import { Truncate } from '..'; describe( 'props', () => { test( 'should render correctly', () => { const { container } = render( <Truncate>Lorem ipsum.</Truncate> ); expect( container.firstChild.textContent ).toEqual( 'Lorem ipsum.' ); } ); test( 'should render limit', () => { const { container } = render( <Truncate limit={ 1 } ellipsizeMode="tail"> Lorem ipsum. </Truncate> ); expect( container.firstChild.textContent ).toEqual( 'L…' ); } ); test( 'should render custom ellipsis', () => { const { container } = render( <Truncate ellipsis="!!!" limit={ 5 } ellipsizeMode="tail"> Lorem ipsum. </Truncate> ); expect( container.firstChild.textContent ).toEqual( 'Lorem!!!' ); } ); test( 'should render custom ellipsizeMode', () => { const { container } = render( <Truncate ellipsis="!!!" ellipsizeMode="middle" limit={ 5 }> Lorem ipsum. </Truncate> ); expect( container.firstChild.textContent ).toEqual( 'Lo!!!m.' ); } ); } );