40 lines
1.7 KiB
HTML
40 lines
1.7 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>tinymce.util.JSON 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.util.JSON");
|
||
|
|
||
|
QUnit.config.reorder = false;
|
||
|
|
||
|
(function() {
|
||
|
var JSON = tinymce.util.JSON;
|
||
|
|
||
|
test('serialize', 2, function() {
|
||
|
equal(JSON.serialize({arr1 : [1, 2, 3, [1, 2, 3]], bool1 : true, float1: 3.14, int1 : 123, null1 : null, obj1 : {key1 : "val1", key2 : "val2"}, str1 : '\"\'abc\u00C5123\\'}), '{"arr1":[1,2,3,[1,2,3]],"bool1":true,"float1":3.14,"int1":123,"null1":null,"obj1":{"key1":"val1","key2":"val2"},"str1":"\\"\'abc\\u00c5123\\\\"}');
|
||
|
|
||
|
equal(JSON.serialize({arr1 : [1, 2, 3, [1, 2, 3]], bool1 : true, float1: 3.14, int1 : 123, null1 : null, obj1 : {key1 : "val1", key2 : "val2"}, str1 : '\"\'abc\u00C5123'}, "'"), "{'arr1':[1,2,3,[1,2,3]],'bool1':true,'float1':3.14,'int1':123,'null1':null,'obj1':{'key1':'val1','key2':'val2'},'str1':'\\\"\\'abc\\u00c5123'}");
|
||
|
});
|
||
|
|
||
|
test('parse', 1, function() {
|
||
|
equal(JSON.parse('{"arr1":[1,2,3,[1,2,3]],"bool1":true,"float1":3.14,"int1":123,"null1":null,"obj1":{"key1":"val1","key2":"val2"},"str1":"abc\\u00c5123"}').str1, 'abc\u00c5123');
|
||
|
});
|
||
|
})();
|
||
|
</script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1 id="qunit-header">tinymce.util.JSON 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>
|