X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FUtil.js;h=08cc88ad598498a0edfcc16548d8190275c7cdad;hb=7ff98630ca7cc2760e2115ad2372053184d3e717;hp=7fca030a765695cc4470b528f38c4f9766d85556;hpb=846038aad4815feec55d2e86b8ccfad7dc1019b6;p=dygraphs.git diff --git a/auto_tests/tests/Util.js b/auto_tests/tests/Util.js index 7fca030..08cc88a 100644 --- a/auto_tests/tests/Util.js +++ b/auto_tests/tests/Util.js @@ -19,7 +19,7 @@ Util.getYLabels = function(axis_num, parent) { ary.push(y_labels[i].innerHTML); } return ary; -} +}; /** * Get the x-labels for a given axis. @@ -34,7 +34,7 @@ Util.getXLabels = function(parent) { ary.push(x_labels[i].innerHTML); } return ary; -} +}; /** * Returns all text in tags w/ a given css class, sorted. @@ -49,11 +49,32 @@ Util.getClassTexts = function(css_class, parent) { } texts.sort(); return texts; -} +}; Util.getLegend = function(parent) { parent = parent || document; var legend = parent.getElementsByClassName("dygraph-legend")[0]; return legend.textContent; -} +}; +/** + * Assert that all elements have a certain style property. + */ +Util.assertStyleOfChildren = function(selector, property, expectedValue) { + assertTrue(selector.length > 0); + $.each(selector, function(idx, child) { + assertEquals(expectedValue, $(child).css(property)); + }); +}; + + +/** + * Takes in an array of strings and returns an array of floats. + */ +Util.makeNumbers = function(ary) { + var ret = []; + for (var i = 0; i < ary.length; i++) { + ret.push(parseFloat(ary[i])); + } + return ret; +};