JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0
[ckeditor.git] / _source / tests / core / tools.html
diff --git a/_source/tests/core/tools.html b/_source/tests/core/tools.html
new file mode 100644 (file)
index 0000000..72a2722
--- /dev/null
@@ -0,0 +1,170 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml">\r
+<head>\r
+       <title>CKEDITOR.tools</title>\r
+       <link rel="stylesheet" type="text/css" href="../test.css" />\r
+       <script type="text/javascript" src="../../ckeditor.js"></script>\r
+       <script type="text/javascript" src="../test.js"></script>\r
+       <script type="text/javascript">\r
+       //<![CDATA[\r
+var testcase;\r
+CKEDITOR.test.addTestCase( testcase = (function()\r
+{\r
+       // Local reference to the "assert" object.\r
+       var assert = CKEDITOR.test.assert;\r
+\r
+       return {\r
+               test_extend : function()\r
+               {\r
+                       var fakeFn = function() {};\r
+                       var fakeObj = { fake1 : 1, fake2 : 2 };\r
+                       var fakeArray = [ 'Test', 10, fakeFn, fakeObj ];\r
+\r
+                       var target =\r
+                       {\r
+                               prop1 : 'Test',\r
+                               prop2 : 10,\r
+                               prop3 : fakeFn,\r
+                               prop4 : fakeObj,\r
+                               prop5 : fakeArray\r
+                       };\r
+\r
+                       CKEDITOR.tools.extend( target,\r
+                               {\r
+                                       prop3 : 'Wrong',\r
+                                       prop6 : 'Good',\r
+                                       prop7 : fakeArray\r
+                               } );\r
+\r
+                       assert.areSame( 'Test'          , target.prop1, 'prop1 doesn\'t match' );\r
+                       assert.areSame( 10                      , target.prop2, 'prop2 doesn\'t match' );\r
+                       assert.areSame( fakeFn          , target.prop3, 'prop3 doesn\'t match' );\r
+                       assert.areSame( fakeObj         , target.prop4, 'prop4 doesn\'t match' );\r
+                       assert.areSame( fakeArray       , target.prop5, 'prop5 doesn\'t match' );\r
+                       assert.areSame( 'Good'          , target.prop6, 'prop6 doesn\'t match' );\r
+                       assert.areSame( fakeArray       , target.prop7, 'prop7 doesn\'t match' );\r
+               },\r
+\r
+               test_isArray1 : function()\r
+               {\r
+                       assert.isTrue( CKEDITOR.tools.isArray( [] ) );\r
+               },\r
+\r
+               test_isArray2 : function()\r
+               {\r
+                       assert.isFalse( CKEDITOR.tools.isArray( { length:1 } ) );\r
+               },\r
+\r
+               test_isArray3 : function()\r
+               {\r
+                       assert.isFalse( CKEDITOR.tools.isArray( null ) );\r
+               },\r
+\r
+               test_isArray4 : function()\r
+               {\r
+                       assert.isFalse( CKEDITOR.tools.isArray( window.x ) );\r
+               },\r
+\r
+               test_htmlEncode1 : function()\r
+               {\r
+                       assert.areSame( '&lt;b&gt;Test&lt;/b&gt;', CKEDITOR.tools.htmlEncode( '<b>Test</b>' ) );\r
+               },\r
+\r
+               test_htmlEncode2 : function()\r
+               {\r
+                       assert.areSame( 'Test\'s &amp; "quote"', CKEDITOR.tools.htmlEncode( 'Test\'s & "quote"' ) );\r
+               },\r
+\r
+               test_htmlEncode_3874 : function()\r
+               {\r
+                       assert.areSame( 'line1\nline2', CKEDITOR.tools.htmlEncode( 'line1\nline2' ) );\r
+               },\r
+\r
+               test_cssStyleToDomStyle1 : function()\r
+               {\r
+                       assert.areSame( 'backgroundColor', CKEDITOR.tools.cssStyleToDomStyle( 'background-color' ) );\r
+               },\r
+\r
+               test_cssStyleToDomStyle2 : function()\r
+               {\r
+                       assert.areSame( 'cssFloat', CKEDITOR.tools.cssStyleToDomStyle( 'float' ) );\r
+               },\r
+\r
+               test_getNextNumber : function()\r
+               {\r
+                       var number = CKEDITOR.tools.getNextNumber();\r
+                       assert.areSame( number +  1, CKEDITOR.tools.getNextNumber() );\r
+                       assert.areSame( number +  2, CKEDITOR.tools.getNextNumber() );\r
+                       assert.areSame( number +  3, CKEDITOR.tools.getNextNumber() );\r
+               },\r
+\r
+               test_trim1 : function()\r
+               {\r
+                       assert.areSame( 'test', CKEDITOR.tools.trim( '    test   ' ) );\r
+               },\r
+\r
+               test_trim2 : function()\r
+               {\r
+                       assert.areSame( 'test', CKEDITOR.tools.trim( ' \n \t  test\n  \t ' ) );\r
+               },\r
+\r
+               test_ltrim1 : function()\r
+               {\r
+                       assert.areSame( 'test   ', CKEDITOR.tools.ltrim( '    test   ' ) );\r
+               },\r
+\r
+               test_ltrim2 : function()\r
+               {\r
+                       assert.areSame( 'test\n  \t ', CKEDITOR.tools.ltrim( ' \n \t  test\n  \t ' ) );\r
+               },\r
+\r
+               test_rtrim1 : function()\r
+               {\r
+                       assert.areSame( '    test', CKEDITOR.tools.rtrim( '    test   ' ) );\r
+               },\r
+\r
+               test_rtrim2 : function()\r
+               {\r
+                       assert.areSame( ' \n \t  test', CKEDITOR.tools.rtrim( ' \n \t  test\n  \t ' ) );\r
+               },\r
+\r
+               test_clone : function()\r
+               {\r
+                       var obj =\r
+                       {\r
+                               name : 'John',\r
+                               cars :\r
+                               {\r
+                                       Mercedes : { color : 'blue' },\r
+                                       Porsche : { color : 'red' }\r
+                               }\r
+                       };\r
+\r
+                       var clone = CKEDITOR.tools.clone( obj );\r
+\r
+                       clone.name = 'Paul';\r
+                       clone.cars.Porsche.color = 'silver';\r
+\r
+                       assert.areSame( 'John', obj.name );\r
+                       assert.areSame( 'Paul', clone.name );\r
+\r
+                       assert.areSame( 'red', obj.cars.Porsche.color );\r
+                       assert.areSame( 'silver', clone.cars.Porsche.color );\r
+               },\r
+\r
+               test_repeat : function()\r
+               {\r
+                       assert.areSame( '&nbsp;&nbsp;&nbsp;', CKEDITOR.tools.repeat( '&nbsp;', 3 ) );\r
+               },\r
+\r
+               name : document.title\r
+       };\r
+})() );\r
+//window.onload = testcase.test_htmlEncode_3874;\r
+       //]]>\r
+       </script>\r
+</head>\r
+<body>\r
+       <iframe></iframe>\r
+</body>\r
+</html>\r