58f914004d
Fixes #32801. git-svn-id: https://develop.svn.wordpress.org/trunk@33013 602fd350-edb4-49c9-b593-d223f7449a82
76 lines
4.4 KiB
JavaScript
76 lines
4.4 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() {
|
|
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');
|
|
|
|
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.");
|
|
});
|