-
Notifications
You must be signed in to change notification settings - Fork 0
/
browsertest.min.js
2 lines (2 loc) · 3.03 KB
/
browsertest.min.js
1
2
import*as m from"../test_unit.js";let o=0,u=0,c=0,r=0;const y=document.getElementById("js_test_results");document.addEventListener("DOMContentLoaded",()=>{if(document.getElementById("NoModuleFound")==null)return;document.getElementById("NoModuleFound").hidden=!0,document.getElementById("testsResultsMeta").hidden=!1;let e=m.TestBrowserJS;if(e===null||e==null||typeof e!="object"||Object.keys(e).length<=0)console.error("TestBrowserJS: The TestBrowserJS object is not properly defined, please see README.",e);else if((e.TestGUIOptions===null||e.TestGUIOptions===void 0||typeof e.TestGUIOptions!="object")&&(e.TestGUIOptions={}),T(e),Array.isArray(e.TestsToRun)&&e.TestsToRun.length>0){a(e.TestsToRun);return}document.getElementById("testsResultsMeta").innerHTML="",document.getElementById("noTestsToRun").hidden=!1});async function a(t){o=Object.entries(t).length;let e=Object.values(t);for(let s=0;s<o;s++){var n={};n.name=e[s].name,n.golden=e[s].golden;try{n.result=await e[s].func()}catch(d){console.error(d),n.result=d}f(n)}g()}async function g(){document.getElementById("totalTestsToRun").innerText=o,document.getElementById("totalTestsRan").innerText=u,document.getElementById("testPastCount").innerText=c,document.getElementById("testFailCount").innerText=r,document.getElementById("testsRunning").hidden=!0,r==0?document.getElementById("testsPassed").hidden=!1:document.getElementById("testsFailed").hidden=!1}function f(t){let e=y.content.cloneNode(!0),n=""+t.name+": ";if(typeof t.golden=="string")var s=t.result.trim()!=t.golden.trim();else s=t.result!=t.golden;s?(console.error("\u274C Failed. Got: "+t.result+" Expected: "+t.golden),n+="\u274C Failed",e.querySelector("div").classList.add("text-danger"),e.querySelector(".result").textContent="Got: "+t.result,e.querySelector(".expected").innerHTML="Expected: "+t.golden,r++):(e.querySelector("div").classList.add("text-success"),n+="\u2705 Passed",c++),u++,e.querySelector(".test").textContent=n,document.getElementById("testsResultsList").append(e)}const l={href:"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css",rel:"stylesheet",integrity:"sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx",crossOrigin:"anonymous"};function T(t){let e=Object.keys(t.TestGUIOptions);if(e.length<=0){i(l);return}e.includes("header")?document.getElementById("CustomHeader").innerHTML=t.TestGUIOptions.header:e.includes("stylesheet")?i(t.TestGUIOptions.stylesheet):i(l),e.includes("footer")&&(document.getElementById("CustomFooter").innerHTML=t.TestGUIOptions.footer),e.includes("main_image")&&(document.getElementById("MainImage").src=t.TestGUIOptions.main_image),e.includes("html_test_area")&&(document.getElementById("htmlTestArea").innerHTML=t.TestGUIOptions.html_test_area)}function i(t){let e=document.getElementById("bootstrapCSS");e.href=t.href;let n=Object.keys(t);n.includes("crossOrigin")?e.crossOrigin=t.crossOrigin:e.crossOrigin=l.crossOrigin,n.includes("integrity")&&(e.integrity=t.integrity),n.includes("rel")?e.rel=t.rel:e.rel=l.rel}export{a as Run};
//# sourceMappingURL=browsertest.min.js.map