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,OAAO,IAAI,mCAAmC,CAAC,CAAC;KAChE;;;;;;;;WAOO,kBAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE;AACtC,UAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACjD,UAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EACxB,MAAM,CAAC,MAAM,CAAC,CAAC,KAEf,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC1C;;;;;WAGK,gBAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC9B,UAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzC,UAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EACxB,MAAM,CAAC,MAAM,CAAC,CAAC,KAEf,WAAW,CAAC,MAAM,EAAE,QAAQ,EAChB,OAAO,yBAAuB,IAAI,4BAAuB,QAAQ,kBAAa,MAAM,MAAG,CAAC,CAAC;KACxG;;;SAhOoB,MAAM;IAkO5B,CAAC","file":"assert.js","sourcesContent":["// Browser assertions convenience.\n\nconst assert = require('assert');\nconst { isRegExp } = require('util');\nconst URL = require('url');\nconst Utils = require('jsdom/lib/jsdom/utils');\n\n\n// Used to assert that actual matches expected value, where expected may be a function or a string.\nfunction assertMatch(actual, expected, message) {\n if (isRegExp(expected))\n assert(expected.test(actual), message || `Expected \"${actual}\" to match \"${expected}\"`);\n else if (typeof expected === 'function')\n assert(expected(actual), message);\n else\n assert.deepEqual(actual, expected, message);\n}\n\n\nmodule.exports = class Assert {\n\n constructor(browser) {\n this.browser = browser;\n }\n\n\n // -- Location/response --\n\n // Asserts that a cookie with the given name has the expected value.\n //\n // identifier - Cookie name or name/domain/path (see getCookie)\n // expected - Expected value (null to test cookie is not set)\n // message - Assert message if cookie does not have expected value\n cookie(identifier, expected = null, message = null) {\n const actual = this.browser.getCookie(identifier);\n assertMatch(actual, expected,\n message || `Expected cookie ${JSON.stringify(identifier)} to have the value \"${expected}\", found \"${actual}\"`);\n }\n\n // Asserts that browser was redirected when retrieving the current page.\n redirected(message) {\n assert(this.browser.redirected, message);\n }\n\n // Assert that the last page load returned the expected status code.\n status(code, message) {\n assert.equal(this.browser.status, code, message);\n }\n\n // Assert that the last page load returned status code 200.\n success(message) {\n assert(this.browser.success, message);\n }\n\n // Asserts that current page has the expected URL.\n //\n // Expected value can be a String, RegExp, Function or an object, in which case\n // object properties are tested against the actual URL (e.g. pathname, host,\n // query).\n url(expected, message) {\n if (typeof expected === 'string') {\n const absolute = Utils.resolveHref(this.browser.location.href, expected);\n assertMatch(this.browser.location.href, absolute, message);\n } else if (isRegExp(expected) || typeof expected === 'function')\n assertMatch(this.browser.location.href, expected, message);\n else {\n const url = URL.parse(this.browser.location.href, true);\n for (let key in expected) {\n let value = expected[key];\n // Gracefully handle default values, e.g. document.location.hash for\n // \"/foo\" is \"\" not null, not undefined.\n let defaultValue = (key === 'port') ? 80 : null;\n assertMatch(url[key] || defaultValue, value || defaultValue, message);\n }\n }\n }\n\n\n // -- Document contents --\n\n // Assert the named attribute of the selected element(s) has the expected value.\n attribute(selector, name, expected = null, message = null) {\n const elements = this.browser.queryAll(selector);\n assert(elements.length, `Expected selector \"${selector}\" to return one or more elements`);\n for (let element of elements) {\n let actual = element.getAttribute(name);\n assertMatch(actual, expected, message);\n }\n }\n\n // Assert that element matching selector exists.\n element(selector, message) {\n this.elements(selector, { exactly: 1 }, message);\n }\n\n // Assert how many elements matching selector exist.\n //\n // Count can be an exact number, or an object with the properties:\n // atLeast - Expect to find at least that many elements\n // atMost - Expect to find at most that many elements\n // exactly - Expect to find exactly that many elements\n //\n // If count is unspecified, defaults to at least one.\n elements(selector, count, message) {\n const elements = this.browser.queryAll(selector);\n if (arguments.length === 1)\n this.elements(selector, { atLeast: 1});\n else if (Number.isInteger(count))\n this.elements(selector, { exactly: count }, message);\n else {\n if (Number.isInteger(count.exactly))\n assert.equal(elements.length, count.exactly,\n message || `Expected ${count.exactly} elements matching \"${selector}\", found ${elements.length}`);\n if (Number.isInteger(count.atLeast))\n assert(elements.length >= count.atLeast,\n message || `Expected at least ${count.atLeast} elements matching \"${selector}\", found only ${elements.length}`);\n if (Number.isInteger(count.atMost))\n assert(elements.length <= count.atMost,\n message || `Expected at most ${count.atMost} elements matching \"${selector}\", found ${elements.length}`);\n }\n }\n\n // Asserts the selected element(s) has the expected CSS class.\n hasClass(selector, expected, message) {\n const elements = this.browser.queryAll(selector);\n assert(elements.length, `Expected selector \"${selector}\" to return one or more elements`);\n for (let element of elements) {\n let classNames = element.className.split(/\\s+/);\n assert(~classNames.indexOf(expected),\n message || `Expected element \"${selector}\" to have class \"${expected}\", found \"${classNames.join(', ')}\"`);\n }\n }\n\n // Asserts the selected element(s) doest not have the expected CSS class.\n hasNoClass(selector, expected, message) {\n const elements = this.browser.queryAll(selector);\n assert(elements.length, `Expected selector \"${selector}\" to return one or more elements`);\n for (let element of elements) {\n let classNames = element.className.split(/\\s+/);\n assert(classNames.indexOf(expected) === -1,\n message || `Expected element \"${selector}\" to not have class \"${expected}\", found \"${classNames.join(', ')}\"`);\n }\n }\n\n // Asserts the selected element(s) has the expected class names.\n className(selector, expected, message) {\n const elements = this.browser.queryAll(selector);\n assert(elements.length, `Expected selector \"${selector}\" to return one or more elements`);\n const array = expected.split(/\\s+/).sort().join(' ');\n for (let element of elements) {\n let actual = element.className.split(/\\s+/).sort().join(' ');\n assertMatch(actual, array,\n message || `Expected element \"${selector}\" to have class \"${expected}\", found \"${actual}\"`);\n }\n }\n\n // Asserts the selected element(s) has the expected value for the named style\n // property.\n style(selector, style, expected = null, message = null) {\n const elements = this.browser.queryAll(selector);\n assert(elements.length, `Expected selector \"${selector}\" to return one or more elements`);\n for (let element of elements) {\n let actual = element.style.getPropertyValue(style);\n assertMatch(actual, expected,\n message || `Expected element \"${selector}\" to have style ${style} value of \"${expected}\", found \"${actual}\"`);\n }\n }\n\n // Asserts that selected input field (text field, text area, etc) has the expected value.\n input(selector, expected = null, message = null) {\n const elements = this.browser.queryAll(selector);\n assert(elements.length, `Expected selector \"${selector}\" to return one or more elements`);\n for (let element of elements)\n assertMatch(element.value, expected, message);\n }\n\n // Asserts that a link exists with the given text and URL.\n link(selector, text, url, message) {\n const elements = this.browser.queryAll(selector);\n assert(elements.length, message || `Expected selector \"${selector}\" to return one or more elements`);\n const matchingText = elements.filter(element => element.textContent.trim() === text);\n if (isRegExp(url)) {\n const matchedRegexp = matchingText.filter(element => url.test(element.href));\n assert(matchedRegexp.length, message || `Expected at least one link matching the given text and URL`);\n } else {\n const absolute = Utils.resolveHref(this.browser.location.href, url);\n const matchedURL = matchingText.filter(element => element.href === absolute);\n assert(matchedURL.length, message || `Expected at least one link matching the given text and URL`);\n }\n }\n\n\n // Assert that text content of selected element(s) matches expected string.\n //\n // You can also call this with a regular expression, or a function.\n text(selector, expected, message) {\n const elements = this.browser.queryAll(selector);\n assert(elements.length, `Expected selector \"${selector}\" to return one or more elements`);\n const actual = elements\n .map(elem => elem.textContent)\n .join('')\n .trim()\n .replace(/\\s+/g, ' ');\n assertMatch(actual, expected || '', message);\n }\n\n\n // -- Window --\n\n // Asserts that selected element has the focus.\n hasFocus(selector, message) {\n if (selector) {\n const elements = this.browser.queryAll(selector);\n assert.equal(elements.length, 1,\n message || `Expected selector \"${selector}\" to return one element`);\n assert.equal(this.browser.activeElement, elements[0],\n message || `Expected element \"${selector}\" to have the focus'`);\n } else\n assert.equal(this.browser.activeElement, this.browser.body,\n message || 'Expected no element to have focus');\n }\n\n\n // -- JavaScript --\n\n // Evaluates Javascript expression and asserts value. With one argument,\n // asserts that the expression evaluates to (JS) true.\n evaluate(expression, expected, message) {\n const actual = this.browser.evaluate(expression);\n if (arguments.length === 1)\n assert(actual);\n else\n assertMatch(actual, expected, message);\n }\n\n // Asserts that the global (window) property name has the expected value.\n global(name, expected, message) {\n const actual = this.browser.window[name];\n if (arguments.length === 1)\n assert(actual);\n else\n assertMatch(actual, expected,\n message || `Expected global ${name} to have the value \"${expected}\", found \"${actual}\"`);\n }\n\n};\n\n"]}