2014-02-10 02:11:25 +01:00
module ( "tinymce.html.Entities" ) ;
test ( 'encodeRaw' , function ( ) {
expect ( 2 ) ;
2014-06-18 01:49:00 +02:00
equal ( tinymce . html . Entities . encodeRaw ( '<>"\'&\u00e5\u00e4\u00f6\u0060' ) , '<>"\'&\u00e5\u00e4\u00f6\u0060' , 'Raw encoding text' ) ;
equal ( tinymce . html . Entities . encodeRaw ( '<>"\'&\u00e5\u00e4\u00f6\u0060' , true ) , '<>"\'&\u00e5\u00e4\u00f6`' , 'Raw encoding attribute' ) ;
2014-02-10 02:11:25 +01:00
} ) ;
test ( 'encodeAllRaw' , function ( ) {
expect ( 1 ) ;
equal ( tinymce . html . Entities . encodeAllRaw ( '<>"\'&\u00e5\u00e4\u00f6' ) , '<>"'&\u00e5\u00e4\u00f6' , 'Raw encoding all' ) ;
} ) ;
test ( 'encodeNumeric' , function ( ) {
expect ( 2 ) ;
equal ( tinymce . html . Entities . encodeNumeric ( '<>"\'&\u00e5\u00e4\u00f6\u03b8\u2170\ufa11' ) , '<>"\'&åäöθⅰ﨑' , 'Numeric encoding text' ) ;
equal ( tinymce . html . Entities . encodeNumeric ( '<>"\'&\u00e5\u00e4\u00f6' , true ) , '<>"\'&åäö' , 'Numeric encoding attribute' ) ;
} ) ;
test ( 'encodeNamed' , function ( ) {
expect ( 4 ) ;
equal ( tinymce . html . Entities . encodeNamed ( '<>"\'&\u00e5\u00e4\u00f6' ) , '<>"\'&åäö' , 'Named encoding text' ) ;
equal ( tinymce . html . Entities . encodeNamed ( '<>"\'&\u00e5\u00e4\u00f6' , true ) , '<>"\'&åäö' , 'Named encoding attribute' ) ;
equal ( tinymce . html . Entities . encodeNamed ( '<>"\'\u00e5\u00e4\u00f6' , false , { '\u00e5' : 'å' } ) , '<>"\'å\u00e4\u00f6' , 'Named encoding text' ) ;
equal ( tinymce . html . Entities . encodeNamed ( '<>"\'\u00e5\u00e4\u00f6' , true , { '\u00e5' : 'å' } ) , '<>"\'å\u00e4\u00f6' , 'Named encoding attribute' ) ;
} ) ;
test ( 'getEncodeFunc' , function ( ) {
var encodeFunc ;
expect ( 10 ) ;
encodeFunc = tinymce . html . Entities . getEncodeFunc ( 'raw' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' ) , '<>"\'&\u00e5\u00e4\u00f6' , 'Raw encoding text' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' , true ) , '<>"\'&\u00e5\u00e4\u00f6' , 'Raw encoding attribute' ) ;
encodeFunc = tinymce . html . Entities . getEncodeFunc ( 'named' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' ) , '<>"\'&åäö' , 'Named encoding text' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' , true ) , '<>"\'&åäö' , 'Named encoding attribute' ) ;
encodeFunc = tinymce . html . Entities . getEncodeFunc ( 'numeric' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' ) , '<>"\'&åäö' , 'Named encoding text' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' , true ) , '<>"\'&åäö' , 'Named encoding attribute' ) ;
encodeFunc = tinymce . html . Entities . getEncodeFunc ( 'named+numeric' , '229,aring' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' ) , '<>"\'&åäö' , 'Named+numeric encoding text' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' , true ) , '<>"\'&åäö' , 'Named+numeric encoding attribute' ) ;
encodeFunc = tinymce . html . Entities . getEncodeFunc ( 'named,numeric' , '229,aring' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' ) , '<>"\'&åäö' , 'Named+numeric encoding text' ) ;
equal ( encodeFunc ( '<>"\'&\u00e5\u00e4\u00f6' , true ) , '<>"\'&åäö' , 'Named+numeric encoding attribute' ) ;
} ) ;
test ( 'decode' , function ( ) {
2015-07-01 02:51:22 +02:00
equal ( tinymce . html . Entities . decode ( '<>"'&åäö&unknown;' ) , '<>"\'&\u00e5\u00e4\u00f6&unknown;' , 'Decode text with various entities' ) ;
equal ( tinymce . html . Entities . decode ( 'AB'' ) , 'AB\'' , 'Decode numeric entities' ) ;
equal ( tinymce . html . Entities . decode ( 'OO'' ) , 'OO\'' , 'Decode hexanumeric entities' ) ;
equal ( tinymce . html . Entities . decode ( 'ABC' ) , 'ABC' , 'Decode numeric entities with no semicolon' ) ;
equal ( tinymce . html . Entities . decode ( '&test' ) , '&test' , 'Dont decode invalid entity name without semicolon' ) ;
2014-02-10 02:11:25 +01:00
equal ( tinymce . html . Entities . encodeNumeric ( tinymce . html . Entities . decode (
'‚ƒ„…†‡ˆ‰Š' +
'‹ŒŽ‘’“”•–—˜' +
'™š›œžŸ' )
) , '‚ƒ„…†‡ˆ‰Š‹ŒŽ' +
'‘’“”•–—˜™š' +
'›œžŸ' ,
'Entity decode ascii' ) ;
equal ( tinymce . html . Entities . encodeNumeric ( tinymce . html . Entities . decode ( '你' ) ) , '你' , "High byte non western character." ) ;
} ) ;