diff --git a/tests/testaudience.js b/tests/testaudience.js index a600ac2..b0f62fc 100644 --- a/tests/testaudience.js +++ b/tests/testaudience.js @@ -1,6 +1,10 @@ /** - * @fileoverview Defines tests for audience engagement. - * + * @fileoverview Defines test for Audience engagement. + * Success criteria: + * - Elements with ID prefix 'audience-engagement-‘ should exist; + * - Elements with ID prefix 'audience-engagement-‘ should contain content + * equal 'N/A' or '-' or one of following string: '10.1%', '10%', + * '10:1', '10'; * @see http://google.github.io/styleguide/javascriptguide.xml * @see http://developers.google.com/closure/compiler/docs/js-for-compiler */ @@ -13,6 +17,7 @@ * @return {boolean} Returns "true" if test failed. */ function testAudience() { + // Elements with ID prefix 'audience-engagement-‘ should exist. /** @type {!Array.} */ var nodes = [ 'audience-engagement-visitors-value', 'audience-engagement-pageviews-value', @@ -25,6 +30,7 @@ function testAudience() { 'audience-engagement-bounce-rate-delta' ]; /** @type {number} */ var length = nodes.length; + /** @type {boolean} */ var result = false; /** @type {Element} */ var element; /** @type {string} */ var content; @@ -32,11 +38,16 @@ function testAudience() { element = document.getElementById(nodes[--length]); content = element && element.textContent.trim(); - if (!content || !(PATTERN.test(content) || 'N/A' == content)) { - return true; + // Elements with ID prefix 'audience-engagement-‘ should contain + // content equal 'N/A' or '-' or one of following string: '10.1%', '10%', + // '10:1', '10'. + if (!(content && (PATTERN.test(content) || 'N/A' == content || + '-' == content))) { + result = true; + break; } } - return false; + return result; } diff --git a/tests/testmediaqueries.js b/tests/testmediaqueries.js index d729d2b..8aad35a 100644 --- a/tests/testmediaqueries.js +++ b/tests/testmediaqueries.js @@ -1,11 +1,12 @@ /** * @fileoverview Defines test for Media Queries widget. - * Success criterias: + * Success criteria: * - Element with ID 'media-widget' should exist; * - Element with ID 'media-widget' should contain element * with ID 'media-data-table'; * - If element with ID 'media-widget' is not empty it shouldn't contain - * element with CSS classes '.rule.media-none' and rows in element with ID + * element with CSS classes '.rule.media-none' + * - If element with ID 'media-widget' is not empty rows in element with ID * 'media-data-table' should start with text string '@media'; * - If element with ID 'media-widget' is empty it should contain element with * CSS classes '.rule.media-none'. @@ -27,8 +28,8 @@ function testMediaQueries() { // Element with ID 'media-widget' should exist. /** @type {Element} */ var element = document.getElementById(WIDGET_ID); - // Element with ID 'media-widget' should contain element - // with ID 'media-data-table'. + // Element with ID 'media-widget' should contain element with + // ID 'media-data-table'. /** @type {Element} */ var table = document.getElementById(TABLE_ID); // If element with ID 'media-widget' is not empty it shouldn't contain