2014-12-29 12:59:16 +00:00
window . onload = function ( ) {
// textCleanup
2015-10-09 20:31:26 +00:00
test ( "textCleanup" , function ( ) {
2014-12-29 12:59:16 +00:00
var source = "Some\nValue\n\n\nTest"
var should = "Some\nValue\n\nTest"
2015-10-09 20:31:26 +00:00
var result = App . Utils . textCleanup ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "Some\nValue\n\n \n\n\nTest"
should = "Some\nValue\n\nTest"
2015-10-09 20:31:26 +00:00
result = App . Utils . textCleanup ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "Some\n\rValue\n\r\n\r\n\rTest"
should = "Some\nValue\n\nTest"
2015-10-09 20:31:26 +00:00
result = App . Utils . textCleanup ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "Some\n\rValue\n\r\n\r\n\rTest\r"
should = "Some\nValue\n\nTest"
2015-10-09 20:31:26 +00:00
result = App . Utils . textCleanup ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "Some\r\nValue\r\n\r\n\r\nTest\r\n"
should = "Some\nValue\n\nTest"
2015-10-09 20:31:26 +00:00
result = App . Utils . textCleanup ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "Some\r\nValue\r\n\r\n\r\n\r\n\r\n\r\nTest\r\n"
should = "Some\nValue\n\nTest"
2015-10-09 20:31:26 +00:00
result = App . Utils . textCleanup ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
2014-12-29 23:25:57 +00:00
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 ..."
2015-10-09 20:31:26 +00:00
result = App . Utils . textCleanup ( source )
equal ( result , should , source )
2014-12-29 23:25:57 +00:00
2014-12-29 12:59:16 +00:00
} ) ;
2015-01-06 22:42:49 +00:00
// text2html
2015-10-09 20:31:26 +00:00
test ( "text2html" , function ( ) {
2015-01-06 22:42:49 +00:00
var source = "Some\nValue\n\n\nTest"
var should = "<div>Some</div><div>Value</div><div><br></div><div>Test</div>"
2015-10-09 20:31:26 +00:00
var result = App . Utils . text2html ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
source = "Some\nValue\n"
should = "<div>Some</div><div>Value</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . text2html ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
source = "Some\n<b>Value</b>\n"
should = "<div>Some</div><div><b>Value</b></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . text2html ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
source = "> Welcome!\n> \n> Thank you for installing Zammad.\n> \n> You will find ..."
should = "<div>> Welcome!</div><div>></div><div>> Thank you for installing Zammad.</div><div>></div><div>> You will find ...</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . text2html ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
} ) ;
2015-04-02 22:29:32 +00:00
// html2text
2015-10-09 20:31:26 +00:00
test ( "html2text" , function ( ) {
2015-04-02 22:29:32 +00:00
var source = "<div>Some</div><div>Value</div><div><br></div><div>Test</div>"
2015-04-03 01:11:21 +00:00
var should = "Some\nValue\n\nTest"
2015-10-09 20:31:26 +00:00
var result = App . Utils . html2text ( source )
equal ( result , should , source )
2015-04-02 22:29:32 +00:00
source = "<div>Some</div><div>Value</div>"
should = "Some\nValue"
2015-10-09 20:31:26 +00:00
result = App . Utils . html2text ( source )
equal ( result , should , source )
2015-04-02 22:29:32 +00:00
source = "<div>Some<br/>Value</div>"
should = "Some\nValue"
2015-10-09 20:31:26 +00:00
result = App . Utils . html2text ( source )
equal ( result , should , source )
2015-04-02 22:29:32 +00:00
source = "<div>Some</div><div><b>Value</b></div>"
should = "Some\n<b>Value</b>"
2015-10-09 20:31:26 +00:00
result = App . Utils . html2text ( source )
equal ( result , should , source )
2015-04-02 22:29:32 +00:00
source = "<div>> Welcome!</div><div>></div><div>> Thank you for installing Zammad.</div><div>></div><div>> You will find ...</div>"
should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..."
2015-10-09 20:31:26 +00:00
result = App . Utils . html2text ( source )
equal ( result , should , source )
2015-04-02 22:29:32 +00:00
source = "<div>test 123 <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>--<br/>Bob Smith</div>"
2015-04-03 01:11:21 +00:00
should = "test 123 \n\n--\nBob Smith"
2015-10-09 20:31:26 +00:00
result = App . Utils . html2text ( source )
equal ( result , should , source )
2015-04-02 22:29:32 +00:00
2015-04-03 00:01:21 +00:00
source = "test 123 <br><br><br><br><br><br><br><br><br><br><br>--<br>Bob Smith"
2015-04-03 01:11:21 +00:00
should = "test 123 \n\n--\nBob Smith"
2015-10-09 20:31:26 +00:00
result = App . Utils . html2text ( source )
equal ( result , should , source )
2015-04-03 00:01:21 +00:00
source = "<div>1<br><br><br><br><br><br><br><br><br><br></div><div>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>"
2015-04-03 01:11:21 +00:00
should = "1\n\nVon: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nGesendet: Donnerstag, 2. April 2015 11:32"
2015-10-09 20:31:26 +00:00
result = App . Utils . html2text ( source )
equal ( result , should , source )
2015-04-03 00:01:21 +00:00
2015-04-03 01:11:21 +00:00
source = "<div>test 123<br/>lalala<p>--</p>some test</div>"
should = "test 123\nlalala\n--\nsome test"
2015-10-09 20:31:26 +00:00
result = App . Utils . html2text ( source )
equal ( result , should , source )
2015-04-02 22:29:32 +00:00
} ) ;
2015-01-06 22:42:49 +00:00
// linkify
2015-10-09 20:31:26 +00:00
test ( "linkify" , function ( ) {
2015-01-06 22:42:49 +00:00
var source = "http://example.com"
var should = '<a href="http://example.com" title="http://example.com" target="_blank">http://example.com</a>'
2015-10-09 20:31:26 +00:00
var result = App . Utils . linkify ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
source = "http://example.com?some_param=lalala"
should = '<a href="http://example.com?some_param=lalala" title="http://example.com?some_param=lalala" target="_blank">http://example.com?some_param=lalala</a>'
2015-10-09 20:31:26 +00:00
result = App . Utils . linkify ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
source = "example.com"
should = '<a href="http://example.com" title="http://example.com" target="_blank">example.com</a>'
2015-10-09 20:31:26 +00:00
result = App . Utils . linkify ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
source = "some text example.com"
should = 'some text <a href="http://example.com" title="http://example.com" target="_blank">example.com</a>'
2015-10-09 20:31:26 +00:00
result = App . Utils . linkify ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
source = "example.com some text"
should = '<a href="http://example.com" title="http://example.com" target="_blank">example.com</a> some text'
2015-10-09 20:31:26 +00:00
result = App . Utils . linkify ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
/ *
source = "<b>example.com</b>"
should = '<b><a href="http://example.com" title="http://example.com" target="_blank">http://example.com</a></b>'
2015-10-09 20:31:26 +00:00
result = App . Utils . linkify ( source )
equal ( result , should , source )
2015-01-06 22:42:49 +00:00
* /
} ) ;
2014-12-29 12:59:16 +00:00
// htmlEscape
2015-10-09 20:31:26 +00:00
test ( "htmlEscape" , function ( ) {
2014-12-29 12:59:16 +00:00
var source = "<"
var should = "<"
2015-10-09 20:31:26 +00:00
var result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = ">"
should = ">"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "&"
should = "&"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "&"
should = "&amp;"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "& ;"
should = "&amp ;"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "& amp;"
should = "& amp;"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "'test'"
should = "'test'"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = '"test"'
should = ""test""
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "<>"
should = "<>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
source = "<<>"
should = "<&lt;>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlEscape ( source )
equal ( result , should , source )
2014-12-29 12:59:16 +00:00
} ) ;
2015-01-06 22:42:49 +00:00
// htmlRemoveTags
2015-10-09 20:31:26 +00:00
test ( "htmlRemoveTags" , function ( ) {
2014-12-29 12:59:16 +00:00
2015-01-06 22:42:49 +00:00
var source = "<div>test</div>"
2015-09-01 00:16:50 +00:00
//var should = "<div>test</div>"
var should = "test"
2015-10-09 20:31:26 +00:00
var result = App . Utils . htmlRemoveTags ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-08-05 09:40:50 +00:00
source = "<div>test<!-- some comment --></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>test</div>"
should = "test"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveTags ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-08-05 09:40:50 +00:00
2015-01-06 22:42:49 +00:00
source = "<a href=\"some_link\">some link to somewhere</a>"
2015-09-01 00:16:50 +00:00
should = "some link to somewhere"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveTags ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-01-06 22:42:49 +00:00
source = "<div><a href=\"some_link\">some link to somewhere</a></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>some link to somewhere</div>"
should = "some link to somewhere"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveTags ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 23:25:57 +00:00
2015-01-07 14:30:13 +00:00
source = "<div><a href=\"some_link\">some link to somewhere</a><input value=\"should not be shown\"></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>some link to somewhere</div>"
should = "some link to somewhere"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveTags ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
2015-01-06 22:42:49 +00:00
source = "<div><a href=\"some_link\">some link to somewhere</a> <div><hr></div> <span>123</span> <img src=\"some_image\"/></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>some link to somewhere 123 </div>"
should = "some link to somewhere 123 "
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveTags ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-01-07 14:30:13 +00:00
source = "<div><form class=\"xxx\">test 123</form></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>test 123</div>"
should = "test 123"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
source = "<div><textarea class=\"xxx\">test 123</textarea></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>test 123</div>"
should = "test 123"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
2015-01-08 23:25:25 +00:00
source = "<div><font size=\"3\" color=\"red\">This is some text!</font></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>This is some text!</div>"
should = "This is some text!"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
} ) ;
2015-01-06 22:42:49 +00:00
// htmlRemoveRichtext
2015-10-09 20:31:26 +00:00
test ( "htmlRemoveRichtext" , function ( ) {
2014-12-29 12:59:16 +00:00
2015-07-30 10:15:13 +00:00
var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
2015-09-01 00:16:50 +00:00
//var should = "<div>test</div>"
var should = "test"
2015-10-09 20:31:26 +00:00
var result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-08-05 09:40:50 +00:00
source = "<div><!--[if !supportLists]--><span lang=\"DE\">1.1.1<span> </span></span><!--[endif]--><span lang=\"DE\">Description</span></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><span>1.1.1<span> </span></span><span>Description</span></div>"
should = "<span>1.1.1<span> </span></span><span>Description</span>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-08-05 09:40:50 +00:00
2015-01-06 22:42:49 +00:00
source = "<a href=\"some_link\">some link to somewhere</a>"
2015-09-01 00:16:50 +00:00
should = "some link to somewhere"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-01-06 22:42:49 +00:00
source = "<div><a href=\"some_link\"></a> test </div>"
2015-09-01 00:16:50 +00:00
//should = "<div> test </div>"
should = " test "
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-01-06 22:42:49 +00:00
source = "<div><b></b> test </div>"
2015-09-01 00:16:50 +00:00
//should = "<div> test </div>"
should = " test "
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-01-06 22:42:49 +00:00
source = "<div><div><b></b> test </div></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><div> test </div></div>"
should = "<div> test </div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-01-07 14:30:13 +00:00
source = "<div><div><b></b> test <input value=\"should not be shown\"></div></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><div> test </div></div>"
should = "<div> test </div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
2015-01-06 22:42:49 +00:00
source = "<div><div><b></b> test </div><span>123</span></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><div> test </div><span>123</span></div>"
should = "<div> test </div><span>123</span>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-08-05 09:40:50 +00:00
source = "<div><div class=\"xxx\" title=\"some title\" lang=\"en\"><b></b> test </div></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><div> test </div></div>"
should = "<div> test </div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-06 22:42:49 +00:00
2015-01-07 14:30:13 +00:00
source = "<div><textarea class=\"xxx\"> test </textarea></div>"
2015-09-01 00:16:50 +00:00
//should = "<div> test </div>"
should = " test "
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
2015-01-07 00:03:18 +00:00
source = "<div><br></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><br></div>"
should = "<br>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 00:03:18 +00:00
source = "<div><div class=\"xxx\"><br></div></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><div><br></div></div>"
should = "<div><br></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 00:03:18 +00:00
2015-01-07 14:30:13 +00:00
source = "<div><form class=\"xxx\">test 123</form></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>test 123</div>"
should = "test 123"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
2015-01-08 23:25:25 +00:00
source = "<div><font size=\"3\" color=\"red\">This is some text!</font></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>This is some text!</div>"
should = "This is some text!"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-08 23:25:25 +00:00
2015-01-06 22:42:49 +00:00
} ) ;
2015-01-27 07:13:25 +00:00
// htmlCleanup
2015-10-09 20:31:26 +00:00
test ( "htmlCleanup" , function ( ) {
2015-01-06 22:42:49 +00:00
2015-07-30 10:15:13 +00:00
var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
2015-09-01 00:16:50 +00:00
//var should = "<div>test</div>"
var should = "test"
2015-10-09 20:31:26 +00:00
var result = App . Utils . htmlCleanup ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-06 22:42:49 +00:00
source = "<a href=\"some_link\">some link to somewhere</a>"
2015-09-01 00:16:50 +00:00
should = "some link to somewhere"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlCleanup ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-06 22:42:49 +00:00
2015-08-05 09:40:50 +00:00
source = "<div><h1>some link to somewhere</h1></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><div>some link to somewhere</div></div>"
should = "<div>some link to somewhere</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlCleanup ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-20 00:33:26 +00:00
source = "<div><small>some link to somewhere</small></a>"
2015-09-01 00:16:50 +00:00
//should = "<div>some link to somewhere</div>"
should = "some link to somewhere"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlCleanup ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-20 00:33:26 +00:00
source = "<div><time>some link to somewhere</time></a>"
2015-09-01 00:16:50 +00:00
//should = "<div>some link to somewhere</div>"
should = "some link to somewhere"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlCleanup ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-06 22:42:49 +00:00
2015-08-05 09:40:50 +00:00
source = "<div><h1>some h1 for somewhere</h1><p><hr></p></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><div>some h1 for somewhere</div><p></p><p></p></div>"
should = "<div>some h1 for somewhere</div><p></p><p></p>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlCleanup ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-06 22:52:01 +00:00
source = "<div><br></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><br></div>"
should = "<br>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlCleanup ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 00:03:18 +00:00
source = "<div><div class=\"xxx\"><br></div></div>"
2015-09-01 00:16:50 +00:00
//should = "<div><div><br></div></div>"
should = "<div><br></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2014-12-29 12:59:16 +00:00
2015-01-07 14:30:13 +00:00
source = "<div><form class=\"xxx\">test 123</form></div>"
//should = "<div>test 123<br></div>"
2015-09-01 00:16:50 +00:00
should = "test 123"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
source = "<div><form class=\"xxx\">test 123</form> some other value</div>"
2015-09-01 00:16:50 +00:00
//should = "<div>test 123 some other value</div>"
should = "test 123 some other value"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
source = "<div><form class=\"xxx\">test 123</form> some other value<input value=\"should not be shown\"></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>test 123 some other value</div>"
should = "test 123 some other value"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
2015-01-08 23:25:25 +00:00
source = "<div><font size=\"3\" color=\"red\">This is some text!</font></div>"
2015-09-01 00:16:50 +00:00
//should = "<div>This is some text!</div>"
should = "This is some text!"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlRemoveRichtext ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-01-07 14:30:13 +00:00
2015-08-05 09:40:50 +00:00
source = "<div><p>some link to somewhere from word<w:sdt>abc</w:sdt></p><o:p></o:p></a>"
should = "<div><p>some link to somewhere from wordabc</p></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . htmlCleanup ( $ ( source ) )
equal ( result . html ( ) , should , source )
2015-08-05 09:40:50 +00:00
2014-12-29 12:59:16 +00:00
} ) ;
2015-01-05 22:21:08 +00:00
// wrap
2015-10-09 20:31:26 +00:00
test ( "wrap" , function ( ) {
2015-01-05 22:21:08 +00:00
var source = "some text"
var should = 'some text'
2015-10-09 20:31:26 +00:00
var result = App . Utils . wrap ( source )
equal ( result , should , source )
2015-01-05 22:21:08 +00:00
source = "some text\nsome other text\n"
should = "some text\nsome other text\n"
2015-10-09 20:31:26 +00:00
result = App . Utils . wrap ( source )
equal ( result , should , source )
2015-01-05 22:21:08 +00:00
source = "some text with some line to wrap"
should = "some text with\nsome line to\nwrap"
2015-10-09 20:31:26 +00:00
result = App . Utils . wrap ( source , 14 )
equal ( result , should , source )
2015-01-05 22:21:08 +00:00
source = "some text\nsome other text\n"
should = "some text\nsome other text\n"
2015-10-09 20:31:26 +00:00
result = App . Utils . wrap ( source )
equal ( result , should , source )
2015-01-05 22:21:08 +00:00
source = "1234567890 1234567890 1234567890 1234567890"
should = "1234567890 1234567890 1234567890 1234567890"
2015-10-09 20:31:26 +00:00
result = App . Utils . wrap ( source )
equal ( result , should , source )
2015-01-05 22:21:08 +00:00
source = "123456789012 123456789012 123456789012"
should = "123456789012\n123456789012\n123456789012"
2015-10-09 20:31:26 +00:00
result = App . Utils . wrap ( source , 14 )
equal ( result , should , source )
2015-01-05 22:21:08 +00:00
} ) ;
2014-12-29 23:25:57 +00:00
// quote
2015-10-09 20:31:26 +00:00
test ( "quote" , function ( ) {
2014-12-29 23:25:57 +00:00
var source = "some text"
var should = '> some text'
2015-10-09 20:31:26 +00:00
var result = App . Utils . quote ( source )
equal ( result , should , source )
2014-12-29 23:25:57 +00:00
source = "some text\nsome other text\n"
should = "> some text\n> some other text"
2015-10-09 20:31:26 +00:00
result = App . Utils . quote ( source )
equal ( result , should , source )
2014-12-29 23:25:57 +00:00
source = "\n\nsome text\nsome other text\n \n"
should = "> some text\n> some other text"
2015-10-09 20:31:26 +00:00
result = App . Utils . quote ( source )
equal ( result , should , source )
2014-12-29 23:25:57 +00:00
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 ..."
2015-10-09 20:31:26 +00:00
result = App . Utils . quote ( source )
equal ( result , should , source )
2014-12-29 23:25:57 +00:00
2015-01-05 22:21:08 +00:00
source = "Welcome! Thank you for installing Zammad. You will find ..."
should = "> Welcome! Thank you\n> for installing\n> Zammad. You will\n> find ..."
2015-10-09 20:31:26 +00:00
result = App . Utils . quote ( source , 20 )
equal ( result , should , source )
2015-01-05 22:21:08 +00:00
2014-12-29 23:25:57 +00:00
} ) ;
2015-01-07 10:05:12 +00:00
// check signature
2015-10-09 20:31:26 +00:00
test ( "check signature" , function ( ) {
2015-01-07 10:05:12 +00:00
var message = "<div>test 123 </div>"
var signature = '<div>--<br>Some Signature<br>some department</div>'
2015-10-09 20:31:26 +00:00
var result = App . Utils . signatureCheck ( message , signature )
equal ( result , true )
2015-01-07 10:05:12 +00:00
message = "<div>test 123 <div>--<br>Some Signature<br>some department\n</div></div>"
signature = '<div>--<br>Some Signature<br>some department</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureCheck ( message , signature )
equal ( result , false )
2015-01-07 10:05:12 +00:00
message = "<div>test 123 <div>--<br>Some Signature\n<br>some department\n</div></div>"
signature = '<div>--<br>Some Signature<br>some department</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureCheck ( message , signature )
equal ( result , false )
2015-01-07 10:05:12 +00:00
message = "<div>test 123 <div>--<p>Some Signature</p>\n<p><div>some department</div>\n</p>\n</div></div>"
signature = '<div>--<br>Some Signature<br>some department</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureCheck ( message , signature )
equal ( result , false )
2015-01-07 10:05:12 +00:00
message = ""
signature = '<div>--<br>Some Signature<br>some department</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureCheck ( message , signature )
equal ( result , true )
2015-01-07 10:05:12 +00:00
message = ""
signature = "--\nSome Signature\nsome department"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureCheck ( message , signature )
equal ( result , true )
2015-01-07 10:05:12 +00:00
} ) ;
2015-04-02 22:29:32 +00:00
// identify signature
2015-10-09 20:31:26 +00:00
test ( "identify signature" , function ( ) {
2015-04-02 22:29:32 +00:00
var message = "<div>test 123 </div>"
var should = '<div>test 123 </div>'
2015-10-09 20:31:26 +00:00
var result = App . Utils . signatureIdentify ( message )
equal ( result , should )
2015-04-02 22:29:32 +00:00
message = "<div>test 123 <br/>--<br/>Bob Smith</div>"
should = '<div>test 123 <br/>--<br/>Bob Smith</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-03 01:11:21 +00:00
message = "<div>test 123 <br/>1<br/>2<br/>3<br/>4<br/>5<br/>6<br/>7<br/>8<br/>9<br/><br/>--<br/>Bob Smith</div>"
should = '<div>test 123 <br/>1<br/>2<br/>3<br/>4<br/>5<br/>6<br/>7<br/>8<br/>9<br/><br/><span class="js-signatureMarker"></span>--<br/>Bob Smith</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-03 01:11:21 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/>--<br/>Bob Smith</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><span class="js-signatureMarker"></span>--<br/>Bob Smith</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-03 01:11:21 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/> -- <br/>Bob Smith</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><span class="js-signatureMarker"></span> -- <br/>Bob Smith</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-03 01:11:21 +00:00
message = "<div>test 123 <br/><br/>--<br/>Bob Smith<br/><br/><br/><br/><br/>--<br/>Bob Smith</div>"
should = '<div>test 123 <br/><br/><span class="js-signatureMarker"></span>--<br/>Bob Smith<br/><br/><br/><br/><br/>--<br/>Bob Smith</div>'
2015-04-02 22:29:32 +00:00
//should = '<div>test 123 <br><br><br><br><br><br><br><br><br><br><br><span class="js-signatureMarker"></span>--<br>Bob Smith<br/><br/><br/><br/><br/>--<br/>Bob Smith</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-03 01:11:21 +00:00
message = "<div>test 123</div><div>test 123</div><div>--</div><div>Bob Smith</div>"
should = "<div>test 123</div><div>test 123</div><div><span class=\"js-signatureMarker\"></span>--</div><div>Bob Smith</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-03 01:11:21 +00:00
message = "<p><span>test 123</span></p><p><span>test 123</span></p><p><span>--</span></p><p><span>Bob Smith</span></p><div></div>"
should = "<p><span>test 123</span></p><p><span>test 123</span></p><p><span><span class=\"js-signatureMarker\"></span>--</span></p><p><span>Bob Smith</span></p><div></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
2015-04-02 22:29:32 +00:00
2015-04-03 00:01:21 +00:00
// apple
2015-04-04 22:20:47 +00:00
// en
2015-04-03 01:11:21 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>On 01/04/15 10:55, Bob Smith wrote:<br/>lalala<p>--</p>some test</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>On 01/04/15 10:55, Bob Smith wrote:<br/>lalala<p>--</p>some test</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-04 22:20:47 +00:00
// de
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Am 03.04.2015 um 20:58 schrieb Bob Smith <bob@example.com>:<br/>lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Am 03.04.2015 um 20:58 schrieb Bob Smith <bob@example.com>:<br/>lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-03 00:01:21 +00:00
// ms
2015-04-04 22:20:47 +00:00
// en
2015-04-03 01:11:21 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>lalala</div>"
2015-04-03 01:49:40 +00:00
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-03 01:49:40 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>Subject: lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>Subject: lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-03 01:49:40 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>1<br/>2<br/>3<br/>4<br/>4<br/>Subject: lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>1<br/>2<br/>3<br/>4<br/>4<br/>Subject: lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-04 22:20:47 +00:00
// de
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Gesendet: Donnerstag, 2. April 2015 10:00<br/>Betreff: lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Gesendet: Donnerstag, 2. April 2015 10:00<br/>Betreff: lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-04 22:20:47 +00:00
2015-04-03 01:11:21 +00:00
message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>"
2015-04-03 01:49:40 +00:00
should = "<div>1<br><br></div><div>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-03 01:49:40 +00:00
message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
should = "<div>1<br><br></div><div><span class=\"js-signatureMarker\"></span>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-03 01:49:40 +00:00
message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Znuny Support <<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>></div>\n<div>An: somebody</div><div>Datum: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
should = "<div>1<br><br></div><div><span class=\"js-signatureMarker\"></span>Von: Martin Edenhofer via Znuny Support <<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>></div>\n<div>An: somebody</div><div>Datum: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-03 00:01:21 +00:00
2015-10-10 08:38:54 +00:00
message = "<div>Von: "Johannes Nickel via Znuny Projects" <<a href=\"mailto:projects@znuny.inc\" title=\"mailto:projects@znuny.inc\">projects@znuny.inc</a>></div><div>An: \"Lisa Smith\" <<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>></div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
should = "<div><span class=\"js-signatureMarker\"></span>Von: "Johannes Nickel via Znuny Projects" <<a href=\"mailto:projects@znuny.inc\" title=\"mailto:projects@znuny.inc\">projects@znuny.inc</a>></div><div>An: \"Lisa Smith\" <<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>></div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
message = "<div>Hi Johannes,</div><div><br></div><div>das Angebot für den halben Tag bitte an uns.</div><div>Der Termin hat sich jetzt auf 10-12 Uhr verschoben, hab ich dir weitergeleitet.</div><div><br></div><div>Viele Grüße</div><div>Max</div><div><br></div><div>> On 07 Oct 2015, at 11:55, Johannes Smith <<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>smith@example.com</a> <<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>mailto:smith@example.com</a>>> wrote:</div><div>></div><div>> Hi,</div><div>></div><div>> OK. Wer kriegt das Angebot? Ist das wirklich nur ein halber Tag?</div></div>"
should = "<div>Hi Johannes,</div><div><br></div><div>das Angebot für den halben Tag bitte an uns.</div><div>Der Termin hat sich jetzt auf 10-12 Uhr verschoben, hab ich dir weitergeleitet.</div><div><br></div><div>Viele Grüße</div><div>Max</div><div><br></div><div><span class=\"js-signatureMarker\"></span>> On 07 Oct 2015, at 11:55, Johannes Smith <<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>smith@example.com</a> <<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>mailto:smith@example.com</a>>> wrote:</div><div>></div><div>> Hi,</div><div>></div><div>> OK. Wer kriegt das Angebot? Ist das wirklich nur ein halber Tag?</div></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-04 22:20:47 +00:00
2015-04-30 07:23:01 +00:00
// fr
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-30 07:23:01 +00:00
2015-04-04 22:20:47 +00:00
// thunderbird
// de
message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Znuny Sales:</div><div>> Hallo Christian,</div>"
should = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div><span class=\"js-signatureMarker\"></span>Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Znuny Sales:</div><div>> Hallo Christian,</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-04 22:20:47 +00:00
// en - Thunderbird default - http://kb.mozillazine.org/Reply_header_settings
message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>On 01-01-2007 11:00 AM, Alf Aardvark wrote:</div><div>> Hallo Christian,</div>"
should = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div><span class=\"js-signatureMarker\"></span>On 01-01-2007 11:00 AM, Alf Aardvark wrote:</div><div>> Hallo Christian,</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-04 22:20:47 +00:00
// en - http://kb.mozillazine.org/Reply_header_settings
message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>Alf Aardvark wrote, on 01-01-2007 11:00 AM:</div><div>> Hallo Christian,</div>"
should = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div><span class=\"js-signatureMarker\"></span>Alf Aardvark wrote, on 01-01-2007 11:00 AM:</div><div>> Hallo Christian,</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-04 22:20:47 +00:00
2015-04-03 00:01:21 +00:00
// otrs
2015-04-04 22:20:47 +00:00
// en
2015-04-03 01:11:21 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>01/04/15 10:55 - Bob Smith wrote:<br/>lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>01/04/15 10:55 - Bob Smith wrote:<br/>lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-04 22:20:47 +00:00
// de
2015-04-03 01:11:21 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>01/04/15 10:55 - Bob Smith schrieb:<br/>lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>01/04/15 10:55 - Bob Smith schrieb:<br/>lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-02 22:29:32 +00:00
2015-04-03 01:11:21 +00:00
message = "<div>test 123 <br/><br/></div><div>24.02.2015 14:20 - Roy Kaldung via Znuny Sales schrieb: </div>"
should = "<div>test 123 <br/><br/></div><div><span class=\"js-signatureMarker\"></span>24.02.2015 14:20 - Roy Kaldung via Znuny Sales schrieb: </div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-03 00:01:21 +00:00
2015-04-04 22:20:47 +00:00
// zammad
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><div data-signature=\"true\" data-signature-id=\"5\">lalala</div></div>"
should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><div data-signature=\"true\" data-signature-id=\"5\">lalala</div></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-04 22:20:47 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><blockquote type=\"cite\">lalala</blockquote></div>"
should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><blockquote type=\"cite\">lalala</blockquote></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-04 22:20:47 +00:00
2015-04-04 22:43:01 +00:00
// gmail
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><blockquote class=\"ecxgmail_quote\">lalala</blockquote></div>"
should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><blockquote class=\"ecxgmail_quote\">lalala</blockquote></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-04 22:43:01 +00:00
2015-04-05 11:05:59 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><blockquote class=\"gmail_quote\">lalala</blockquote></div>"
should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><blockquote class=\"gmail_quote\">lalala</blockquote></div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-05 11:05:59 +00:00
2015-04-04 22:43:01 +00:00
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Am 24. Dezember 2015 um 07:45 schrieb kathrine <kathrine@example.com>:<br/>lalala</div>"
should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span>Am 24. Dezember 2015 um 07:45 schrieb kathrine <kathrine@example.com>:<br/>lalala</div>"
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-04-04 22:43:01 +00:00
2015-09-02 07:16:31 +00:00
// word 14
// en
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Bob Smith wrote:<br/>lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Bob Smith wrote:<br/>lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-09-02 07:16:31 +00:00
// de
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Bob Smith schrieb:<br/>lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Bob Smith schrieb:<br/>lalala</div>'
2015-10-09 20:31:26 +00:00
result = App . Utils . signatureIdentify ( message , true )
equal ( result , should )
2015-09-02 07:16:31 +00:00
2015-04-02 22:29:32 +00:00
} ) ;
2015-01-12 22:15:39 +00:00
// replace tags
2015-10-09 20:31:26 +00:00
test ( "check replace tags" , function ( ) {
2015-01-12 22:15:39 +00:00
var message = "<div>#{user.firstname} #{user.lastname}</div>"
var result = '<div>Bob Smith</div>'
var data = {
user : {
firstname : 'Bob' ,
lastname : 'Smith' ,
} ,
}
2015-10-09 20:31:26 +00:00
var verify = App . Utils . replaceTags ( message , data )
equal ( verify , result )
2015-01-12 22:15:39 +00:00
message = "<div>#{user.firstname} #{user.lastname}</div>"
result = '<div>Bob Smith</div>'
data = {
user : {
firstname : function ( ) { return 'Bob' } ,
lastname : function ( ) { return 'Smith' } ,
} ,
}
2015-10-09 20:31:26 +00:00
verify = App . Utils . replaceTags ( message , data )
equal ( verify , result )
2015-01-12 22:15:39 +00:00
message = "<div>#{user.firstname} #{user.lastname}</div>"
result = '<div>Bob </div>'
data = {
user : {
firstname : 'Bob' ,
} ,
}
2015-10-09 20:31:26 +00:00
verify = App . Utils . replaceTags ( message , data )
equal ( verify , result )
2015-01-12 22:15:39 +00:00
} ) ;
// check if last line is a empty line
2015-10-09 20:31:26 +00:00
test ( "check if last line is a empty line" , function ( ) {
2015-01-12 22:15:39 +00:00
var message = "123"
var result = false
2015-10-09 20:31:26 +00:00
var verify = App . Utils . lastLineEmpty ( message )
equal ( verify , result , message )
2015-01-12 22:15:39 +00:00
message = "<div>123</div>"
result = false
2015-10-09 20:31:26 +00:00
verify = App . Utils . lastLineEmpty ( message )
equal ( verify , result , message )
2015-01-12 22:15:39 +00:00
message = "<p><div>123 </div></p>"
result = false
2015-10-09 20:31:26 +00:00
verify = App . Utils . lastLineEmpty ( message )
equal ( verify , result , message )
2015-01-12 22:15:39 +00:00
message = "<div></div>"
result = true
2015-10-09 20:31:26 +00:00
verify = App . Utils . lastLineEmpty ( message )
equal ( verify , result , message )
2015-01-12 22:15:39 +00:00
message = "<div class=\"some_class\"></div>"
result = true
2015-10-09 20:31:26 +00:00
verify = App . Utils . lastLineEmpty ( message )
equal ( verify , result , message )
2015-01-12 22:15:39 +00:00
message = "<div class=\"some_class\"></div> "
result = true
2015-10-09 20:31:26 +00:00
verify = App . Utils . lastLineEmpty ( message )
equal ( verify , result , message )
2015-01-12 22:15:39 +00:00
message = "<div class=\"some_class\"></div> \n \n\t"
result = true
2015-10-09 20:31:26 +00:00
verify = App . Utils . lastLineEmpty ( message )
equal ( verify , result , message )
2015-01-12 22:15:39 +00:00
message = "<div class=\"some_class\"> </div> \n \n\t"
result = true
2015-10-09 20:31:26 +00:00
verify = App . Utils . lastLineEmpty ( message )
equal ( verify , result , message )
2015-01-12 22:15:39 +00:00
message = "<div class=\"some_class\"\n> \n</div> \n \n\t"
result = true
2015-10-09 20:31:26 +00:00
verify = App . Utils . lastLineEmpty ( message )
equal ( verify , result , message )
2015-01-12 22:15:39 +00:00
2015-01-27 07:38:17 +00:00
} ) ;
// check attibute validation
2015-10-09 20:31:26 +00:00
test ( "check attibute validation" , function ( ) {
2015-01-27 07:38:17 +00:00
var string = '123'
2015-10-09 20:31:26 +00:00
var result = '123'
var verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
string = '123!'
2015-10-09 20:31:26 +00:00
result = '123'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
string = '12 3!'
2015-10-09 20:31:26 +00:00
result = '123'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
string = '12-3!'
2015-10-09 20:31:26 +00:00
result = '12-3'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
string = '12_3!'
2015-10-09 20:31:26 +00:00
result = '12_3'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
string = '^12_3!'
2015-10-09 20:31:26 +00:00
result = '12_3'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
string = '^1\n 2_3!'
2015-10-09 20:31:26 +00:00
result = '12_3'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
string = 'abc?'
2015-10-09 20:31:26 +00:00
result = 'abc'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
string = 'abc."'
2015-10-09 20:31:26 +00:00
result = 'abc'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
string = '#abc!^'
2015-10-09 20:31:26 +00:00
result = 'abc'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
2015-01-27 07:50:40 +00:00
string = 'abc()=$'
2015-10-09 20:31:26 +00:00
result = 'abc'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:50:40 +00:00
2015-01-27 08:14:25 +00:00
string = "abc()=$\n123\rß"
2015-10-09 20:31:26 +00:00
result = 'abc123'
verify = App . Utils . htmlAttributeCleanup ( string )
equal ( verify , result , string )
2015-01-27 07:38:17 +00:00
2015-01-12 22:15:39 +00:00
} ) ;
2015-01-28 22:12:16 +00:00
// check form diff
2015-10-09 20:31:26 +00:00
test ( "check form diff" , function ( ) {
2015-01-28 22:12:16 +00:00
var dataNow = {
owner _id : 1 ,
pending _date : '2015-01-28T09:39:00Z' ,
}
var dataLast = {
owner _id : '' ,
pending _date : '2015-01-28T09:39:00Z' ,
}
var diff = { }
2015-10-09 20:31:26 +00:00
var result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
owner _id : '1' ,
pending _date : '2015-01-28T09:39:00Z' ,
}
dataLast = {
owner _id : '' ,
pending _date : '2015-01-28T09:39:00Z' ,
}
diff = { }
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
pending _date : '2015-01-28T09:39:00Z' ,
}
dataLast = {
owner _id : 1 ,
pending _date : '2015-01-28T09:39:00Z' ,
}
diff = { }
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
owner _id : '' ,
pending _date : '2015-01-28T09:39:00Z' ,
}
dataLast = {
pending _date : '2015-01-28T09:39:00Z' ,
}
diff = {
owner _id : '' ,
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
owner _id : '' ,
state _ids : [ 1 , 5 , 6 , 7 ] ,
}
dataLast = { }
diff = {
owner _id : '' ,
state _ids : [ '1' , '5' , '6' , '7' ] ,
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
owner _id : 1 ,
state _ids : [ 1 , 5 , 7 , 6 ] ,
}
dataLast = {
owner _id : '' ,
state _ids : [ 1 , 5 , 6 , 7 ] ,
}
diff = { }
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
owner _id : 1 ,
state _ids : [ 1 , 5 , 6 , 7 ] ,
}
dataLast = {
state _ids : [ '1' , '5' , '7' ] ,
}
diff = {
owner _id : '' ,
state _ids : [ '6' ] ,
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
owner _id : '' ,
state _ids : [ 1 , 5 , 6 , 7 ] ,
}
dataLast = {
owner _id : 1 ,
state _ids : [ 1 , 5 , 6 , 7 ] ,
}
diff = { }
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
owner _id : '' ,
state _ids : [ 1 , 5 , 6 , 7 ] ,
}
dataLast = {
owner _id : 5 ,
state _ids : [ 1 , 5 , 6 , 7 ] ,
}
diff = {
owner _id : ''
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
state _id : 4 ,
pending _time : '2015-01-28T11:34:00Z'
}
dataLast = {
state _id : 5 ,
pending _time : undefined
}
diff = {
state _id : '4' ,
pending _time : '2015-01-28T11:34:00Z'
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
pending _time : undefined
}
dataLast = {
pending _time : null
}
diff = { }
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
ticket : {
pending _time : undefined ,
} ,
}
dataLast = {
ticket : {
pending _time : null ,
} ,
}
diff = { }
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
test : '123' ,
ticket : {
pending _time : undefined ,
} ,
}
dataLast = {
test : '123' ,
ticket : {
pending _time : null ,
} ,
}
diff = { }
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
test : '123' ,
}
dataLast = { }
diff = {
test : '123' ,
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
test : '123' ,
}
dataLast = {
test : [ 1 , 2 , 3 , 4 ]
}
diff = {
test : '123' ,
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
test : '123' ,
}
dataLast = {
test : {
1 : 1 ,
2 : 2 ,
}
}
diff = {
test : '123' ,
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
test : [ 1 , 2 , 3 , '4' ]
}
dataLast = {
test : '123' ,
}
diff = {
test : [ '1' , '2' , '3' , '4' ]
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
test : {
1 : 1 ,
2 : 2 ,
}
}
dataLast = {
test : '123' ,
}
diff = {
test : {
1 : '1' ,
2 : '2' ,
}
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
dataNow = {
test : '123' ,
ticket : {
pending _time : undefined ,
} ,
}
dataLast = {
ticket : {
pending _time : null ,
} ,
}
diff = {
test : '123' ,
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-28 22:12:16 +00:00
2015-01-29 13:19:11 +00:00
dataNow = undefined
dataLast = undefined
diff = { }
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-29 13:19:11 +00:00
dataNow = { }
dataLast = { "number" : "10012" , "title" : "some subject 123äöü" , "group_id" : 1 , "owner_id" : 1 , "customer_id" : 2 , "state_id" : 3 , "priority_id" : 2 , "article" : { "from" : "Test Master Agent" , "to" : "" , "cc" : "" , "body" : "dasdad" , "content_type" : "text/html" , "ticket_id" : 12 , "type_id" : 9 , "sender_id" : 1 , "internal" : false , "form_id" : "523405147" } , "updated_at" : "2015-01-29T09:22:23.000Z" , "pending_time" : "2015-01-28T22:22:00.000Z" , "id" : 12 }
diff = { }
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-29 13:19:11 +00:00
// do not compare content of data instances/objects
no = function test _object ( ) {
this . a = function ( ) { return 123 ; }
this . b = function ( ) { return '1234' ; }
this . c = function ( ) { return [ 123 ] ; }
this . d = [ 1 , 2 , 3 ] ;
this . e = 'abc' ;
}
no1 = new no ( )
no2 = new no ( )
no3 = new no ( )
dataNow = {
number : '10013' ,
Article : [ no1 ] ,
}
dataLast = {
number : "10012" ,
title : "some subject 123äöü" ,
Article : [ no2 , no3 ] ,
}
diff = {
number : '10013' ,
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-29 13:19:11 +00:00
dataNow = {
number : '10013' ,
Article : [ no1 , 2 ] ,
}
dataLast = {
number : "10012" ,
title : "some subject 123äöü" ,
Article : [ no2 , no3 ] ,
}
diff = {
number : '10013' ,
Article : [ '2' ] ,
}
2015-10-09 20:31:26 +00:00
result = App . Utils . formDiff ( dataNow , dataLast )
deepEqual ( result , diff , 'check form diff' )
2015-01-29 13:19:11 +00:00
2015-01-28 22:12:16 +00:00
} ) ;
2015-10-02 21:41:41 +00:00
// check decimal format
2015-10-09 20:31:26 +00:00
test ( "check decimal format" , function ( ) {
2015-10-02 21:41:41 +00:00
var string = '123'
2015-10-09 20:31:26 +00:00
var result = '123.00'
var verify = App . Utils . decimal ( string )
equal ( verify , result , string )
2015-10-02 21:41:41 +00:00
string = '0.6'
2015-10-09 20:31:26 +00:00
result = '0.60'
verify = App . Utils . decimal ( string )
equal ( verify , result , string )
2015-10-02 21:41:41 +00:00
2015-10-03 07:25:40 +00:00
string = '6'
2015-10-09 20:31:26 +00:00
result = '6.00'
verify = App . Utils . decimal ( string )
equal ( verify , result , string )
2015-10-03 07:25:40 +00:00
string = 6.5
2015-10-09 20:31:26 +00:00
result = '6.50'
verify = App . Utils . decimal ( string )
equal ( verify , result , string )
2015-10-03 07:25:40 +00:00
2015-10-02 21:41:41 +00:00
string = '111111.6'
2015-10-09 20:31:26 +00:00
result = '111111.60'
verify = App . Utils . decimal ( string )
equal ( verify , result , string )
2015-10-02 21:41:41 +00:00
string = '111111.622'
2015-10-09 20:31:26 +00:00
result = '111111.62'
verify = App . Utils . decimal ( string )
equal ( verify , result , string )
2015-10-02 21:41:41 +00:00
string = 'abc.6'
2015-10-09 20:31:26 +00:00
result = 'abc.6'
verify = App . Utils . decimal ( string )
equal ( verify , result , string )
string = ''
result = ''
verify = App . Utils . decimal ( string )
equal ( verify , result , string )
string = undefined
result = ''
verify = App . Utils . decimal ( string )
equal ( verify , result , string )
string = null
result = ''
verify = App . Utils . decimal ( string )
equal ( verify , result , string )
2015-10-02 21:41:41 +00:00
} ) ;
// check formatTime format
2015-10-09 20:31:26 +00:00
test ( "check formatTime format" , function ( ) {
2015-10-02 21:41:41 +00:00
var string = '123'
2015-10-09 20:31:26 +00:00
var result = '123'
var verify = App . Utils . formatTime ( string , 0 )
equal ( verify , result , string )
2015-10-02 21:41:41 +00:00
string = '6'
2015-10-09 20:31:26 +00:00
result = '06'
verify = App . Utils . formatTime ( string , 2 )
equal ( verify , result , string )
string = ''
result = '00'
verify = App . Utils . formatTime ( string , 2 )
equal ( verify , result , string )
string = undefined
result = ''
verify = App . Utils . formatTime ( string , 2 )
equal ( verify , result , string )
string = null
result = ''
verify = App . Utils . formatTime ( string , 2 )
equal ( verify , result , string )
2015-10-02 21:41:41 +00:00
} ) ;
2014-12-29 12:59:16 +00:00
}