@magnit-ce/code-tests 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-tests.cjs +21 -2
- package/dist/code-tests.d.cts +1 -1
- package/dist/code-tests.d.ts +1 -1
- package/dist/code-tests.js +21 -2
- package/dist/code-tests.min.js +10 -10
- package/package.json +1 -1
package/dist/code-tests.cjs
CHANGED
|
@@ -526,13 +526,16 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
526
526
|
this.#boundClickHandler = this.#onClick.bind(this);
|
|
527
527
|
}
|
|
528
528
|
connectedCallback() {
|
|
529
|
+
assignClassAndIdToPart(this.shadowRoot);
|
|
529
530
|
this.addEventListener("click", this.#boundClickHandler);
|
|
531
|
+
if (this.getAttribute("auto") == "false") {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
530
534
|
const testsPath = this.getAttribute("src") ?? this.getAttribute("test") ?? this.getAttribute("tests") ?? this.getAttribute("run") ?? this.getAttribute("path");
|
|
531
535
|
if (testsPath == null) {
|
|
532
536
|
return;
|
|
533
537
|
}
|
|
534
538
|
this.loadTests(testsPath);
|
|
535
|
-
assignClassAndIdToPart(this.shadowRoot);
|
|
536
539
|
}
|
|
537
540
|
disconnectedCallback() {
|
|
538
541
|
this.removeEventListener("click", this.#boundClickHandler);
|
|
@@ -561,7 +564,14 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
561
564
|
}
|
|
562
565
|
this.#runTest(testId, test);
|
|
563
566
|
}
|
|
564
|
-
|
|
567
|
+
#getCurrentTestsPath() {
|
|
568
|
+
return this.getAttribute("src") ?? this.getAttribute("test") ?? this.getAttribute("tests") ?? this.getAttribute("run") ?? this.getAttribute("path");
|
|
569
|
+
}
|
|
570
|
+
async loadTests(testsPath) {
|
|
571
|
+
const path = testsPath ?? this.#getCurrentTestsPath();
|
|
572
|
+
if (path == null) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
565
575
|
try {
|
|
566
576
|
this.getElement("tests").innerHTML = "";
|
|
567
577
|
this.#tests.clear();
|
|
@@ -686,6 +696,9 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
686
696
|
this.#handleHookResult(hookResult, false, "before", error);
|
|
687
697
|
console.error(error);
|
|
688
698
|
this.#continueRunningTests = false;
|
|
699
|
+
this.classList.remove("running");
|
|
700
|
+
this.part.remove("running");
|
|
701
|
+
this.dispatchEvent(new CustomEvent("afterall" /* AfterAll */, { bubbles: true, composed: true }));
|
|
689
702
|
return;
|
|
690
703
|
}
|
|
691
704
|
}
|
|
@@ -704,6 +717,9 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
704
717
|
}
|
|
705
718
|
}
|
|
706
719
|
if (this.#continueRunningTests == false) {
|
|
720
|
+
this.classList.remove("running");
|
|
721
|
+
this.part.remove("running");
|
|
722
|
+
this.dispatchEvent(new CustomEvent("afterall" /* AfterAll */, { bubbles: true, composed: true }));
|
|
707
723
|
return;
|
|
708
724
|
}
|
|
709
725
|
const afterHooks = this.#hooks.get(AFTERALL);
|
|
@@ -723,6 +739,9 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
723
739
|
this.#handleHookResult(hookResult, false, "after", error);
|
|
724
740
|
console.error(error);
|
|
725
741
|
this.#continueRunningTests = false;
|
|
742
|
+
this.classList.remove("running");
|
|
743
|
+
this.part.remove("running");
|
|
744
|
+
this.dispatchEvent(new CustomEvent("afterall" /* AfterAll */, { bubbles: true, composed: true }));
|
|
726
745
|
return;
|
|
727
746
|
}
|
|
728
747
|
}
|
package/dist/code-tests.d.cts
CHANGED
|
@@ -32,7 +32,7 @@ declare class CodeTestsElement extends HTMLElement {
|
|
|
32
32
|
constructor();
|
|
33
33
|
connectedCallback(): void;
|
|
34
34
|
disconnectedCallback(): void;
|
|
35
|
-
loadTests(
|
|
35
|
+
loadTests(testsPath?: string): Promise<void>;
|
|
36
36
|
runTests(): Promise<void>;
|
|
37
37
|
static create(properties: CodeTestsProperties): HTMLElement;
|
|
38
38
|
static observedAttributes: string[];
|
package/dist/code-tests.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare class CodeTestsElement extends HTMLElement {
|
|
|
32
32
|
constructor();
|
|
33
33
|
connectedCallback(): void;
|
|
34
34
|
disconnectedCallback(): void;
|
|
35
|
-
loadTests(
|
|
35
|
+
loadTests(testsPath?: string): Promise<void>;
|
|
36
36
|
runTests(): Promise<void>;
|
|
37
37
|
static create(properties: CodeTestsProperties): HTMLElement;
|
|
38
38
|
static observedAttributes: string[];
|
package/dist/code-tests.js
CHANGED
|
@@ -493,13 +493,16 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
493
493
|
this.#boundClickHandler = this.#onClick.bind(this);
|
|
494
494
|
}
|
|
495
495
|
connectedCallback() {
|
|
496
|
+
assignClassAndIdToPart(this.shadowRoot);
|
|
496
497
|
this.addEventListener("click", this.#boundClickHandler);
|
|
498
|
+
if (this.getAttribute("auto") == "false") {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
497
501
|
const testsPath = this.getAttribute("src") ?? this.getAttribute("test") ?? this.getAttribute("tests") ?? this.getAttribute("run") ?? this.getAttribute("path");
|
|
498
502
|
if (testsPath == null) {
|
|
499
503
|
return;
|
|
500
504
|
}
|
|
501
505
|
this.loadTests(testsPath);
|
|
502
|
-
assignClassAndIdToPart(this.shadowRoot);
|
|
503
506
|
}
|
|
504
507
|
disconnectedCallback() {
|
|
505
508
|
this.removeEventListener("click", this.#boundClickHandler);
|
|
@@ -528,7 +531,14 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
528
531
|
}
|
|
529
532
|
this.#runTest(testId, test);
|
|
530
533
|
}
|
|
531
|
-
|
|
534
|
+
#getCurrentTestsPath() {
|
|
535
|
+
return this.getAttribute("src") ?? this.getAttribute("test") ?? this.getAttribute("tests") ?? this.getAttribute("run") ?? this.getAttribute("path");
|
|
536
|
+
}
|
|
537
|
+
async loadTests(testsPath) {
|
|
538
|
+
const path = testsPath ?? this.#getCurrentTestsPath();
|
|
539
|
+
if (path == null) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
532
542
|
try {
|
|
533
543
|
this.getElement("tests").innerHTML = "";
|
|
534
544
|
this.#tests.clear();
|
|
@@ -653,6 +663,9 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
653
663
|
this.#handleHookResult(hookResult, false, "before", error);
|
|
654
664
|
console.error(error);
|
|
655
665
|
this.#continueRunningTests = false;
|
|
666
|
+
this.classList.remove("running");
|
|
667
|
+
this.part.remove("running");
|
|
668
|
+
this.dispatchEvent(new CustomEvent("afterall" /* AfterAll */, { bubbles: true, composed: true }));
|
|
656
669
|
return;
|
|
657
670
|
}
|
|
658
671
|
}
|
|
@@ -671,6 +684,9 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
671
684
|
}
|
|
672
685
|
}
|
|
673
686
|
if (this.#continueRunningTests == false) {
|
|
687
|
+
this.classList.remove("running");
|
|
688
|
+
this.part.remove("running");
|
|
689
|
+
this.dispatchEvent(new CustomEvent("afterall" /* AfterAll */, { bubbles: true, composed: true }));
|
|
674
690
|
return;
|
|
675
691
|
}
|
|
676
692
|
const afterHooks = this.#hooks.get(AFTERALL);
|
|
@@ -690,6 +706,9 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
690
706
|
this.#handleHookResult(hookResult, false, "after", error);
|
|
691
707
|
console.error(error);
|
|
692
708
|
this.#continueRunningTests = false;
|
|
709
|
+
this.classList.remove("running");
|
|
710
|
+
this.part.remove("running");
|
|
711
|
+
this.dispatchEvent(new CustomEvent("afterall" /* AfterAll */, { bubbles: true, composed: true }));
|
|
693
712
|
return;
|
|
694
713
|
}
|
|
695
714
|
}
|
package/dist/code-tests.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var H=`:host
|
|
2
2
|
{
|
|
3
3
|
/*** gray ***/
|
|
4
4
|
--uchu-light-gray-raw: 95.57% 0.003 286.35;
|
|
@@ -356,7 +356,7 @@ pre
|
|
|
356
356
|
{
|
|
357
357
|
from { transform: rotate(0deg); }
|
|
358
358
|
to { transform: rotate(360deg); }
|
|
359
|
-
}`;var
|
|
359
|
+
}`;var F=`<slot name="header">
|
|
360
360
|
<header id="header">
|
|
361
361
|
<span id="title"><slot name="title"><span id="title-text">Tests</span></slot></span>
|
|
362
362
|
<slot name="play-button">
|
|
@@ -385,13 +385,13 @@ pre
|
|
|
385
385
|
<div id="after-all-results" class="results"></div>
|
|
386
386
|
</details>`;var T=class extends Promise{async toBeDefined(t){if(await this==null)throw new Error(`${t??"Value"} is undefined`)}async toBe(t,s=!1){let e=await this;if((s==!0?e===t:e==t)==!1)throw new Error(` Value is not equal.
|
|
387
387
|
Expected: ${t}
|
|
388
|
-
Result: ${e}`)}async toContainText(t){let s=await this}async toHaveAttribute(t){let s=await this;if(!(s instanceof HTMLElement))throw new Error("Unable to check for attribute on non-HTMLElement target");if(s.getAttribute(t))throw new Error("Taret does not have attribute")}},y=Symbol("beforeAll"),v=Symbol("beforeEach"),k=Symbol("afterAll"),x=Symbol("afterEach"),
|
|
389
|
-
${
|
|
390
|
-
${
|
|
388
|
+
Result: ${e}`)}async toContainText(t){let s=await this}async toHaveAttribute(t){let s=await this;if(!(s instanceof HTMLElement))throw new Error("Unable to check for attribute on non-HTMLElement target");if(s.getAttribute(t))throw new Error("Taret does not have attribute")}},y=Symbol("beforeAll"),v=Symbol("beforeEach"),k=Symbol("afterAll"),x=Symbol("afterEach"),M=class{static timeoutMS=500;static#e;static#p;static expect(t){return new T(async(e,a)=>{if(t instanceof Promise){let r=await t;e(r);return}e(t)})}static expectSync(t){return new T(async(e,a)=>{if(t instanceof Promise){let r=await t;e(r);return}e(t)})}static expectBefore(t){return new T(async(e,a)=>{if(t instanceof Promise){let r=await t;e(r);return}e(t)})}};function j(h){return M.expect(h)}var $=":not(slot,defs,g,rect,path,circle,ellipse,line,polygon,text,tspan,use,svg image,svg title,desc,template,template *)";function D(h){let t=[...h.querySelectorAll(`${$}[id]`)];for(let e=0;e<t.length;e++)t[e].part.add(t[e].id);let s=[...h.querySelectorAll(`${$}[class]`)];for(let e=0;e<s.length;e++)s[e].part.add(...s[e].classList)}var z=(a=>(a.BeforeAll="beforeall",a.AfterAll="afterall",a.BeforeTest="beforetest",a.AfterTest="aftertest",a))(z||{}),R=Symbol("No Test Defined"),B=new CSSStyleSheet;B.replaceSync(H);var P="code-tests",S=class extends HTMLElement{componentParts=new Map;getElement(t){if(this.componentParts.get(t)==null){let s=this.findElement(t);s!=null&&this.componentParts.set(t,s)}return this.componentParts.get(t)}findElement(t){return this.shadowRoot.getElementById(t)}#e=new Map;#p={[y]:L(),[v]:L(),[x]:L(),[k]:L()};#t=!0;constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=F,this.shadowRoot.adoptedStyleSheets.push(B),this.#c=this.#h.bind(this)}connectedCallback(){if(D(this.shadowRoot),this.addEventListener("click",this.#c),this.getAttribute("auto")=="false")return;let t=this.getAttribute("src")??this.getAttribute("test")??this.getAttribute("tests")??this.getAttribute("run")??this.getAttribute("path");t!=null&&this.loadTests(t)}disconnectedCallback(){this.removeEventListener("click",this.#c)}#c;#h(t){let s=t.composedPath().find(n=>n instanceof HTMLButtonElement&&n.classList.contains("run"));if(s==null)return;let e=s.closest("li");if(e==null){s.hasAttribute("data-all")==!0&&this.runTests();return}let a=e.dataset.testId;if(a==null)return;let r=this.#s.get(a);r!=null&&this.#u(a,r)}#f(){return this.getAttribute("src")??this.getAttribute("test")??this.getAttribute("tests")??this.getAttribute("run")??this.getAttribute("path")}async loadTests(t){let s=t??this.#f();if(s!=null)try{this.getElement("tests").innerHTML="",this.#s.clear(),this.classList.remove("has-before-hook"),this.classList.remove("has-after-hook");let e=window.location.href.lastIndexOf("/"),r=window.location.href.substring(e).indexOf(".")!=-1==!0?window.location.href.substring(0,e+1):window.location.href,n=r+s.substring(0,s.lastIndexOf("/")+1),o=r+s,l=await(await fetch(o)).text();l=l.replaceAll(/['"`](((\.\/)|(\.\.\/))+(.*))['"`]/g,`'${n}$1'`);let u=new File([l],s.substring(s.lastIndexOf("/")),{type:"text/javascript"}),f=await import(URL.createObjectURL(u)),g=f.tests??f.default;if(g==null)throw new Error(`Unable to find tests definition in file at path: ${s}`);let E=g[y];if(E!=null){if(this.#e.get(y)==null){let c=new Map;c.set(E,new Set),this.#e.set(y,c)}this.classList.add("has-before-hook")}let m=g[v];if(m!=null&&this.#e.get(v)==null){let c=new Map;c.set(m,new Set),this.#e.set(v,c)}let b=g[k];if(b!=null){if(this.#e.get(k)==null){let c=new Map;c.set(b,new Set),this.#e.set(k,c)}this.classList.add("has-after-hook")}let A=g[x];if(A!=null&&this.#e.get(x)==null){let c=new Map;c.set(A,new Set),this.#e.set(x,c)}for(let[w,c]of Object.entries(g)){let C=this.#m(w,c);if(E!=null){let d=this.#e.get(y);if(d!=null){let p=d.get(E);p?.add(C)}}if(m!=null){let d=this.#e.get(v);if(d!=null){let p=d.get(m);p?.add(C)}}if(b!=null){let d=this.#e.get(k);if(d!=null){let p=d.get(b);p?.add(C)}}if(A!=null){let d=this.#e.get(x);if(d!=null){let p=d.get(A);p?.add(C)}}}}catch(e){this.#i("An error occurred while loading the tasks:",e)}}async runTests(){this.dispatchEvent(new CustomEvent("beforeall",{bubbles:!0,composed:!0})),this.#t=!0,this.classList.add("running"),this.toggleAttribute("success",!1),this.#g();let t=this.hasAttribute("in-order"),s=this.#e.get(y);if(s!=null){let r;try{let n=this.getElement("before-all-details");n.classList.add("running"),n.part.add("running");for(let[o,l]of s)r=await o(),this.#n(r,!0,"before");n.part.remove("running"),n.classList.remove("running")}catch(n){this.#n(r,!1,"before",n),console.error(n),this.#t=!1,this.classList.remove("running"),this.part.remove("running"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}));return}}if(t==!1){let r=[];for(let[n,o]of this.#s)r.push(this.#u(n,o));await Promise.all(r)}else for(let[r,n]of this.#s){if(this.#t==!1)break;await this.#u(r,n)}if(this.#t==!1){this.classList.remove("running"),this.part.remove("running"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}));return}let e=this.#e.get(k);if(e!=null){let r;try{let n=this.getElement("after-all-details");n.classList.add("running"),n.part.add("running");for(let[o,l]of e)r=await o(),this.#n(r,!0,"after");n.part.remove("running"),n.classList.remove("running")}catch(n){this.#n(r,!1,"after",n),console.error(n),this.#t=!1,this.classList.remove("running"),this.part.remove("running"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}));return}}let a=this.shadowRoot.querySelectorAll('[success="false"]');this.setAttribute("success",a.length==0?"true":"false"),this.classList.remove("running"),this.part.remove("running"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}))}#g(){for(let[e,a]of this.#s){let r=this.getElement("tests").querySelector(`[data-test-id="${e}"]`);if(r==null){this.#i(`Unable to find test element for test: ${e}`);return}r.toggleAttribute("success",!1),r.classList.remove("success","fail"),r.part.remove("success","fail")}let t=this.getElement("before-all-details");t.toggleAttribute("success",!1),t.classList.remove("success","fail"),t.part.remove("success","fail");let s=this.getElement("after-all-details");s.toggleAttribute("success",!1),s.classList.remove("success","fail"),s.part.remove("success","fail")}async#u(t,s){let e=this.getElement("tests").querySelector(`[data-test-id="${t}"]`);if(e==null){this.#i(`Unable to find test element for test: ${t}`);return}e.toggleAttribute("success",!1),e.classList.add("running"),e.part.add("running"),e.classList.remove("success","fail"),e.part.remove("success","fail");let a=e.querySelector(".result-icon");a?.classList.remove("success","fail"),a?.part.remove("success","fail"),a?.classList.add("running"),a?.part.add("running");let r=e.querySelector(".error-message");r!=null&&(r.textContent="");let n=e.querySelector("details");n!=null&&(n.open=!1);let o=R,l,u=R,i;try{if(this.dispatchEvent(new CustomEvent("beforetest",{bubbles:!0,cancelable:!0,composed:!0,detail:{testElement:e}}))==!0){let g=this.#e.get(v);if(g!=null){for(let[m,b]of g)if(b.has(t)){o=await m();break}}l=await s();let E=this.#e.get(x);if(E!=null){for(let[m,b]of E)if(b.has(t)){u=await m();break}}i="before",o!=R&&this.#a(e,o,!0,void 0,i),i=void 0,this.#a(e,l,!0,void 0,i),i="after",u!=R&&this.#a(e,u,!0,void 0,i)}}catch(f){this.#a(e,l,!1,f,i),console.error(f),this.#t=!1}finally{e?.classList.remove("running"),e?.part.remove("running"),a?.classList.remove("running"),a?.part.remove("running"),this.dispatchEvent(new CustomEvent("aftertest",{bubbles:!0,cancelable:!0,composed:!0,detail:{testElement:e}}))}}#a(t,s,e,a,r){if(s instanceof HTMLElement)this.#o(t,s,e,r);else if(s==null){let o=r==null?"Passed":"Hook Ran Successfully",l=this.#r(e==!0?`${o}`:`Failed${a!=null?`:
|
|
389
|
+
${a.message}`:""}`,e,r);this.#o(t,l,e,r)}else if(typeof s=="string"){let o=this.#r(`${s}${a==null?"":`:
|
|
390
|
+
${a.message}`}`,e,r);this.#o(t,o,e,r)}else if(typeof s=="object"){let o=s;if(o.success!=null&&o.expected!=null&&o.value!=null){let l=r==null?"Passed":"Success",u=r==null?"Failed":"Fail",i=this.#r(`${o.success==!0?`${l}:`:`${u}:`}
|
|
391
391
|
Expected:${o.expected}
|
|
392
|
-
Result:${o.value}`,o.success,
|
|
393
|
-
${
|
|
394
|
-
${
|
|
392
|
+
Result:${o.value}`,o.success,r);this.#o(t,i,e,r)}}let n=t.querySelector("details");n!=null&&(n.open=!0)}#n(t,s,e,a){if(t instanceof HTMLElement)this.#l(t,s,e);else{let n;if(t==null)n=this.#r(s==!0?"Hook Ran Successfully":`Failed${a!=null?`:
|
|
393
|
+
${a.message}`:""}`,s),this.#l(n,s,e);else if(typeof t=="string")n=this.#r(`${t}${a==null?"":`:
|
|
394
|
+
${a.message}`}`,s),this.#l(n,s,e);else if(typeof t=="object"){let o=t;o.success!=null&&o.expected!=null&&o.value!=null&&(n=this.#r(`${o.success==!0?"Success:":"Fail:"}
|
|
395
395
|
Expected:${o.expected}
|
|
396
|
-
Result:${o.value}`,o.success),this.#l(n,s,e))}}let
|
|
397
|
-
${s.message}`,console.error(s));let e=document.createElement("li");e.classList.add("error","process-error"),e.part.add("error","process-error");let
|
|
396
|
+
Result:${o.value}`,o.success),this.#l(n,s,e))}}let r=this.getElement(`${e}-all-details`);r!=null&&(r.open=!0)}static create(t){let s=document.createElement("code-tests");return console.log(t),s}#s=new Map;#m(t,s){let e=L();this.#s.set(e,s);let a=this.#b(e,t);return this.getElement("tests").append(a),e}#b(t,s){let e=document.createElement("li");e.dataset.testId=t,e.classList.add("test"),e.part.add("test");let a=document.createElement("details");a.classList.add("test-details"),a.part.add("test-details");let r=document.createElement("summary");r.classList.add("test-summary"),r.part.add("test-summary");let n=document.createElement("div");n.classList.add("result-icon"),n.part.add("result-icon"),r.append(n);let o=document.createElement("span");o.classList.add("description","test-description"),o.textContent=s,r.append(o);let l=document.createElement("button");l.classList.add("run","test-run"),l.part.add("run","test-run"),l.textContent="Run Test",l.title="Run Test",r.append(l);let u=document.createElement("div");u.classList.add("before-result","test-before-result"),u.part.add("before-result","test-before-result");let i=document.createElement("div");i.classList.add("result","test-result"),i.part.add("result","test-result");let f=document.createElement("div");return f.classList.add("after-result","test-after-result"),f.part.add("after-result","test-after-result"),a.append(r),a.append(u),a.append(i),a.append(f),e.append(a),e}#o(t,s,e,a){t.setAttribute("success",e==!0?"true":"false"),t.classList.toggle("success",e),t.part.toggle("success",e),t.classList.toggle("fail",!e),t.part.toggle("fail",!e);let r=t.querySelector(".result-icon");r?.classList.toggle("success",e),r?.part.toggle("success",e),r?.classList.toggle("fail",!e),r?.part.toggle("fail",!e);let n=t.querySelector(`.${a==null?"result":a=="before"?"before-result":"after-result"}`);if(n==null){this.#i("Unable to find result element");return}n.innerHTML="",n.appendChild(s)}#r(t,s,e){let a=document.createElement("code");a.classList.add("code"),a.part.add("code");let r=document.createElement("pre");r.textContent=t;let n=s==!0?"success-message":"error-message";return r.classList.add("pre",n),r.part.add("pre",n),a.appendChild(r),a}#l(t,s,e){let a=this.getElement(`${e}-all-details`),r=this.getElement(`${e}-all-results`);a.setAttribute("success",s==!0?"true":"false"),a.classList.toggle("success",s),a.part.toggle("success",s),a.classList.toggle("fail",!s),a.part.toggle("fail",!s),r.innerHTML="",r.appendChild(t)}#i(t,s){s instanceof Error&&(t+=`
|
|
397
|
+
${s.message}`,console.error(s));let e=document.createElement("li");e.classList.add("error","process-error"),e.part.add("error","process-error");let a=document.createElement("code");a.classList.add("code","process-error-code"),a.part.add("code","process-error-code");let r=document.createElement("pre");r.classList.add("pre","process-error-pre"),r.part.add("pre","process-error-pre"),r.textContent=t,a.append(r),e.append(a),this.getElement("tests").append(e)}#d(t){if(t=="ordered"){let s=this.shadowRoot.querySelector("ul");if(s==null)return;let e=this.shadowRoot?.querySelectorAll("li"),a=document.createElement("ol");e!=null&&a.append(...e),a.id="tests",s.replaceWith(a)}else{let s=this.shadowRoot.querySelector("ol");if(s==null)return;let e=this.shadowRoot?.querySelectorAll("li"),a=document.createElement("ul");a.id="tests",e!=null&&a.append(...e),s.replaceWith(a)}}static observedAttributes=["in-order"];attributeChangedCallback(t,s,e){t=="in-order"&&(e==null?this.#d("unordered"):this.#d("ordered"))}};function L(){let h=new Uint8Array(20);crypto.getRandomValues(h);let t=[].slice.apply(h).map(function(e){return String.fromCharCode(e)}).join("");return btoa(t).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}customElements.get(P)==null&&customElements.define(P,S);export{k as AFTERALL,x as AFTEREACH,y as BEFOREALL,v as BEFOREEACH,z as CodeTestEventType,M as CodeTests,S as CodeTestsElement,j as expect};
|