Some code improvements suggested by linter
[fnpeditor.git] / modules / documentCanvas / tests / canvas.test.js
index d336192..ac3e69a 100644 (file)
@@ -57,10 +57,26 @@ define([
             var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="header">Header 1</div></div>');\r
             var header = c.findNodes({tag: 'header'})[0];\r
             var wrapper = canvasNode.create({tag: 'aside'});\r
             var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="header">Header 1</div></div>');\r
             var header = c.findNodes({tag: 'header'})[0];\r
             var wrapper = canvasNode.create({tag: 'aside'});\r
-            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 6})\r
+            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 6});\r
             assertDomEqual(c.getContent(), '<div wlxml-tag="section"><div wlxml-tag="header">H<span wlxml-tag="aside">eader</span> 1</div></div>');\r
         });\r
         \r
             assertDomEqual(c.getContent(), '<div wlxml-tag="section"><div wlxml-tag="header">H<span wlxml-tag="aside">eader</span> 1</div></div>');\r
         });\r
         \r
+        test('wrap text in node - text not a first node', function() {\r
+            var c = canvas.create('<div wlxml-tag="header">Alice <span wlxml-tag="span">has a</span> cat</div>');\r
+            var header = c.findNodes({tag: 'header'})[0];\r
+            var wrapper = canvasNode.create({tag: 'aside'});\r
+            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 4, textNodeIdx: 2});\r
+            assertDomEqual(c.getContent(), '<div wlxml-tag="header">Alice <span wlxml-tag="span">has a</span> <span wlxml-tag="aside">cat</span></div>');\r
+        });\r
+        \r
+        test('wrap text with nodes inside', function() {\r
+            var c = canvas.create('<div wlxml-tag="header">Alice has a <span wlxml-tag="span">small</span> cat</div>');\r
+            var header = c.findNodes({tag: 'header'})[0];\r
+            var wrapper = canvasNode.create({tag: 'aside'});\r
+            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 6, offsetEnd: 4, textNodeIdx: [0,2]});\r
+            assertDomEqual(c.getContent(), '<div wlxml-tag="header">Alice <span wlxml-tag="aside">has a <span wlxml-tag="span">small</span> cat</span></div>');            \r
+        });\r
+        \r
         test('split node', function() {\r
             var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="header">Header 1</div></div>');\r
             var header = c.findNodes({tag: 'header'})[0];\r
         test('split node', function() {\r
             var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="header">Header 1</div></div>');\r
             var header = c.findNodes({tag: 'header'})[0];\r