@@ -394,7 +394,6 @@ describe('Selection', function () {
394394
395395 it ( 'trims whitespaces from range when linking' , function ( ) {
396396 this . selection . link ( 'https://livingdocs.io' )
397- console . log ( 'tag' , this . wordWithWhitespace )
398397 const linkTags = this . selection . getTagsByName ( 'a' )
399398 const html = getHtml ( linkTags [ 0 ] )
400399 expect ( html ) . to . equal ( '<a class="foo bar" href="https://livingdocs.io">foobar</a>' )
@@ -417,6 +416,22 @@ describe('Selection', function () {
417416 expect ( selection . range . startOffset ) . to . equal ( 3 )
418417 expect ( selection . range . endOffset ) . to . equal ( 6 )
419418 } )
419+
420+ it ( 'does trim if only a whitespace is selected' , function ( ) {
421+ const whitespaceOnly = createElement ( '<div> </div>' )
422+ const range = rangy . createRange ( )
423+ range . selectNodeContents ( whitespaceOnly . firstChild )
424+ const selection = new Selection ( whitespaceOnly , range )
425+ selection . trimRange ( )
426+ expect ( selection . toString ( ) ) . to . equal ( '' )
427+ } )
428+
429+ it ( 'trims a custom element if the param is given' , function ( ) {
430+ this . selection . toggleCustom ( { tagName : 'span' , attributes : { class : 'foo' } , trim : true } )
431+ const spanTags = this . selection . getTagsByName ( 'span' )
432+ const html = getHtml ( spanTags [ 0 ] )
433+ expect ( html ) . to . equal ( '<span class="foo">foobar</span>' )
434+ } )
420435 } )
421436
422437 describe ( 'inherits form Cursor' , function ( ) {
0 commit comments