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 = "
"
var should = "Some\nValue\n\n\nTest"
var result = App.Utils.html2text( source )
equal( result, should, source )
source = "
Some
Value
"
should = "Some\nValue"
result = App.Utils.html2text( source )
equal( result, should, source )
source = "
Some Value
"
should = "Some\nValue"
result = App.Utils.html2text( source )
equal( result, should, source )
source = "
Some
<b>Value</b>
"
should = "Some\nValue"
result = App.Utils.html2text( source )
equal( result, should, source )
source = "
> Welcome!
>
> Thank you for installing Zammad.
>
> You will find ...
"
should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..."
result = App.Utils.html2text( source )
equal( result, should, source )
source = "
"
should = "1\n\n\n\n\n\n\n\n\n\n\n\Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nGesendet: Donnerstag, 2. April 2015 11:32"
result = App.Utils.html2text( 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 = "&"
result = App.Utils.htmlEscape( source )
equal( result, should, source )
source = "& ;"
should = "& ;"
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 = "<<>"
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) )
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 = "
"
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 = "
"
var should = "test"
var result = App.Utils.htmlCleanup( $(source) )
equal( result.html(), should, source )
source = "some link to somewhere"
should = "some link to somewhere"
result = App.Utils.htmlCleanup( $(source) )
equal( result.html(), should, source )
source = "
"
should = "test 123"
result = App.Utils.htmlRemoveRichtext( $(source) )
equal( result.html(), should, source )
source = "
some other value
"
//should = "
ttest 123 some other value
"
should = "test 123 some other value"
result = App.Utils.htmlRemoveRichtext( $(source) )
equal( result.html(), should, source )
source = "
some other value
"
//should = "
test 123 some other value
"
should = "test 123 some other value"
result = App.Utils.htmlRemoveRichtext( $(source) )
equal( result.html(), should, source )
source = "
This is some text!
"
//should = "
This is some text!
"
should = "This is some text!"
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 = "
'
data = {
user: {
firstname: 'Bob',
},
}
verify = App.Utils.replaceTags( message, data )
equal( verify, result )
});
// check if last line is a empty line
test( "check if last line is a empty line", function() {
var message = "123"
var result = false
var verify = App.Utils.lastLineEmpty( message )
equal( verify, result, message )
message = "