window.onload = function() { // textCleanup test( "textCleanup", function() { var source = "Some\nValue\n\n\nTest" var should = "Some\nValue\n\nTest" var result = App.Utils.textCleanup( source ) equal( result, should, source ) source = "Some\nValue\n\n \n\n\nTest" should = "Some\nValue\n\nTest" result = App.Utils.textCleanup( source ) equal( result, should, source ) source = "Some\n\rValue\n\r\n\r\n\rTest" should = "Some\nValue\n\nTest" result = App.Utils.textCleanup( source ) equal( result, should, source ) source = "Some\n\rValue\n\r\n\r\n\rTest\r" should = "Some\nValue\n\nTest" result = App.Utils.textCleanup( source ) equal( result, should, source ) source = "Some\r\nValue\r\n\r\n\r\nTest\r\n" should = "Some\nValue\n\nTest" result = App.Utils.textCleanup( source ) equal( result, should, source ) source = "Some\r\nValue\r\n\r\n\r\n\r\n\r\n\r\nTest\r\n" should = "Some\nValue\n\nTest" result = App.Utils.textCleanup( source ) equal( result, should, source ) source = "> Welcome!\n> \n> Thank you for installing Zammad.\n> \n> You will find ..." should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..." result = App.Utils.textCleanup( source ) equal( result, should, source ) }); // text2html test( "text2html", function() { var source = "Some\nValue\n\n\nTest" var should = "
Some
Value

Test
" var result = App.Utils.text2html( source ) equal( result, should, source ) source = "Some\nValue\n" should = "
Some
Value
" result = App.Utils.text2html( source ) equal( result, should, source ) source = "Some\nValue\n" should = "
Some
<b>Value</b>
" result = App.Utils.text2html( source ) equal( result, should, source ) source = "> Welcome!\n> \n> Thank you for installing Zammad.\n> \n> You will find ..." should = "
> Welcome!
>
> Thank you for installing Zammad.
>
> You will find ...
" result = App.Utils.text2html( source ) equal( result, should, source ) }); // linkify test( "linkify", function() { var source = "http://example.com" var should = 'http://example.com' var result = App.Utils.linkify( source ) equal( result, should, source ) source = "http://example.com?some_param=lalala" should = 'http://example.com?some_param=lalala' result = App.Utils.linkify( source ) equal( result, should, source ) source = "example.com" should = 'example.com' result = App.Utils.linkify( source ) equal( result, should, source ) source = "some text example.com" should = 'some text example.com' result = App.Utils.linkify( source ) equal( result, should, source ) source = "example.com some text" should = 'example.com some text' result = App.Utils.linkify( source ) equal( result, should, source ) /* source = "example.com" should = 'http://example.com' result = App.Utils.linkify( source ) equal( result, should, source ) */ }); // htmlEscape test( "htmlEscape", function() { var source = "<" var should = "<" var result = App.Utils.htmlEscape( source ) equal( result, should, source ) source = ">" should = ">" result = App.Utils.htmlEscape( source ) equal( result, should, source ) source = "&" should = "&" result = App.Utils.htmlEscape( source ) equal( result, should, source ) source = "&" should = "&amp;" result = App.Utils.htmlEscape( source ) equal( result, should, source ) source = "& ;" should = "&amp ;" result = App.Utils.htmlEscape( source ) equal( result, should, source ) source = "& amp;" should = "& amp;" result = App.Utils.htmlEscape( source ) equal( result, should, source ) source = "'test'" should = "'test'" result = App.Utils.htmlEscape( source ) equal( result, should, source ) source = '"test"' should = ""test"" result = App.Utils.htmlEscape( source ) equal( result, should, source ) source = "<>" should = "<>" result = App.Utils.htmlEscape( source ) equal( result, should, source ) source = "<<>" should = "<&lt;>" result = App.Utils.htmlEscape( source ) equal( result, should, source ) }); // htmlRemoveTags test( "htmlRemoveTags", function() { var source = "
test
" var should = "test" var result = App.Utils.htmlRemoveTags( $(source) ) console.log('RRRR', result); equal( result.html(), should, source ) source = "some link to somewhere" should = "some link to somewhere" result = App.Utils.htmlRemoveTags( $(source) ) equal( result.html(), should, source ) source = "
some link to somewhere
" should = "some link to somewhere" result = App.Utils.htmlRemoveTags( $(source) ) equal( result.html(), should, source ) source = "
some link to somewhere

123
" should = "some link to somewhere 123 " result = App.Utils.htmlRemoveTags( $(source) ) equal( result.html(), should, source ) }); // htmlRemoveRichtext test( "htmlRemoveRichtext", function() { var source = "
test
" var should = "test" var result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) source = "some link to somewhere" should = "some link to somewhere" result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) source = "
test
" should = " test " result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) source = "
test
" should = " test " result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) source = "
test
" should = "
test
" result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) source = "
test
123
" should = "
test
123" result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) source = "
test
" should = "
test
" result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) source = "

" should = "
" result = App.Utils.htmlClanup( $(source) ) equal( result.html(), should, source ) source = "

" should = "

" result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) }); // htmlClanup test( "htmlClanup", function() { var source = "
test
" var should = "test" var result = App.Utils.htmlClanup( $(source) ) equal( result.html(), should, source ) source = "some link to somewhere" should = "some link to somewhere" result = App.Utils.htmlClanup( $(source) ) equal( result.html(), should, source ) source = "

some link to somewhere

" should = "
some link to somewhere
" result = App.Utils.htmlClanup( $(source) ) equal( result.html(), should, source ) source = "

some link to somewhere


" should = "
some link to somewhere

" result = App.Utils.htmlClanup( $(source) ) equal( result.html(), should, source ) source = "

" should = "
" result = App.Utils.htmlClanup( $(source) ) equal( result.html(), should, source ) source = "

" should = "

" result = App.Utils.htmlRemoveRichtext( $(source) ) equal( result.html(), should, source ) }); // wrap test( "wrap", function() { var source = "some text" var should = 'some text' var result = App.Utils.wrap( source ) equal( result, should, source ) source = "some text\nsome other text\n" should = "some text\nsome other text\n" result = App.Utils.wrap( source ) equal( result, should, source ) source = "some text with some line to wrap" should = "some text with\nsome line to\nwrap" result = App.Utils.wrap( source, 14 ) equal( result, should, source ) source = "some text\nsome other text\n" should = "some text\nsome other text\n" result = App.Utils.wrap( source ) equal( result, should, source ) source = "1234567890 1234567890 1234567890 1234567890" should = "1234567890 1234567890 1234567890 1234567890" result = App.Utils.wrap( source ) equal( result, should, source ) source = "123456789012 123456789012 123456789012" should = "123456789012\n123456789012\n123456789012" result = App.Utils.wrap( source, 14 ) equal( result, should, source ) }); // quote test( "quote", function() { var source = "some text" var should = '> some text' var result = App.Utils.quote( source ) equal( result, should, source ) source = "some text\nsome other text\n" should = "> some text\n> some other text" result = App.Utils.quote( source ) equal( result, should, source ) source = "\n\nsome text\nsome other text\n \n" should = "> some text\n> some other text" result = App.Utils.quote( source ) equal( result, should, source ) source = "Welcome!\n\nThank you for installing Zammad.\n\nYou will find ..." should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..." result = App.Utils.quote( source ) equal( result, should, source ) source = "Welcome! Thank you for installing Zammad. You will find ..." should = "> Welcome! Thank you\n> for installing\n> Zammad. You will\n> find ..." result = App.Utils.quote( source, 20 ) equal( result, should, source ) }); }