X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FUtil.js;h=8937e43920a270718485010ceab02395e4326afc;hb=65129ba82d4efe12714be88fa3c792149c00ca10;hp=3436c152ac4998d2168cf2e6c3109f7d2c21be63;hpb=89fdcedbda6906d90e15d84285c4f6c0b8d96d28;p=dygraphs.git diff --git a/auto_tests/tests/Util.js b/auto_tests/tests/Util.js index 3436c15..8937e43 100644 --- a/auto_tests/tests/Util.js +++ b/auto_tests/tests/Util.js @@ -51,11 +51,16 @@ Util.getClassTexts = function(css_class, parent) { return texts; }; +// Convert   to a normal space +Util.nbspToSpace = function(str) { + var re = new RegExp(String.fromCharCode(160), 'g'); + return str.replace(re, ' '); +}; + Util.getLegend = function(parent) { parent = parent || document; var legend = parent.getElementsByClassName("dygraph-legend")[0]; - var re = new RegExp(String.fromCharCode(160), 'g'); - return legend.textContent.replace(re, ' '); + return Util.nbspToSpace(legend.textContent); }; /** @@ -63,9 +68,10 @@ Util.getLegend = function(parent) { */ Util.assertStyleOfChildren = function(selector, property, expectedValue) { assert.isTrue(selector.length > 0); - $.each(selector, function(idx, child) { - assert.isEqual(expectedValue, $(child).css(property)); - }); + for (var idx = 0; idx < selector.length; idx++) { + var child = selector[idx]; + assert.equal(expectedValue, window.getComputedStyle(child)[property]); + } };