@magnit-ce/code-tests 0.0.10 → 0.0.11
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 +43 -27
- package/dist/code-tests.d.cts +1 -0
- package/dist/code-tests.d.ts +1 -0
- package/dist/code-tests.js +43 -27
- package/dist/code-tests.min.js +42 -26
- package/package.json +1 -1
package/dist/code-tests.cjs
CHANGED
|
@@ -139,18 +139,6 @@ var code_tests_default = `:host
|
|
|
139
139
|
padding: var(--small-spacer);
|
|
140
140
|
font-family: var(--font-text);
|
|
141
141
|
}
|
|
142
|
-
@media (prefers-color-scheme: dark)
|
|
143
|
-
{
|
|
144
|
-
:host
|
|
145
|
-
{
|
|
146
|
-
--text-surface: var(--uchu-yang);
|
|
147
|
-
--text-result: var(--uchu-yang);
|
|
148
|
-
|
|
149
|
-
--surface-0: var(--uchu-yin);
|
|
150
|
-
--surface-test: oklch(25.11% 0.006 258.36);
|
|
151
|
-
--surface-test-summary: oklch(35.02% 0.005 236.66);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
142
|
|
|
155
143
|
#header
|
|
156
144
|
{
|
|
@@ -214,18 +202,19 @@ summary::before
|
|
|
214
202
|
|
|
215
203
|
:host(.running) .run[data-all]
|
|
216
204
|
{
|
|
217
|
-
|
|
218
|
-
|
|
205
|
+
color: var(--text-surface);
|
|
206
|
+
background-color: oklch(89.68% 0.002 197.12);
|
|
207
|
+
border-color: oklch(63.12% 0.004 219.55);
|
|
219
208
|
}
|
|
220
209
|
:host(.running) .run[data-all]:hover
|
|
221
210
|
{
|
|
222
|
-
background-color:
|
|
223
|
-
border-color:
|
|
211
|
+
background-color: oklch(95.57% 0.003 286.35);
|
|
212
|
+
border-color: oklch(63.12% 0.004 219.55);
|
|
224
213
|
}
|
|
225
214
|
:host(.running) .run[data-all]:active
|
|
226
215
|
{
|
|
227
|
-
background-color:
|
|
228
|
-
border-color:
|
|
216
|
+
background-color: oklch(63.12% 0.004 219.55);
|
|
217
|
+
border-color: oklch(53.12% 0.004 219.55);
|
|
229
218
|
}
|
|
230
219
|
:host(.running) .run[data-all]::before
|
|
231
220
|
{
|
|
@@ -407,6 +396,33 @@ pre
|
|
|
407
396
|
}
|
|
408
397
|
|
|
409
398
|
|
|
399
|
+
@media (prefers-color-scheme: dark)
|
|
400
|
+
{
|
|
401
|
+
:host
|
|
402
|
+
{
|
|
403
|
+
--text-surface: var(--uchu-yang);
|
|
404
|
+
--text-result: var(--uchu-yang);
|
|
405
|
+
|
|
406
|
+
--surface-0: var(--uchu-yin);
|
|
407
|
+
--surface-test: oklch(25.11% 0.006 258.36);
|
|
408
|
+
--surface-test-summary: oklch(35.02% 0.005 236.66);
|
|
409
|
+
}
|
|
410
|
+
:host(.running) .run[data-all]
|
|
411
|
+
{
|
|
412
|
+
background-color: oklch(35.02% 0.005 236.66);
|
|
413
|
+
border-color: oklch(35.02% 0.005 236.66);
|
|
414
|
+
}
|
|
415
|
+
:host(.running) .run[data-all]:hover
|
|
416
|
+
{
|
|
417
|
+
background-color: oklch(63.12% 0.004 219.55);
|
|
418
|
+
border-color:oklch(63.12% 0.004 219.55);
|
|
419
|
+
}
|
|
420
|
+
:host(.running) .run[data-all]:active
|
|
421
|
+
{
|
|
422
|
+
background-color: oklch(25.11% 0.006 258.36);
|
|
423
|
+
border-color: oklch(25.11% 0.006 258.36);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
410
426
|
|
|
411
427
|
@keyframes spin
|
|
412
428
|
{
|
|
@@ -643,7 +659,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
643
659
|
if (test == null) {
|
|
644
660
|
return;
|
|
645
661
|
}
|
|
646
|
-
this
|
|
662
|
+
this.isCanceled = false;
|
|
647
663
|
this.classList.remove("canceled");
|
|
648
664
|
this.part.remove("canceled");
|
|
649
665
|
this.#runTest(testId, test);
|
|
@@ -756,9 +772,9 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
756
772
|
this.#addProcessError("An error occurred while loading the tasks:", error);
|
|
757
773
|
}
|
|
758
774
|
}
|
|
759
|
-
|
|
775
|
+
isCanceled = false;
|
|
760
776
|
cancel() {
|
|
761
|
-
this
|
|
777
|
+
this.isCanceled = true;
|
|
762
778
|
this.classList.add("canceled");
|
|
763
779
|
this.part.add("canceled");
|
|
764
780
|
this.dispatchEvent(new CustomEvent("cancel" /* Cancel */, { bubbles: true, composed: true }));
|
|
@@ -767,7 +783,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
767
783
|
this.dispatchEvent(new CustomEvent("beforeall" /* BeforeAll */, { bubbles: true, composed: true }));
|
|
768
784
|
this.#continueRunningTests = true;
|
|
769
785
|
this.classList.add("running");
|
|
770
|
-
this
|
|
786
|
+
this.isCanceled = false;
|
|
771
787
|
this.classList.remove("canceled");
|
|
772
788
|
this.part.remove("canceled");
|
|
773
789
|
this.toggleAttribute("success", false);
|
|
@@ -785,7 +801,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
785
801
|
beforeAllHookElement.classList.add("running");
|
|
786
802
|
beforeAllHookElement.part.add("running");
|
|
787
803
|
for (const [hook, ids] of beforeHooks) {
|
|
788
|
-
if (this
|
|
804
|
+
if (this.isCanceled == true) {
|
|
789
805
|
throw new Error("Test has been cancelled");
|
|
790
806
|
}
|
|
791
807
|
hookResult = await hook(this, beforeAllHookElement);
|
|
@@ -837,7 +853,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
837
853
|
afterAllHookElement.classList.add("running");
|
|
838
854
|
afterAllHookElement.part.add("running");
|
|
839
855
|
for (const [hook, ids] of afterHooks) {
|
|
840
|
-
if (this
|
|
856
|
+
if (this.isCanceled == true) {
|
|
841
857
|
throw new Error("Test has been cancelled");
|
|
842
858
|
}
|
|
843
859
|
hookResult = await hook(this, afterAllHookElement);
|
|
@@ -917,7 +933,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
917
933
|
let testType;
|
|
918
934
|
try {
|
|
919
935
|
const allowTest = this.dispatchEvent(new CustomEvent("beforetest" /* BeforeTest */, { bubbles: true, cancelable: true, composed: true, detail: { testElement } }));
|
|
920
|
-
if (allowTest == false || this
|
|
936
|
+
if (allowTest == false || this.isCanceled == true) {
|
|
921
937
|
throw new Error("Test has been cancelled");
|
|
922
938
|
}
|
|
923
939
|
const beforeHooks = this.#hooks.get(BEFOREEACH);
|
|
@@ -929,11 +945,11 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
929
945
|
}
|
|
930
946
|
}
|
|
931
947
|
}
|
|
932
|
-
if (this
|
|
948
|
+
if (this.isCanceled == true) {
|
|
933
949
|
throw new Error("Test has been cancelled");
|
|
934
950
|
}
|
|
935
951
|
testResult = await test(this, testElement);
|
|
936
|
-
if (this
|
|
952
|
+
if (this.isCanceled == true) {
|
|
937
953
|
throw new Error("Test has been cancelled");
|
|
938
954
|
}
|
|
939
955
|
const afterHooks = this.#hooks.get(AFTEREACH);
|
package/dist/code-tests.d.cts
CHANGED
|
@@ -43,6 +43,7 @@ declare class CodeTestsElement extends HTMLElement {
|
|
|
43
43
|
connectedCallback(): void;
|
|
44
44
|
disconnectedCallback(): void;
|
|
45
45
|
loadTests(testsPath?: string): Promise<void>;
|
|
46
|
+
isCanceled: boolean;
|
|
46
47
|
cancel(): void;
|
|
47
48
|
runTests(): Promise<void>;
|
|
48
49
|
static create(properties: CodeTestsProperties): HTMLElement;
|
package/dist/code-tests.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ declare class CodeTestsElement extends HTMLElement {
|
|
|
43
43
|
connectedCallback(): void;
|
|
44
44
|
disconnectedCallback(): void;
|
|
45
45
|
loadTests(testsPath?: string): Promise<void>;
|
|
46
|
+
isCanceled: boolean;
|
|
46
47
|
cancel(): void;
|
|
47
48
|
runTests(): Promise<void>;
|
|
48
49
|
static create(properties: CodeTestsProperties): HTMLElement;
|
package/dist/code-tests.js
CHANGED
|
@@ -105,18 +105,6 @@ var code_tests_default = `:host
|
|
|
105
105
|
padding: var(--small-spacer);
|
|
106
106
|
font-family: var(--font-text);
|
|
107
107
|
}
|
|
108
|
-
@media (prefers-color-scheme: dark)
|
|
109
|
-
{
|
|
110
|
-
:host
|
|
111
|
-
{
|
|
112
|
-
--text-surface: var(--uchu-yang);
|
|
113
|
-
--text-result: var(--uchu-yang);
|
|
114
|
-
|
|
115
|
-
--surface-0: var(--uchu-yin);
|
|
116
|
-
--surface-test: oklch(25.11% 0.006 258.36);
|
|
117
|
-
--surface-test-summary: oklch(35.02% 0.005 236.66);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
108
|
|
|
121
109
|
#header
|
|
122
110
|
{
|
|
@@ -180,18 +168,19 @@ summary::before
|
|
|
180
168
|
|
|
181
169
|
:host(.running) .run[data-all]
|
|
182
170
|
{
|
|
183
|
-
|
|
184
|
-
|
|
171
|
+
color: var(--text-surface);
|
|
172
|
+
background-color: oklch(89.68% 0.002 197.12);
|
|
173
|
+
border-color: oklch(63.12% 0.004 219.55);
|
|
185
174
|
}
|
|
186
175
|
:host(.running) .run[data-all]:hover
|
|
187
176
|
{
|
|
188
|
-
background-color:
|
|
189
|
-
border-color:
|
|
177
|
+
background-color: oklch(95.57% 0.003 286.35);
|
|
178
|
+
border-color: oklch(63.12% 0.004 219.55);
|
|
190
179
|
}
|
|
191
180
|
:host(.running) .run[data-all]:active
|
|
192
181
|
{
|
|
193
|
-
background-color:
|
|
194
|
-
border-color:
|
|
182
|
+
background-color: oklch(63.12% 0.004 219.55);
|
|
183
|
+
border-color: oklch(53.12% 0.004 219.55);
|
|
195
184
|
}
|
|
196
185
|
:host(.running) .run[data-all]::before
|
|
197
186
|
{
|
|
@@ -373,6 +362,33 @@ pre
|
|
|
373
362
|
}
|
|
374
363
|
|
|
375
364
|
|
|
365
|
+
@media (prefers-color-scheme: dark)
|
|
366
|
+
{
|
|
367
|
+
:host
|
|
368
|
+
{
|
|
369
|
+
--text-surface: var(--uchu-yang);
|
|
370
|
+
--text-result: var(--uchu-yang);
|
|
371
|
+
|
|
372
|
+
--surface-0: var(--uchu-yin);
|
|
373
|
+
--surface-test: oklch(25.11% 0.006 258.36);
|
|
374
|
+
--surface-test-summary: oklch(35.02% 0.005 236.66);
|
|
375
|
+
}
|
|
376
|
+
:host(.running) .run[data-all]
|
|
377
|
+
{
|
|
378
|
+
background-color: oklch(35.02% 0.005 236.66);
|
|
379
|
+
border-color: oklch(35.02% 0.005 236.66);
|
|
380
|
+
}
|
|
381
|
+
:host(.running) .run[data-all]:hover
|
|
382
|
+
{
|
|
383
|
+
background-color: oklch(63.12% 0.004 219.55);
|
|
384
|
+
border-color:oklch(63.12% 0.004 219.55);
|
|
385
|
+
}
|
|
386
|
+
:host(.running) .run[data-all]:active
|
|
387
|
+
{
|
|
388
|
+
background-color: oklch(25.11% 0.006 258.36);
|
|
389
|
+
border-color: oklch(25.11% 0.006 258.36);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
376
392
|
|
|
377
393
|
@keyframes spin
|
|
378
394
|
{
|
|
@@ -609,7 +625,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
609
625
|
if (test == null) {
|
|
610
626
|
return;
|
|
611
627
|
}
|
|
612
|
-
this
|
|
628
|
+
this.isCanceled = false;
|
|
613
629
|
this.classList.remove("canceled");
|
|
614
630
|
this.part.remove("canceled");
|
|
615
631
|
this.#runTest(testId, test);
|
|
@@ -722,9 +738,9 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
722
738
|
this.#addProcessError("An error occurred while loading the tasks:", error);
|
|
723
739
|
}
|
|
724
740
|
}
|
|
725
|
-
|
|
741
|
+
isCanceled = false;
|
|
726
742
|
cancel() {
|
|
727
|
-
this
|
|
743
|
+
this.isCanceled = true;
|
|
728
744
|
this.classList.add("canceled");
|
|
729
745
|
this.part.add("canceled");
|
|
730
746
|
this.dispatchEvent(new CustomEvent("cancel" /* Cancel */, { bubbles: true, composed: true }));
|
|
@@ -733,7 +749,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
733
749
|
this.dispatchEvent(new CustomEvent("beforeall" /* BeforeAll */, { bubbles: true, composed: true }));
|
|
734
750
|
this.#continueRunningTests = true;
|
|
735
751
|
this.classList.add("running");
|
|
736
|
-
this
|
|
752
|
+
this.isCanceled = false;
|
|
737
753
|
this.classList.remove("canceled");
|
|
738
754
|
this.part.remove("canceled");
|
|
739
755
|
this.toggleAttribute("success", false);
|
|
@@ -751,7 +767,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
751
767
|
beforeAllHookElement.classList.add("running");
|
|
752
768
|
beforeAllHookElement.part.add("running");
|
|
753
769
|
for (const [hook, ids] of beforeHooks) {
|
|
754
|
-
if (this
|
|
770
|
+
if (this.isCanceled == true) {
|
|
755
771
|
throw new Error("Test has been cancelled");
|
|
756
772
|
}
|
|
757
773
|
hookResult = await hook(this, beforeAllHookElement);
|
|
@@ -803,7 +819,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
803
819
|
afterAllHookElement.classList.add("running");
|
|
804
820
|
afterAllHookElement.part.add("running");
|
|
805
821
|
for (const [hook, ids] of afterHooks) {
|
|
806
|
-
if (this
|
|
822
|
+
if (this.isCanceled == true) {
|
|
807
823
|
throw new Error("Test has been cancelled");
|
|
808
824
|
}
|
|
809
825
|
hookResult = await hook(this, afterAllHookElement);
|
|
@@ -883,7 +899,7 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
883
899
|
let testType;
|
|
884
900
|
try {
|
|
885
901
|
const allowTest = this.dispatchEvent(new CustomEvent("beforetest" /* BeforeTest */, { bubbles: true, cancelable: true, composed: true, detail: { testElement } }));
|
|
886
|
-
if (allowTest == false || this
|
|
902
|
+
if (allowTest == false || this.isCanceled == true) {
|
|
887
903
|
throw new Error("Test has been cancelled");
|
|
888
904
|
}
|
|
889
905
|
const beforeHooks = this.#hooks.get(BEFOREEACH);
|
|
@@ -895,11 +911,11 @@ var CodeTestsElement = class extends HTMLElement {
|
|
|
895
911
|
}
|
|
896
912
|
}
|
|
897
913
|
}
|
|
898
|
-
if (this
|
|
914
|
+
if (this.isCanceled == true) {
|
|
899
915
|
throw new Error("Test has been cancelled");
|
|
900
916
|
}
|
|
901
917
|
testResult = await test(this, testElement);
|
|
902
|
-
if (this
|
|
918
|
+
if (this.isCanceled == true) {
|
|
903
919
|
throw new Error("Test has been cancelled");
|
|
904
920
|
}
|
|
905
921
|
const afterHooks = this.#hooks.get(AFTEREACH);
|
package/dist/code-tests.min.js
CHANGED
|
@@ -104,18 +104,6 @@ var S=`:host
|
|
|
104
104
|
padding: var(--small-spacer);
|
|
105
105
|
font-family: var(--font-text);
|
|
106
106
|
}
|
|
107
|
-
@media (prefers-color-scheme: dark)
|
|
108
|
-
{
|
|
109
|
-
:host
|
|
110
|
-
{
|
|
111
|
-
--text-surface: var(--uchu-yang);
|
|
112
|
-
--text-result: var(--uchu-yang);
|
|
113
|
-
|
|
114
|
-
--surface-0: var(--uchu-yin);
|
|
115
|
-
--surface-test: oklch(25.11% 0.006 258.36);
|
|
116
|
-
--surface-test-summary: oklch(35.02% 0.005 236.66);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
107
|
|
|
120
108
|
#header
|
|
121
109
|
{
|
|
@@ -179,18 +167,19 @@ summary::before
|
|
|
179
167
|
|
|
180
168
|
:host(.running) .run[data-all]
|
|
181
169
|
{
|
|
182
|
-
|
|
183
|
-
|
|
170
|
+
color: var(--text-surface);
|
|
171
|
+
background-color: oklch(89.68% 0.002 197.12);
|
|
172
|
+
border-color: oklch(63.12% 0.004 219.55);
|
|
184
173
|
}
|
|
185
174
|
:host(.running) .run[data-all]:hover
|
|
186
175
|
{
|
|
187
|
-
background-color:
|
|
188
|
-
border-color:
|
|
176
|
+
background-color: oklch(95.57% 0.003 286.35);
|
|
177
|
+
border-color: oklch(63.12% 0.004 219.55);
|
|
189
178
|
}
|
|
190
179
|
:host(.running) .run[data-all]:active
|
|
191
180
|
{
|
|
192
|
-
background-color:
|
|
193
|
-
border-color:
|
|
181
|
+
background-color: oklch(63.12% 0.004 219.55);
|
|
182
|
+
border-color: oklch(53.12% 0.004 219.55);
|
|
194
183
|
}
|
|
195
184
|
:host(.running) .run[data-all]::before
|
|
196
185
|
{
|
|
@@ -372,6 +361,33 @@ pre
|
|
|
372
361
|
}
|
|
373
362
|
|
|
374
363
|
|
|
364
|
+
@media (prefers-color-scheme: dark)
|
|
365
|
+
{
|
|
366
|
+
:host
|
|
367
|
+
{
|
|
368
|
+
--text-surface: var(--uchu-yang);
|
|
369
|
+
--text-result: var(--uchu-yang);
|
|
370
|
+
|
|
371
|
+
--surface-0: var(--uchu-yin);
|
|
372
|
+
--surface-test: oklch(25.11% 0.006 258.36);
|
|
373
|
+
--surface-test-summary: oklch(35.02% 0.005 236.66);
|
|
374
|
+
}
|
|
375
|
+
:host(.running) .run[data-all]
|
|
376
|
+
{
|
|
377
|
+
background-color: oklch(35.02% 0.005 236.66);
|
|
378
|
+
border-color: oklch(35.02% 0.005 236.66);
|
|
379
|
+
}
|
|
380
|
+
:host(.running) .run[data-all]:hover
|
|
381
|
+
{
|
|
382
|
+
background-color: oklch(63.12% 0.004 219.55);
|
|
383
|
+
border-color:oklch(63.12% 0.004 219.55);
|
|
384
|
+
}
|
|
385
|
+
:host(.running) .run[data-all]:active
|
|
386
|
+
{
|
|
387
|
+
background-color: oklch(25.11% 0.006 258.36);
|
|
388
|
+
border-color: oklch(25.11% 0.006 258.36);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
375
391
|
|
|
376
392
|
@keyframes spin
|
|
377
393
|
{
|
|
@@ -419,13 +435,13 @@ pre
|
|
|
419
435
|
</div>
|
|
420
436
|
</template>`;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.
|
|
421
437
|
Expected: ${t}
|
|
422
|
-
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")}},v=Symbol("beforeAll"),y=Symbol("beforeEach"),k=Symbol("afterAll"),w=Symbol("afterEach"),L=class d{static timeoutMS=500;static#e;static#h;static expect(t){return new T(async(e,r)=>{if(t instanceof Promise){let n=await t;e(n);return}e(t)})}static expectSync(t){return new T(async(e,r)=>{if(t instanceof Promise){let n=await t;e(n);return}e(t)})}static expectBefore(t){return new T(async(e,r)=>{if(t instanceof Promise){let n=await t;e(n);return}e(t)})}static async prompt(t,s,e,r){return new Promise((n,o)=>{let a=t.findElement("prompt-template"),l=d.createElementFromTemplate(a);l.querySelector(".label").textContent=e;let c=h=>{let f=h.composedPath();if(f.find(i=>i instanceof HTMLButtonElement&&i.classList.contains("accept"))!=null){let i=r?.onAccept?.()??!0;l.removeEventListener("click",c),n(i);return}if(f.find(i=>i instanceof HTMLButtonElement&&i.classList.contains("reject"))!=null){let i=r?.onReject?.()??!1;l.removeEventListener("click",c),n(i);return}};l.addEventListener("click",c),r?.acceptLabel!=null&&(l.querySelector(".accept").textContent=r.acceptLabel),r?.rejectLabel!=null&&(l.querySelector(".reject").textContent=r.rejectLabel);let u=s instanceof HTMLDetailsElement?s:s.querySelector(".test-details");u!=null&&(u.open=!0),s.querySelector(".result")?.append(l)})}static createElementFromTemplate(t,s){let e=t instanceof HTMLTemplateElement?t:document.querySelector(t);if(e==null)throw new Error(`Unable to find template element from selector: ${t}`);let r=e.content.cloneNode(!0).querySelector("*");if(r==null)throw new Error("Unable to find first child of template element");return s?.append(r),r}};function I(d){return L.expect(d)}function U(d,t,s,e){return L.prompt(d,t,s,e)}var $=":not(slot,defs,g,rect,path,circle,ellipse,line,polygon,text,tspan,use,svg image,svg title,desc,template,template *)";function P(d){let t=[...d.querySelectorAll(`${$}[id]`)];for(let e=0;e<t.length;e++)t[e].part.add(t[e].id);let s=[...d.querySelectorAll(`${$}[class]`)];for(let e=0;e<s.length;e++)s[e].part.add(...s[e].classList)}var z=(n=>(n.BeforeAll="beforeall",n.AfterAll="afterall",n.BeforeTest="beforetest",n.AfterTest="aftertest",n.Cancel="cancel",n))(z||{}),H=Symbol("No Test Defined"),D=new CSSStyleSheet;D.replaceSync(S);var B="code-tests",R=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;#h={[v]:C(),[y]:C(),[w]:C(),[k]:C()};#s=!0;constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=F,this.shadowRoot.adoptedStyleSheets.push(D),this.#u=this.#f.bind(this)}connectedCallback(){if(P(this.shadowRoot),this.addEventListener("click",this.#u),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.#u)}#u;#f(t){let s=t.composedPath().find(o=>o instanceof HTMLButtonElement&&o.classList.contains("run"));if(s==null)return;let e=s.closest("li");if(e==null){if(s.hasAttribute("data-all")==!0)if(this.classList.contains("running")){if(this.classList.contains("canceled"))return;this.cancel()}else this.runTests();return}let r=e.dataset.testId;if(r==null)return;let n=this.#r.get(r);n!=null&&(this.#t=!1,this.classList.remove("canceled"),this.part.remove("canceled"),this.#d(r,n))}#m(){return this.getAttribute("src")??this.getAttribute("test")??this.getAttribute("tests")??this.getAttribute("run")??this.getAttribute("path")}async loadTests(t){let s=t??this.#m();if(s!=null)try{this.getElement("tests").innerHTML="",this.#r.clear(),this.classList.remove("has-before-hook"),this.classList.remove("has-after-hook");let e=window.location.href.lastIndexOf("/"),n=window.location.href.substring(e).indexOf(".")!=-1==!0?window.location.href.substring(0,e+1):window.location.href,o=n+s.substring(0,s.lastIndexOf("/")+1),a=n+s,l=await(await fetch(a)).text();l=l.replaceAll(/['"`](((\.\/)|(\.\.\/))+(.*))['"`]/g,`'${o}$1'`);let c=new File([l],s.substring(s.lastIndexOf("/")),{type:"text/javascript"}),h=await import(URL.createObjectURL(c)),f=h.tests??h.default;if(f==null)throw new Error(`Unable to find tests definition in file at path: ${s}`);let E=f[v];if(E!=null){if(this.#e.get(v)==null){let p=new Map;p.set(E,new Set),this.#e.set(v,p)}this.classList.add("has-before-hook")}let b=f[y];if(b!=null&&this.#e.get(y)==null){let p=new Map;p.set(b,new Set),this.#e.set(y,p)}let i=f[k];if(i!=null){if(this.#e.get(k)==null){let p=new Map;p.set(i,new Set),this.#e.set(k,p)}this.classList.add("has-after-hook")}let A=f[w];if(A!=null&&this.#e.get(w)==null){let p=new Map;p.set(A,new Set),this.#e.set(w,p)}for(let[x,p]of Object.entries(f)){let M=this.#b(x,p);if(E!=null){let m=this.#e.get(v);if(m!=null){let g=m.get(E);g?.add(M)}}if(b!=null){let m=this.#e.get(y);if(m!=null){let g=m.get(b);g?.add(M)}}if(i!=null){let m=this.#e.get(k);if(m!=null){let g=m.get(i);g?.add(M)}}if(A!=null){let m=this.#e.get(w);if(m!=null){let g=m.get(A);g?.add(M)}}}}catch(e){this.#c("An error occurred while loading the tasks:",e)}}#t=!1;cancel(){this.#t=!0,this.classList.add("canceled"),this.part.add("canceled"),this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}async runTests(){this.dispatchEvent(new CustomEvent("beforeall",{bubbles:!0,composed:!0})),this.#s=!0,this.classList.add("running"),this.#t=!1,this.classList.remove("canceled"),this.part.remove("canceled"),this.toggleAttribute("success",!1);let t=this.findElement("play-button-label");t!=null&&(t.textContent="Cancel"),this.#g();let s=this.hasAttribute("in-order"),e=this.#e.get(v);if(e!=null){let o;try{let a=this.getElement("before-all-details");a.classList.add("running"),a.part.add("running");for(let[l,c]of e){if(this.#t==!0)throw new Error("Test has been cancelled");o=await l(this,a),this.#o(o,!0,"before")}a.part.remove("running"),a.classList.remove("running")}catch(a){this.#o(o,!1,"before",a),console.error(a),this.#s=!1,this.classList.remove("running"),this.part.remove("running"),t!=null&&(t.textContent="Run Tests"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}));return}}if(s==!1){let o=[];for(let[a,l]of this.#r)o.push(this.#d(a,l));await Promise.all(o)}else for(let[o,a]of this.#r){if(this.#s==!1)break;await this.#d(o,a)}if(this.#s==!1){this.classList.remove("running"),this.part.remove("running"),t!=null&&(t.textContent="Run Tests"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}));return}let r=this.#e.get(k);if(r!=null){let o;try{let a=this.getElement("after-all-details");a.classList.add("running"),a.part.add("running");for(let[l,c]of r){if(this.#t==!0)throw new Error("Test has been cancelled");o=await l(this,a),this.#o(o,!0,"after")}a.part.remove("running"),a.classList.remove("running")}catch(a){this.#o(o,!1,"after",a),console.error(a),this.#s=!1,this.classList.remove("running"),this.part.remove("running"),t!=null&&(t.textContent="Run Tests"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}));return}}let n=this.shadowRoot.querySelectorAll('[success="false"]');this.setAttribute("success",n.length==0?"true":"false"),this.classList.remove("running"),this.part.remove("running"),t!=null&&(t.textContent="Run Tests"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}))}#g(){for(let[e,r]of this.#r){let n=this.getElement("tests").querySelector(`[data-test-id="${e}"]`);if(n==null){this.#c(`Unable to find test element for test: ${e}`);return}n.toggleAttribute("success",!1),n.classList.remove("success","fail"),n.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#d(t,s){let e=this.getElement("tests").querySelector(`[data-test-id="${t}"]`);if(e==null){this.#c(`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 r=e.querySelector(".result-icon");r?.classList.remove("success","fail"),r?.part.remove("success","fail"),r?.classList.add("running"),r?.part.add("running");let n=e.querySelector(".error-message");n!=null&&(n.textContent="");let o=e.querySelector("details");o!=null&&(o.open=!1);let a=H,l,c=H,u;try{if(this.dispatchEvent(new CustomEvent("beforetest",{bubbles:!0,cancelable:!0,composed:!0,detail:{testElement:e}}))==!1||this.#t==!0)throw new Error("Test has been cancelled");let f=this.#e.get(y);if(f!=null){for(let[b,i]of f)if(i.has(t)){a=await b(this,e);break}}if(this.#t==!0)throw new Error("Test has been cancelled");if(l=await s(this,e),this.#t==!0)throw new Error("Test has been cancelled");let E=this.#e.get(w);if(E!=null){for(let[b,i]of E)if(i.has(t)){c=await b(this,e);break}}u="before",a!=H&&this.#a(e,a,!0,void 0,u),u=void 0,this.#a(e,l,!0,void 0,u),u="after",c!=H&&this.#a(e,c,!0,void 0,u)}catch(h){this.#a(e,l,!1,h,u),console.error(h),this.#s=!1}finally{e?.classList.remove("running"),e?.part.remove("running"),r?.classList.remove("running"),r?.part.remove("running"),this.dispatchEvent(new CustomEvent("aftertest",{bubbles:!0,cancelable:!0,composed:!0,detail:{testElement:e}}))}}#a(t,s,e,r,n){if(s instanceof HTMLElement)this.#l(t,s,e,n);else if(s==null){let a=n==null?"Passed":"Hook Ran Successfully",l=this.#n(e==!0?`${a}`:`Failed${r!=null?`:
|
|
423
|
-
${r.message}`:""}`,e,n);this.#
|
|
424
|
-
${r.message}`}`,e,n);this.#
|
|
438
|
+
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")}},v=Symbol("beforeAll"),y=Symbol("beforeEach"),k=Symbol("afterAll"),x=Symbol("afterEach"),L=class d{static timeoutMS=500;static#e;static#p;static expect(t){return new T(async(e,r)=>{if(t instanceof Promise){let n=await t;e(n);return}e(t)})}static expectSync(t){return new T(async(e,r)=>{if(t instanceof Promise){let n=await t;e(n);return}e(t)})}static expectBefore(t){return new T(async(e,r)=>{if(t instanceof Promise){let n=await t;e(n);return}e(t)})}static async prompt(t,s,e,r){return new Promise((n,o)=>{let a=t.findElement("prompt-template"),l=d.createElementFromTemplate(a);l.querySelector(".label").textContent=e;let c=h=>{let f=h.composedPath();if(f.find(i=>i instanceof HTMLButtonElement&&i.classList.contains("accept"))!=null){let i=r?.onAccept?.()??!0;l.removeEventListener("click",c),n(i);return}if(f.find(i=>i instanceof HTMLButtonElement&&i.classList.contains("reject"))!=null){let i=r?.onReject?.()??!1;l.removeEventListener("click",c),n(i);return}};l.addEventListener("click",c),r?.acceptLabel!=null&&(l.querySelector(".accept").textContent=r.acceptLabel),r?.rejectLabel!=null&&(l.querySelector(".reject").textContent=r.rejectLabel);let u=s instanceof HTMLDetailsElement?s:s.querySelector(".test-details");u!=null&&(u.open=!0),s.querySelector(".result")?.append(l)})}static createElementFromTemplate(t,s){let e=t instanceof HTMLTemplateElement?t:document.querySelector(t);if(e==null)throw new Error(`Unable to find template element from selector: ${t}`);let r=e.content.cloneNode(!0).querySelector("*");if(r==null)throw new Error("Unable to find first child of template element");return s?.append(r),r}};function I(d){return L.expect(d)}function U(d,t,s,e){return L.prompt(d,t,s,e)}var $=":not(slot,defs,g,rect,path,circle,ellipse,line,polygon,text,tspan,use,svg image,svg title,desc,template,template *)";function P(d){let t=[...d.querySelectorAll(`${$}[id]`)];for(let e=0;e<t.length;e++)t[e].part.add(t[e].id);let s=[...d.querySelectorAll(`${$}[class]`)];for(let e=0;e<s.length;e++)s[e].part.add(...s[e].classList)}var z=(n=>(n.BeforeAll="beforeall",n.AfterAll="afterall",n.BeforeTest="beforetest",n.AfterTest="aftertest",n.Cancel="cancel",n))(z||{}),H=Symbol("No Test Defined"),D=new CSSStyleSheet;D.replaceSync(S);var B="code-tests",R=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={[v]:C(),[y]:C(),[x]:C(),[k]:C()};#t=!0;constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=F,this.shadowRoot.adoptedStyleSheets.push(D),this.#c=this.#h.bind(this)}connectedCallback(){if(P(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(o=>o instanceof HTMLButtonElement&&o.classList.contains("run"));if(s==null)return;let e=s.closest("li");if(e==null){if(s.hasAttribute("data-all")==!0)if(this.classList.contains("running")){if(this.classList.contains("canceled"))return;this.cancel()}else this.runTests();return}let r=e.dataset.testId;if(r==null)return;let n=this.#s.get(r);n!=null&&(this.isCanceled=!1,this.classList.remove("canceled"),this.part.remove("canceled"),this.#u(r,n))}#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("/"),n=window.location.href.substring(e).indexOf(".")!=-1==!0?window.location.href.substring(0,e+1):window.location.href,o=n+s.substring(0,s.lastIndexOf("/")+1),a=n+s,l=await(await fetch(a)).text();l=l.replaceAll(/['"`](((\.\/)|(\.\.\/))+(.*))['"`]/g,`'${o}$1'`);let c=new File([l],s.substring(s.lastIndexOf("/")),{type:"text/javascript"}),h=await import(URL.createObjectURL(c)),f=h.tests??h.default;if(f==null)throw new Error(`Unable to find tests definition in file at path: ${s}`);let E=f[v];if(E!=null){if(this.#e.get(v)==null){let p=new Map;p.set(E,new Set),this.#e.set(v,p)}this.classList.add("has-before-hook")}let b=f[y];if(b!=null&&this.#e.get(y)==null){let p=new Map;p.set(b,new Set),this.#e.set(y,p)}let i=f[k];if(i!=null){if(this.#e.get(k)==null){let p=new Map;p.set(i,new Set),this.#e.set(k,p)}this.classList.add("has-after-hook")}let A=f[x];if(A!=null&&this.#e.get(x)==null){let p=new Map;p.set(A,new Set),this.#e.set(x,p)}for(let[w,p]of Object.entries(f)){let M=this.#g(w,p);if(E!=null){let m=this.#e.get(v);if(m!=null){let g=m.get(E);g?.add(M)}}if(b!=null){let m=this.#e.get(y);if(m!=null){let g=m.get(b);g?.add(M)}}if(i!=null){let m=this.#e.get(k);if(m!=null){let g=m.get(i);g?.add(M)}}if(A!=null){let m=this.#e.get(x);if(m!=null){let g=m.get(A);g?.add(M)}}}}catch(e){this.#i("An error occurred while loading the tasks:",e)}}isCanceled=!1;cancel(){this.isCanceled=!0,this.classList.add("canceled"),this.part.add("canceled"),this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))}async runTests(){this.dispatchEvent(new CustomEvent("beforeall",{bubbles:!0,composed:!0})),this.#t=!0,this.classList.add("running"),this.isCanceled=!1,this.classList.remove("canceled"),this.part.remove("canceled"),this.toggleAttribute("success",!1);let t=this.findElement("play-button-label");t!=null&&(t.textContent="Cancel"),this.#m();let s=this.hasAttribute("in-order"),e=this.#e.get(v);if(e!=null){let o;try{let a=this.getElement("before-all-details");a.classList.add("running"),a.part.add("running");for(let[l,c]of e){if(this.isCanceled==!0)throw new Error("Test has been cancelled");o=await l(this,a),this.#a(o,!0,"before")}a.part.remove("running"),a.classList.remove("running")}catch(a){this.#a(o,!1,"before",a),console.error(a),this.#t=!1,this.classList.remove("running"),this.part.remove("running"),t!=null&&(t.textContent="Run Tests"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}));return}}if(s==!1){let o=[];for(let[a,l]of this.#s)o.push(this.#u(a,l));await Promise.all(o)}else for(let[o,a]of this.#s){if(this.#t==!1)break;await this.#u(o,a)}if(this.#t==!1){this.classList.remove("running"),this.part.remove("running"),t!=null&&(t.textContent="Run Tests"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}));return}let r=this.#e.get(k);if(r!=null){let o;try{let a=this.getElement("after-all-details");a.classList.add("running"),a.part.add("running");for(let[l,c]of r){if(this.isCanceled==!0)throw new Error("Test has been cancelled");o=await l(this,a),this.#a(o,!0,"after")}a.part.remove("running"),a.classList.remove("running")}catch(a){this.#a(o,!1,"after",a),console.error(a),this.#t=!1,this.classList.remove("running"),this.part.remove("running"),t!=null&&(t.textContent="Run Tests"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}));return}}let n=this.shadowRoot.querySelectorAll('[success="false"]');this.setAttribute("success",n.length==0?"true":"false"),this.classList.remove("running"),this.part.remove("running"),t!=null&&(t.textContent="Run Tests"),this.dispatchEvent(new CustomEvent("afterall",{bubbles:!0,composed:!0}))}#m(){for(let[e,r]of this.#s){let n=this.getElement("tests").querySelector(`[data-test-id="${e}"]`);if(n==null){this.#i(`Unable to find test element for test: ${e}`);return}n.toggleAttribute("success",!1),n.classList.remove("success","fail"),n.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 r=e.querySelector(".result-icon");r?.classList.remove("success","fail"),r?.part.remove("success","fail"),r?.classList.add("running"),r?.part.add("running");let n=e.querySelector(".error-message");n!=null&&(n.textContent="");let o=e.querySelector("details");o!=null&&(o.open=!1);let a=H,l,c=H,u;try{if(this.dispatchEvent(new CustomEvent("beforetest",{bubbles:!0,cancelable:!0,composed:!0,detail:{testElement:e}}))==!1||this.isCanceled==!0)throw new Error("Test has been cancelled");let f=this.#e.get(y);if(f!=null){for(let[b,i]of f)if(i.has(t)){a=await b(this,e);break}}if(this.isCanceled==!0)throw new Error("Test has been cancelled");if(l=await s(this,e),this.isCanceled==!0)throw new Error("Test has been cancelled");let E=this.#e.get(x);if(E!=null){for(let[b,i]of E)if(i.has(t)){c=await b(this,e);break}}u="before",a!=H&&this.#n(e,a,!0,void 0,u),u=void 0,this.#n(e,l,!0,void 0,u),u="after",c!=H&&this.#n(e,c,!0,void 0,u)}catch(h){this.#n(e,l,!1,h,u),console.error(h),this.#t=!1}finally{e?.classList.remove("running"),e?.part.remove("running"),r?.classList.remove("running"),r?.part.remove("running"),this.dispatchEvent(new CustomEvent("aftertest",{bubbles:!0,cancelable:!0,composed:!0,detail:{testElement:e}}))}}#n(t,s,e,r,n){if(s instanceof HTMLElement)this.#o(t,s,e,n);else if(s==null){let a=n==null?"Passed":"Hook Ran Successfully",l=this.#r(e==!0?`${a}`:`Failed${r!=null?`:
|
|
439
|
+
${r.message}`:""}`,e,n);this.#o(t,l,e,n)}else if(typeof s=="string"){let a=this.#r(`${s}${r==null?"":`:
|
|
440
|
+
${r.message}`}`,e,n);this.#o(t,a,e,n)}else if(typeof s=="object"){let a=s;if(a.success!=null&&a.expected!=null&&a.value!=null){let l=n==null?"Passed":"Success",c=n==null?"Failed":"Fail",u=this.#r(`${a.success==!0?`${l}:`:`${c}:`}
|
|
425
441
|
Expected:${a.expected}
|
|
426
|
-
Result:${a.value}`,a.success,n);this.#
|
|
427
|
-
${r.message}`:""}`,s),this.#
|
|
428
|
-
${r.message}`}`,s),this.#
|
|
442
|
+
Result:${a.value}`,a.success,n);this.#o(t,u,e,n)}}let o=t.querySelector("details");o!=null&&(o.open=!0)}#a(t,s,e,r){if(t instanceof HTMLElement)this.#l(t,s,e);else{let o;if(t==null)o=this.#r(s==!0?"Hook Ran Successfully":`Failed${r!=null?`:
|
|
443
|
+
${r.message}`:""}`,s),this.#l(o,s,e);else if(typeof t=="string")o=this.#r(`${t}${r==null?"":`:
|
|
444
|
+
${r.message}`}`,s),this.#l(o,s,e);else if(typeof t=="object"){let a=t;a.success!=null&&a.expected!=null&&a.value!=null&&(o=this.#r(`${a.success==!0?"Success:":"Fail:"}
|
|
429
445
|
Expected:${a.expected}
|
|
430
|
-
Result:${a.value}`,a.success),this.#
|
|
431
|
-
${s.message}`,console.error(s));let e=document.createElement("li");e.classList.add("error","process-error"),e.part.add("error","process-error");let r=document.createElement("code");r.classList.add("code","process-error-code"),r.part.add("code","process-error-code");let n=document.createElement("pre");n.classList.add("pre","process-error-pre"),n.part.add("pre","process-error-pre"),n.textContent=t,r.append(n),e.append(r),this.getElement("tests").append(e)}#
|
|
446
|
+
Result:${a.value}`,a.success),this.#l(o,s,e))}}let n=this.getElement(`${e}-all-details`);n!=null&&(n.open=!0)}static create(t){return document.createElement("code-tests")}#s=new Map;#g(t,s){let e=C();this.#s.set(e,s);let r=this.#b(e,t);return this.getElement("tests").append(r),e}#b(t,s){let e=document.createElement("li");e.dataset.testId=t,e.classList.add("test"),e.part.add("test");let r=document.createElement("details");r.classList.add("test-details"),r.part.add("test-details");let n=document.createElement("summary");n.classList.add("test-summary"),n.part.add("test-summary");let o=document.createElement("div");o.classList.add("result-icon"),o.part.add("result-icon"),n.append(o);let a=document.createElement("span");a.classList.add("description","test-description"),a.textContent=s,n.append(a);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",n.append(l);let c=document.createElement("div");c.classList.add("before-result","test-before-result"),c.part.add("before-result","test-before-result");let u=document.createElement("div");u.classList.add("result","test-result"),u.part.add("result","test-result");let h=document.createElement("div");return h.classList.add("after-result","test-after-result"),h.part.add("after-result","test-after-result"),r.append(n),r.append(c),r.append(u),r.append(h),e.append(r),e}#o(t,s,e,r){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 n=t.querySelector(".result-icon");n?.classList.toggle("success",e),n?.part.toggle("success",e),n?.classList.toggle("fail",!e),n?.part.toggle("fail",!e);let o=t.querySelector(`.${r==null?"result":r=="before"?"before-result":"after-result"}`);if(o==null){this.#i("Unable to find result element");return}o.innerHTML="",o.appendChild(s)}#r(t,s,e){let r=document.createElement("code");r.classList.add("code"),r.part.add("code");let n=document.createElement("pre");n.textContent=t;let o=s==!0?"success-message":"error-message";return n.classList.add("pre",o),n.part.add("pre",o),r.appendChild(n),r}#l(t,s,e){let r=this.getElement(`${e}-all-details`),n=this.getElement(`${e}-all-results`);r.setAttribute("success",s==!0?"true":"false"),r.classList.toggle("success",s),r.part.toggle("success",s),r.classList.toggle("fail",!s),r.part.toggle("fail",!s),n.innerHTML="",n.appendChild(t)}#i(t,s){s instanceof Error&&(t+=`
|
|
447
|
+
${s.message}`,console.error(s));let e=document.createElement("li");e.classList.add("error","process-error"),e.part.add("error","process-error");let r=document.createElement("code");r.classList.add("code","process-error-code"),r.part.add("code","process-error-code");let n=document.createElement("pre");n.classList.add("pre","process-error-pre"),n.part.add("pre","process-error-pre"),n.textContent=t,r.append(n),e.append(r),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"),r=document.createElement("ol");e!=null&&r.append(...e),r.id="tests",s.replaceWith(r)}else{let s=this.shadowRoot.querySelector("ol");if(s==null)return;let e=this.shadowRoot?.querySelectorAll("li"),r=document.createElement("ul");r.id="tests",e!=null&&r.append(...e),s.replaceWith(r)}}static observedAttributes=["in-order"];attributeChangedCallback(t,s,e){t=="in-order"&&(e==null?this.#d("unordered"):this.#d("ordered"))}};function C(){let d=new Uint8Array(20);crypto.getRandomValues(d);let t=[].slice.apply(d).map(function(e){return String.fromCharCode(e)}).join("");return btoa(t).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}customElements.get(B)==null&&customElements.define(B,R);export{k as AFTERALL,x as AFTEREACH,v as BEFOREALL,y as BEFOREEACH,z as CodeTestEventType,L as CodeTests,R as CodeTestsElement,I as expect,U as prompt};
|