@@ -276,6 +276,18 @@ describe('<Truncate />', () => {
276276 ` ) ;
277277 } ) ;
278278
279+ it ( 'should render without an error when the last line is exactly as wide as the container' , ( ) => {
280+ const render = ( ) => renderIntoDocument (
281+ < div >
282+ < Truncate lines = { 2 } >
283+ { new Array ( numCharacters ) . fill ( 'a' ) . join ( ) }
284+ </ Truncate >
285+ </ div >
286+ ) ;
287+
288+ expect ( render , 'not to throw' ) ;
289+ } ) ;
290+
279291 describe ( 'onTruncate' , ( ) => {
280292 describe ( 'with Truncate.prototype.onTruncate mocked out' , ( ) => {
281293 before ( ( ) => {
@@ -359,39 +371,6 @@ describe('<Truncate />', () => {
359371 } ) ;
360372 } ) ;
361373
362- it ( 'should render without an error when the last line is exactly as wide as the container' , ( ) => {
363- const text = 'Foo bar - end of text' ;
364-
365- sinon . stub ( global . window . HTMLDivElement . prototype ,
366- 'getBoundingClientRect' , ( ) => ( {
367- width : measureWidth ( text )
368- } )
369- ) ;
370-
371- // Approximate .offsetWidth
372- sinon . stub ( Truncate . prototype ,
373- 'ellipsisWidth' , node => {
374- return measureWidth ( text ) ;
375- }
376- ) ;
377-
378- try {
379- const render = ( ) => renderIntoDocument (
380- < div >
381- < Truncate lines = { 2 } >
382- Foo bar - end of text
383- </ Truncate >
384- </ div >
385- ) ;
386-
387- expect ( render , 'not to throw' ) ;
388- } finally {
389- global . window . HTMLDivElement . prototype . getBoundingClientRect . restore ( ) ;
390-
391- Truncate . prototype . ellipsisWidth . restore ( ) ;
392- }
393- } ) ;
394-
395374 it ( 'should recalculate when resizing the window' , ( ) => {
396375 const calcTargetWidth = sinon . spy ( Truncate . prototype , 'calcTargetWidth' ) ;
397376
0 commit comments