74 lines
4.0 KiB
JavaScript
74 lines
4.0 KiB
JavaScript
module("tinymce.html.Entities");
|
|
|
|
test('encodeRaw', function() {
|
|
expect(2);
|
|
|
|
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');
|
|
});
|
|
|
|
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() {
|
|
expect(3);
|
|
|
|
equal(tinymce.html.Entities.decode('<>"'&åäö&unknown;'''), '<>"\'&\u00e5\u00e4\u00f6&unknown;\'\'', 'Decode text with various entities');
|
|
|
|
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.");
|
|
});
|