X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FUtil.js;h=08cc88ad598498a0edfcc16548d8190275c7cdad;hb=7ff98630ca7cc2760e2115ad2372053184d3e717;hp=3eb59e3db6c1351431ccb967d5e4ce280caaf794;hpb=901b2ebbe25c116c93550cfca91b0704d751d997;p=dygraphs.git diff --git a/auto_tests/tests/Util.js b/auto_tests/tests/Util.js index 3eb59e3..08cc88a 100644 --- a/auto_tests/tests/Util.js +++ b/auto_tests/tests/Util.js @@ -58,26 +58,13 @@ Util.getLegend = function(parent) { }; /** - * Assert that all the elements in 'parent' with class 'className' is - * the expected font size. + * Assert that all elements have a certain style property. */ -Util.assertFontSizes = function(parent, className, expectedSize) { - var expectedSizePx = expectedSize + "px"; - var labels = parent.getElementsByClassName(className); - assertTrue(labels.length > 0); - - // window.getComputedStyle is apparently compatible with all browsers - // (IE first became compatible with IE9.) - // If this test fails on earlier browsers, then enable something like this, - // because the font size is set by the parent div. - // if (!window.getComputedStyle) { - // fontSize = label.parentElement.style.fontSize; - // } - for (var idx = 0; idx < labels.length; idx++) { - var label = labels[idx]; - var fontSize = window.getComputedStyle(label).fontSize; - assertEquals(expectedSizePx, fontSize); - } +Util.assertStyleOfChildren = function(selector, property, expectedValue) { + assertTrue(selector.length > 0); + $.each(selector, function(idx, child) { + assertEquals(expectedValue, $(child).css(property)); + }); };