JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0
[ckeditor.git] / _source / tests / core / dom / text.html
diff --git a/_source/tests/core/dom/text.html b/_source/tests/core/dom/text.html
new file mode 100644 (file)
index 0000000..a3053f5
--- /dev/null
@@ -0,0 +1,128 @@
+<!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.dom.text</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
+\r
+var tc;\r
+CKEDITOR.test.addTestCase( tc = (function()\r
+{\r
+       // Local reference to the "assert" object.\r
+       var assert = CKEDITOR.test.assert;\r
+\r
+       return {\r
+\r
+               test_substring1 : function()\r
+               {\r
+                       var text = new CKEDITOR.dom.text( '0123456789' );\r
+\r
+                       assert.areSame( '123', text.substring( 1, 4 ) );\r
+               },\r
+\r
+               test_substring2 : function()\r
+               {\r
+                       var text = new CKEDITOR.dom.text( '0123456789' );\r
+\r
+                       assert.areSame( '56789', text.substring( 5 ) );\r
+               },\r
+\r
+               test_substring3 : function()\r
+               {\r
+                       var text = new CKEDITOR.dom.text( '0123456789' );\r
+\r
+                       assert.areSame( '', text.substring( 1,1 ) );\r
+               },\r
+\r
+               test_substring4 : function()\r
+               {\r
+                       var text = new CKEDITOR.dom.text( '0123456789' );\r
+\r
+                       assert.areSame( '012', text.substring( -10,3 ) );\r
+               },\r
+\r
+               test_substring5 : function()\r
+               {\r
+                       var text = new CKEDITOR.dom.text( '0123456789' );\r
+\r
+                       assert.areSame( '89', text.substring( 8,100 ) );\r
+               },\r
+\r
+               test_substring6 : function()\r
+               {\r
+                       var text = new CKEDITOR.dom.text( '0123456789' );\r
+\r
+                       assert.areSame( '234', text.substring( 5,2 ) );\r
+               },\r
+\r
+               test_split1 : function()\r
+               {\r
+                       var div = CKEDITOR.document.getById( 'playground' );\r
+                       div.setHtml( '01234' );\r
+\r
+                       var text = div.getFirst(),\r
+                               next = text.split( 3 );\r
+\r
+                       assert.areSame( '012', text.getText(), 'text.getText() is wrong' );\r
+                       assert.areSame( '34', next.getText(), 'next.getText() is wrong' );\r
+\r
+                       assert.areSame( div.$, next.$.parentNode, 'parentNode is wrong' );\r
+                       assert.areSame( text.$, next.$.previousSibling, 'sibling is wrong' );\r
+               },\r
+\r
+               test_split2 : function()\r
+               {\r
+                       var div = CKEDITOR.document.getById( 'playground' );\r
+                       div.setHtml( '01234' );\r
+\r
+                       var text = div.getFirst(),\r
+                               next = text.split( 5 );\r
+\r
+                       assert.areSame( '01234', text.getText(), 'text.getText() is wrong' );\r
+                       assert.areSame( '', next.getText(), 'next.getText() is wrong' );\r
+\r
+                       assert.areSame( div.$, next.$.parentNode, 'parentNode is wrong' );\r
+                       assert.areSame( text.$, next.$.previousSibling, 'sibling is wrong' );\r
+               },\r
+\r
+               test_split3 : function()\r
+               {\r
+                       var div = CKEDITOR.document.getById( 'playground' );\r
+                       div.setHtml( '01234' );\r
+\r
+                       var text = div.getFirst(),\r
+                               next = text.split( 0 );\r
+\r
+                       assert.areSame( '', text.getText(), 'text.getText() is wrong' );\r
+                       assert.areSame( '01234', next.getText(), 'next.getText() is wrong' );\r
+\r
+                       assert.areSame( div.$, next.$.parentNode, 'parentNode is wrong' );\r
+                       assert.areSame( text.$, next.$.previousSibling, 'sibling is wrong' );\r
+               },\r
+\r
+               test_split_3436 : function()\r
+               {\r
+                       var parent = CKEDITOR.document.getById( 'playground2' );\r
+                       parent.setHtml( 'A B <b>C </b>D E' );\r
+                       parent.getFirst().split( 2 );   // Right before "B"\r
+                       parent.getChildren().getItem( 3 ).split( 2 );   // Right before "E"\r
+                       assert.areSame( 5, parent.getChildren().count(), 'Child nodes num doesn\'t match after split' );\r
+               },\r
+\r
+               name : document.title\r
+       };\r
+})() );\r
+\r
+//window.onload = tc.test_split_3436;\r
+\r
+       //]]>\r
+       </script>\r
+</head>\r
+<body>\r
+       <p id="playground"></p>\r
+       <p id="playground2"></p>\r
+</body>\r
+</html>\r