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 = "
> 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 = 'some link to somewhere
"
should = "
some link to somewhere
"
result = App.Utils.htmlClanup( $(source) )
equal( result.html(), should, source )
source = "
"
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 )
});
// check signature
test( "check signature", function() {
var message = "
test 123
"
var signature = '
--
Some Signature
some department
'
var result = App.Utils.signatureCheck( message, signature )
equal( result, true )
message = "
test 123
--
Some Signature
some department\n
"
signature = '
--
Some Signature
some department
'
result = App.Utils.signatureCheck( message, signature )
equal( result, false )
message = "
test 123
--
Some Signature\n
some department\n
"
signature = '
--
Some Signature
some department
'
result = App.Utils.signatureCheck( message, signature )
equal( result, false )
message = "
test 123
--
Some Signature
\n
some department
\n\n
"
signature = '
--
Some Signature
some department
'
result = App.Utils.signatureCheck( message, signature )
equal( result, false )
message = ""
signature = '
--
Some Signature
some department
'
result = App.Utils.signatureCheck( message, signature )
equal( result, true )
message = ""
signature = "--\nSome Signature\nsome department"
result = App.Utils.signatureCheck( message, signature )
equal( result, true )
});
}