99 lines
4.7 KiB
HTML
99 lines
4.7 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>tinymce.html.Entities tests</title>
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||
|
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
|
||
|
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
|
||
|
<script src="../../js/qunit/reporter.js"></script>
|
||
|
<script src="../../js/utils.js"></script>
|
||
|
<script src="../../js/tinymce_loader.js"></script>
|
||
|
<script>
|
||
|
module("tinymce.html.Entities");
|
||
|
|
||
|
QUnit.config.reorder = false;
|
||
|
|
||
|
test('encodeRaw', function() {
|
||
|
expect(2);
|
||
|
|
||
|
equal(tinymce.html.Entities.encodeRaw('<>"\'&\u00e5\u00e4\u00f6'), '<>"\'&\u00e5\u00e4\u00f6', 'Raw encoding text');
|
||
|
equal(tinymce.html.Entities.encodeRaw('<>"\'&\u00e5\u00e4\u00f6', 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.");
|
||
|
});
|
||
|
|
||
|
</script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1 id="qunit-header">tinymce.html.Entities tests</h1>
|
||
|
<h2 id="qunit-banner"></h2>
|
||
|
<div id="qunit-testrunner-toolbar"></div>
|
||
|
<h2 id="qunit-userAgent"></h2>
|
||
|
<ol id="qunit-tests"></ol>
|
||
|
<div id="content"></div>
|
||
|
</body>
|
||
|
</html>
|