-define(['libs/jquery-1.9.1.min', 'libs/chai'], function($, chai) {\r
- return {\r
- cleanUp: function(xml) {\r
- var rmws = function(node) {\r
- if(node.nodeType === 3) {\r
- node.data = $.trim(node.data);\r
- }\r
- else {\r
- $(node).contents().each(function() {\r
- rmws(this);\r
- });\r
- }\r
- }\r
- \r
- xml = $($.trim(xml));\r
- xml.each(function() {\r
- rmws(this);\r
- });\r
- \r
- /*var toret = xml\r
- .replace(/(<.*>)\s*(<.*>)/gm, '$1$2')\r
- .replace(/(<\/.*>)\s*(<\/.*>)/gm, '$1$2')\r
- .replace(/(<\/.*>)\s*(<.*>)/gm, '$1$2');\r
- return $.trim(toret);*/\r
- return $('<div>').append(xml).html();\r
- },\r
- \r
- assertDomEqual: function(lhs, rhs) {\r
- lhs = lhs.clone();\r
- var rhsArr = $.parseHTML(rhs);\r
- if(rhsArr.length === 1) {\r
- rhs = $(rhsArr[0]);\r
- } else {\r
- rhs = $('<div>');\r
- $.each(rhsArr, function(i, el) {\r
- rhs.append(el);\r
- }); \r
- }\r
- if(lhs.length > 1) {\r
- lhs = $('<div>').append(lhs);\r
- }\r
- lhs.attr('id', '');\r
- rhs.attr('id', '');\r
- lhs.find('*').each(function() {$(this).attr('id', '');});\r
- rhs.find('*').each(function() {$(this).attr('id', '');});\r
- return chai.assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');\r
- }\r
- }\r
+define(['libs/jquery-1.9.1.min', 'libs/chai'], function($, chai) {
+ return {
+ cleanUp: function(xml) {
+ var rmws = function(node) {
+ if(node.nodeType === 3) {
+ node.data = $.trim(node.data);
+ }
+ else {
+ $(node).contents().each(function() {
+ rmws(this);
+ });
+ }
+ };
+
+ xml = $($.trim(xml));
+ xml.each(function() {
+ rmws(this);
+ });
+
+ /*var toret = xml
+ .replace(/(<.*>)\s*(<.*>)/gm, '$1$2')
+ .replace(/(<\/.*>)\s*(<\/.*>)/gm, '$1$2')
+ .replace(/(<\/.*>)\s*(<.*>)/gm, '$1$2');
+ return $.trim(toret);*/
+ return $('<div>').append(xml).html();
+ },
+
+ assertDomEqual: function(lhs, rhs) {
+ lhs = lhs.clone();
+ var rhsArr = $.parseHTML(rhs);
+ if(rhsArr.length === 1) {
+ rhs = $(rhsArr[0]);
+ } else {
+ rhs = $('<div>');
+ $.each(rhsArr, function(i, el) {
+ rhs.append(el);
+ });
+ }
+ if(lhs.length > 1) {
+ lhs = $('<div>').append(lhs);
+ }
+ lhs.attr('id', '');
+ rhs.attr('id', '');
+ lhs.find('*').each(function() {$(this).attr('id', '');});
+ rhs.find('*').each(function() {$(this).attr('id', '');});
+ return chai.assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');
+ }
+ };