X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/c986f6ebfd3d20bdc75ce00ee09bd2c716e0cb16..0fbb8e87c499516530c1d6ce54b1bd7ebc845c7b:/modules/documentCanvas/tests/utils.js diff --git a/modules/documentCanvas/tests/utils.js b/modules/documentCanvas/tests/utils.js index cf1f7c2..fcb9853 100644 --- a/modules/documentCanvas/tests/utils.js +++ b/modules/documentCanvas/tests/utils.js @@ -1,49 +1,49 @@ -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 $('
').append(xml).html(); - }, - - assertDomEqual: function(lhs, rhs) { - lhs = lhs.clone(); - var rhsArr = $.parseHTML(rhs); - if(rhsArr.length === 1) { - rhs = $(rhsArr[0]); - } else { - rhs = $('
'); - $.each(rhsArr, function(i, el) { - rhs.append(el); - }); - } - if(lhs.length > 1) { - lhs = $('
').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'); - } - } +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 $('
').append(xml).html(); + }, + + assertDomEqual: function(lhs, rhs) { + lhs = lhs.clone(); + var rhsArr = $.parseHTML(rhs); + if(rhsArr.length === 1) { + rhs = $(rhsArr[0]); + } else { + rhs = $('
'); + $.each(rhsArr, function(i, el) { + rhs.append(el); + }); + } + if(lhs.length > 1) { + lhs = $('
').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'); + } + }; }); \ No newline at end of file