@universityofmaryland/web-model-library 1.0.7 → 1.1.0
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/LICENSE +5 -0
- package/README.md +1 -1
- package/dist/_types.d.ts +43 -0
- package/dist/_types.d.ts.map +1 -1
- package/dist/_virtual/index.js +1 -1
- package/dist/_virtual/postcss.js +1 -1
- package/dist/attributes/change-detection.d.ts +21 -0
- package/dist/attributes/change-detection.d.ts.map +1 -0
- package/dist/attributes/change-detection.js +60 -0
- package/dist/attributes/change-detection.js.map +1 -0
- package/dist/attributes/checks.d.ts.map +1 -1
- package/dist/attributes/checks.js +15 -8
- package/dist/attributes/checks.js.map +1 -1
- package/dist/attributes/config.d.ts +29 -0
- package/dist/attributes/config.d.ts.map +1 -0
- package/dist/attributes/config.js +57 -0
- package/dist/attributes/config.js.map +1 -0
- package/dist/attributes/converters.d.ts +14 -0
- package/dist/attributes/converters.d.ts.map +1 -0
- package/dist/attributes/converters.js +84 -0
- package/dist/attributes/converters.js.map +1 -0
- package/dist/attributes/errors.d.ts +16 -0
- package/dist/attributes/errors.d.ts.map +1 -0
- package/dist/attributes/errors.js +51 -0
- package/dist/attributes/errors.js.map +1 -0
- package/dist/attributes/index.d.ts +4 -0
- package/dist/attributes/index.d.ts.map +1 -1
- package/dist/attributes.js +18 -0
- package/dist/attributes.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/model/controllers.d.ts +22 -0
- package/dist/model/controllers.d.ts.map +1 -0
- package/dist/model/controllers.js +53 -0
- package/dist/model/controllers.js.map +1 -0
- package/dist/model/errors.d.ts +13 -0
- package/dist/model/errors.d.ts.map +1 -0
- package/dist/model/errors.js +23 -0
- package/dist/model/errors.js.map +1 -0
- package/dist/model/index.d.ts +54 -3
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/registration.d.ts +13 -0
- package/dist/model/registration.d.ts.map +1 -0
- package/dist/model/registration.js +83 -0
- package/dist/model/registration.js.map +1 -0
- package/dist/model/update-cycle.d.ts +12 -0
- package/dist/model/update-cycle.d.ts.map +1 -0
- package/dist/model/update-cycle.js +41 -0
- package/dist/model/update-cycle.js.map +1 -0
- package/dist/model.js +335 -55
- package/dist/model.js.map +1 -1
- package/dist/node_modules/.pnpm/nanoid@3.3.11/node_modules/nanoid/non-secure/index.js.map +1 -0
- package/dist/node_modules/{picocolors → .pnpm/picocolors@1.1.1/node_modules/picocolors}/picocolors.browser.js +1 -1
- package/dist/node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.browser.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss-discard-duplicates@5.1.0_postcss@8.5.8/node_modules/postcss-discard-duplicates/src/index.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/at-rule.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/comment.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/container.js.map +1 -0
- package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/css-syntax-error.js +2 -2
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/css-syntax-error.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/declaration.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/document.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/fromJSON.js.map +1 -0
- package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/input.js +2 -2
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/input.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/lazy-result.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/list.js.map +1 -0
- package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/map-generator.js +1 -1
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/map-generator.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/no-work-result.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/node.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/parse.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/parser.js.map +1 -0
- package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/postcss.js +1 -1
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/postcss.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/postcss2.js.map +1 -0
- package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/previous-map.js +1 -1
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/previous-map.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/processor.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/result.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/root.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/rule.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/stringifier.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/stringify.js.map +1 -0
- package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/symbols.js +1 -1
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/symbols.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/tokenize.js.map +1 -0
- package/dist/node_modules/.pnpm/postcss@8.5.8/node_modules/postcss/lib/warning.js.map +1 -0
- package/dist/slots/index.d.ts +6 -0
- package/dist/slots/index.d.ts.map +1 -1
- package/dist/slots/slot-events.d.ts +32 -0
- package/dist/slots/slot-events.d.ts.map +1 -0
- package/dist/slots/slot-events.js +83 -0
- package/dist/slots/slot-events.js.map +1 -0
- package/dist/slots/slot-query.d.ts +18 -0
- package/dist/slots/slot-query.d.ts.map +1 -0
- package/dist/slots/slot-query.js +59 -0
- package/dist/slots/slot-query.js.map +1 -0
- package/dist/slots/slot-validation.d.ts +5 -0
- package/dist/slots/slot-validation.d.ts.map +1 -0
- package/dist/slots/slot-validation.js +89 -0
- package/dist/slots/slot-validation.js.map +1 -0
- package/dist/slots.js +15 -1
- package/dist/slots.js.map +1 -1
- package/dist/testing/console.d.ts +8 -0
- package/dist/testing/console.d.ts.map +1 -0
- package/dist/testing/console.js +39 -0
- package/dist/testing/console.js.map +1 -0
- package/dist/testing/events.d.ts +11 -0
- package/dist/testing/events.d.ts.map +1 -0
- package/dist/testing/events.js +47 -0
- package/dist/testing/events.js.map +1 -0
- package/dist/testing/fixture.d.ts +10 -0
- package/dist/testing/fixture.d.ts.map +1 -0
- package/dist/testing/fixture.js +36 -0
- package/dist/testing/fixture.js.map +1 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/shadow.d.ts +6 -0
- package/dist/testing/shadow.d.ts.map +1 -0
- package/dist/testing/shadow.js +27 -0
- package/dist/testing/shadow.js.map +1 -0
- package/dist/testing/slots.d.ts +10 -0
- package/dist/testing/slots.d.ts.map +1 -0
- package/dist/testing/slots.js +62 -0
- package/dist/testing/slots.js.map +1 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +26 -0
- package/dist/testing.js.map +1 -0
- package/dist/utilities/debug.d.ts +365 -0
- package/dist/utilities/debug.d.ts.map +1 -0
- package/dist/utilities/debug.js +71 -0
- package/dist/utilities/debug.js.map +1 -0
- package/dist/utilities/dom.d.ts +11 -0
- package/dist/utilities/dom.d.ts.map +1 -0
- package/dist/utilities/dom.js +57 -0
- package/dist/utilities/dom.js.map +1 -0
- package/dist/utilities/events.d.ts +22 -0
- package/dist/utilities/events.d.ts.map +1 -0
- package/dist/utilities/events.js +49 -0
- package/dist/utilities/events.js.map +1 -0
- package/dist/utilities/index.d.ts +7 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/register.d.ts.map +1 -1
- package/dist/utilities/register.js +16 -4
- package/dist/utilities/register.js.map +1 -1
- package/dist/utilities/styles.js +1 -1
- package/dist/utilities/types.d.ts +10 -0
- package/dist/utilities/types.d.ts.map +1 -0
- package/dist/utilities/types.js +45 -0
- package/dist/utilities/types.js.map +1 -0
- package/dist/utilities.js +27 -1
- package/dist/utilities.js.map +1 -1
- package/package.json +21 -15
- package/dist/node_modules/nanoid/non-secure/index.js.map +0 -1
- package/dist/node_modules/picocolors/picocolors.browser.js.map +0 -1
- package/dist/node_modules/postcss/lib/at-rule.js.map +0 -1
- package/dist/node_modules/postcss/lib/comment.js.map +0 -1
- package/dist/node_modules/postcss/lib/container.js.map +0 -1
- package/dist/node_modules/postcss/lib/css-syntax-error.js.map +0 -1
- package/dist/node_modules/postcss/lib/declaration.js.map +0 -1
- package/dist/node_modules/postcss/lib/document.js.map +0 -1
- package/dist/node_modules/postcss/lib/fromJSON.js.map +0 -1
- package/dist/node_modules/postcss/lib/input.js.map +0 -1
- package/dist/node_modules/postcss/lib/lazy-result.js.map +0 -1
- package/dist/node_modules/postcss/lib/list.js.map +0 -1
- package/dist/node_modules/postcss/lib/map-generator.js.map +0 -1
- package/dist/node_modules/postcss/lib/no-work-result.js.map +0 -1
- package/dist/node_modules/postcss/lib/node.js.map +0 -1
- package/dist/node_modules/postcss/lib/parse.js.map +0 -1
- package/dist/node_modules/postcss/lib/parser.js.map +0 -1
- package/dist/node_modules/postcss/lib/postcss.js.map +0 -1
- package/dist/node_modules/postcss/lib/postcss2.js.map +0 -1
- package/dist/node_modules/postcss/lib/previous-map.js.map +0 -1
- package/dist/node_modules/postcss/lib/processor.js.map +0 -1
- package/dist/node_modules/postcss/lib/result.js.map +0 -1
- package/dist/node_modules/postcss/lib/root.js.map +0 -1
- package/dist/node_modules/postcss/lib/rule.js.map +0 -1
- package/dist/node_modules/postcss/lib/stringifier.js.map +0 -1
- package/dist/node_modules/postcss/lib/stringify.js.map +0 -1
- package/dist/node_modules/postcss/lib/symbols.js.map +0 -1
- package/dist/node_modules/postcss/lib/tokenize.js.map +0 -1
- package/dist/node_modules/postcss/lib/warning.js.map +0 -1
- package/dist/packages/model/node_modules/postcss-discard-duplicates/src/index.js.map +0 -1
- /package/dist/node_modules/{nanoid → .pnpm/nanoid@3.3.11/node_modules/nanoid}/non-secure/index.js +0 -0
- /package/dist/{packages/model → node_modules/.pnpm/postcss-discard-duplicates@5.1.0_postcss@8.5.8}/node_modules/postcss-discard-duplicates/src/index.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/at-rule.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/comment.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/container.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/declaration.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/document.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/fromJSON.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/lazy-result.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/list.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/no-work-result.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/node.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/parse.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/parser.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/postcss2.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/processor.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/result.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/root.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/rule.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/stringifier.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/stringify.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/tokenize.js +0 -0
- /package/dist/node_modules/{postcss → .pnpm/postcss@8.5.8/node_modules/postcss}/lib/warning.js +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type ConsoleMethod = 'log' | 'warn' | 'error';
|
|
2
|
+
declare function captureConsole(method: ConsoleMethod, callback: () => void): string[];
|
|
3
|
+
declare function captureConsoleAsync(method: ConsoleMethod, callback: () => Promise<void>): Promise<string[]>;
|
|
4
|
+
declare function captureWarnings(callback: () => void): string[];
|
|
5
|
+
declare function captureWarningsAsync(callback: () => Promise<void>): Promise<string[]>;
|
|
6
|
+
export { captureConsole, captureConsoleAsync, captureWarnings, captureWarningsAsync, };
|
|
7
|
+
export type { ConsoleMethod };
|
|
8
|
+
//# sourceMappingURL=console.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../source/testing/console.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9C,iBAAS,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,EAAE,CAe7E;AAED,iBAAe,mBAAmB,CAChC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CAenB;AAED,iBAAS,eAAe,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,EAAE,CAEvD;AAED,iBAAe,oBAAoB,CACjC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CAEnB;AAED,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,oBAAoB,GACrB,CAAC;AACF,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function captureConsole(method, callback) {
|
|
2
|
+
const messages = [];
|
|
3
|
+
const original = console[method];
|
|
4
|
+
console[method] = (...args) => {
|
|
5
|
+
messages.push(args.map(String).join(" "));
|
|
6
|
+
};
|
|
7
|
+
try {
|
|
8
|
+
callback();
|
|
9
|
+
} finally {
|
|
10
|
+
console[method] = original;
|
|
11
|
+
}
|
|
12
|
+
return messages;
|
|
13
|
+
}
|
|
14
|
+
async function captureConsoleAsync(method, callback) {
|
|
15
|
+
const messages = [];
|
|
16
|
+
const original = console[method];
|
|
17
|
+
console[method] = (...args) => {
|
|
18
|
+
messages.push(args.map(String).join(" "));
|
|
19
|
+
};
|
|
20
|
+
try {
|
|
21
|
+
await callback();
|
|
22
|
+
} finally {
|
|
23
|
+
console[method] = original;
|
|
24
|
+
}
|
|
25
|
+
return messages;
|
|
26
|
+
}
|
|
27
|
+
function captureWarnings(callback) {
|
|
28
|
+
return captureConsole("warn", callback);
|
|
29
|
+
}
|
|
30
|
+
async function captureWarningsAsync(callback) {
|
|
31
|
+
return captureConsoleAsync("warn", callback);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
captureConsole,
|
|
35
|
+
captureConsoleAsync,
|
|
36
|
+
captureWarnings,
|
|
37
|
+
captureWarningsAsync
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.js","sources":["../../source/testing/console.ts"],"sourcesContent":["type ConsoleMethod = 'log' | 'warn' | 'error';\n\nfunction captureConsole(method: ConsoleMethod, callback: () => void): string[] {\n const messages: string[] = [];\n const original = console[method];\n\n console[method] = (...args: unknown[]) => {\n messages.push(args.map(String).join(' '));\n };\n\n try {\n callback();\n } finally {\n console[method] = original;\n }\n\n return messages;\n}\n\nasync function captureConsoleAsync(\n method: ConsoleMethod,\n callback: () => Promise<void>,\n): Promise<string[]> {\n const messages: string[] = [];\n const original = console[method];\n\n console[method] = (...args: unknown[]) => {\n messages.push(args.map(String).join(' '));\n };\n\n try {\n await callback();\n } finally {\n console[method] = original;\n }\n\n return messages;\n}\n\nfunction captureWarnings(callback: () => void): string[] {\n return captureConsole('warn', callback);\n}\n\nasync function captureWarningsAsync(\n callback: () => Promise<void>,\n): Promise<string[]> {\n return captureConsoleAsync('warn', callback);\n}\n\nexport {\n captureConsole,\n captureConsoleAsync,\n captureWarnings,\n captureWarningsAsync,\n};\nexport type { ConsoleMethod };\n"],"names":[],"mappings":"AAEA,SAAS,eAAe,QAAuB,UAAgC;AAC7E,QAAM,WAAqB,CAAA;AAC3B,QAAM,WAAW,QAAQ,MAAM;AAE/B,UAAQ,MAAM,IAAI,IAAI,SAAoB;AACxC,aAAS,KAAK,KAAK,IAAI,MAAM,EAAE,KAAK,GAAG,CAAC;AAAA,EAC1C;AAEA,MAAI;AACF,aAAA;AAAA,EACF,UAAA;AACE,YAAQ,MAAM,IAAI;AAAA,EACpB;AAEA,SAAO;AACT;AAEA,eAAe,oBACb,QACA,UACmB;AACnB,QAAM,WAAqB,CAAA;AAC3B,QAAM,WAAW,QAAQ,MAAM;AAE/B,UAAQ,MAAM,IAAI,IAAI,SAAoB;AACxC,aAAS,KAAK,KAAK,IAAI,MAAM,EAAE,KAAK,GAAG,CAAC;AAAA,EAC1C;AAEA,MAAI;AACF,UAAM,SAAA;AAAA,EACR,UAAA;AACE,YAAQ,MAAM,IAAI;AAAA,EACpB;AAEA,SAAO;AACT;AAEA,SAAS,gBAAgB,UAAgC;AACvD,SAAO,eAAe,QAAQ,QAAQ;AACxC;AAEA,eAAe,qBACb,UACmB;AACnB,SAAO,oBAAoB,QAAQ,QAAQ;AAC7C;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare function simulateEvent<T = unknown>(target: EventTarget, type: string, detail?: T, options?: {
|
|
2
|
+
bubbles?: boolean;
|
|
3
|
+
composed?: boolean;
|
|
4
|
+
}): void;
|
|
5
|
+
declare function waitForEvent<E extends Event = CustomEvent>(target: EventTarget, type: string, timeout?: number): Promise<E>;
|
|
6
|
+
declare function captureEvents(target: EventTarget, types: string[]): {
|
|
7
|
+
events: Record<string, Event[]>;
|
|
8
|
+
cleanup: () => void;
|
|
9
|
+
};
|
|
10
|
+
export { simulateEvent, waitForEvent, captureEvents };
|
|
11
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../source/testing/events.ts"],"names":[],"mappings":"AAAA,iBAAS,aAAa,CAAC,CAAC,GAAG,OAAO,EAChC,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,CAAC,EACV,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAClD,IAAI,CAON;AAED,iBAAS,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,WAAW,EACjD,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,SAAO,GACb,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAED,iBAAS,aAAa,CACpB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,EAAE,GACd;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAoB1D;AAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function simulateEvent(target, type, detail, options) {
|
|
2
|
+
const event = new CustomEvent(type, {
|
|
3
|
+
detail,
|
|
4
|
+
bubbles: options?.bubbles ?? true,
|
|
5
|
+
composed: options?.composed ?? true
|
|
6
|
+
});
|
|
7
|
+
target.dispatchEvent(event);
|
|
8
|
+
}
|
|
9
|
+
function waitForEvent(target, type, timeout = 1e3) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
let timer;
|
|
12
|
+
const handler = (event) => {
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
target.removeEventListener(type, handler);
|
|
15
|
+
resolve(event);
|
|
16
|
+
};
|
|
17
|
+
target.addEventListener(type, handler);
|
|
18
|
+
timer = setTimeout(() => {
|
|
19
|
+
target.removeEventListener(type, handler);
|
|
20
|
+
reject(new Error(`waitForEvent: "${type}" not received within ${timeout}ms`));
|
|
21
|
+
}, timeout);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function captureEvents(target, types) {
|
|
25
|
+
const events = {};
|
|
26
|
+
const listeners = [];
|
|
27
|
+
for (const type of types) {
|
|
28
|
+
events[type] = [];
|
|
29
|
+
const handler = (e) => {
|
|
30
|
+
events[type].push(e);
|
|
31
|
+
};
|
|
32
|
+
listeners.push({ type, handler });
|
|
33
|
+
target.addEventListener(type, handler);
|
|
34
|
+
}
|
|
35
|
+
const cleanup = () => {
|
|
36
|
+
for (const { type, handler } of listeners) {
|
|
37
|
+
target.removeEventListener(type, handler);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return { events, cleanup };
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
captureEvents,
|
|
44
|
+
simulateEvent,
|
|
45
|
+
waitForEvent
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../../source/testing/events.ts"],"sourcesContent":["function simulateEvent<T = unknown>(\n target: EventTarget,\n type: string,\n detail?: T,\n options?: { bubbles?: boolean; composed?: boolean },\n): void {\n const event = new CustomEvent(type, {\n detail,\n bubbles: options?.bubbles ?? true,\n composed: options?.composed ?? true,\n });\n target.dispatchEvent(event);\n}\n\nfunction waitForEvent<E extends Event = CustomEvent>(\n target: EventTarget,\n type: string,\n timeout = 1000,\n): Promise<E> {\n return new Promise<E>((resolve, reject) => {\n let timer: ReturnType<typeof setTimeout>;\n\n const handler = (event: Event) => {\n clearTimeout(timer);\n target.removeEventListener(type, handler);\n resolve(event as E);\n };\n\n target.addEventListener(type, handler);\n\n timer = setTimeout(() => {\n target.removeEventListener(type, handler);\n reject(new Error(`waitForEvent: \"${type}\" not received within ${timeout}ms`));\n }, timeout);\n });\n}\n\nfunction captureEvents(\n target: EventTarget,\n types: string[],\n): { events: Record<string, Event[]>; cleanup: () => void } {\n const events: Record<string, Event[]> = {};\n const listeners: Array<{ type: string; handler: (e: Event) => void }> = [];\n\n for (const type of types) {\n events[type] = [];\n const handler = (e: Event) => {\n events[type].push(e);\n };\n listeners.push({ type, handler });\n target.addEventListener(type, handler);\n }\n\n const cleanup = () => {\n for (const { type, handler } of listeners) {\n target.removeEventListener(type, handler);\n }\n };\n\n return { events, cleanup };\n}\n\nexport { simulateEvent, waitForEvent, captureEvents };\n"],"names":[],"mappings":"AAAA,SAAS,cACP,QACA,MACA,QACA,SACM;AACN,QAAM,QAAQ,IAAI,YAAY,MAAM;AAAA,IAClC;AAAA,IACA,SAAS,SAAS,WAAW;AAAA,IAC7B,UAAU,SAAS,YAAY;AAAA,EAAA,CAChC;AACD,SAAO,cAAc,KAAK;AAC5B;AAEA,SAAS,aACP,QACA,MACA,UAAU,KACE;AACZ,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI;AAEJ,UAAM,UAAU,CAAC,UAAiB;AAChC,mBAAa,KAAK;AAClB,aAAO,oBAAoB,MAAM,OAAO;AACxC,cAAQ,KAAU;AAAA,IACpB;AAEA,WAAO,iBAAiB,MAAM,OAAO;AAErC,YAAQ,WAAW,MAAM;AACvB,aAAO,oBAAoB,MAAM,OAAO;AACxC,aAAO,IAAI,MAAM,kBAAkB,IAAI,yBAAyB,OAAO,IAAI,CAAC;AAAA,IAC9E,GAAG,OAAO;AAAA,EACZ,CAAC;AACH;AAEA,SAAS,cACP,QACA,OAC0D;AAC1D,QAAM,SAAkC,CAAA;AACxC,QAAM,YAAkE,CAAA;AAExE,aAAW,QAAQ,OAAO;AACxB,WAAO,IAAI,IAAI,CAAA;AACf,UAAM,UAAU,CAAC,MAAa;AAC5B,aAAO,IAAI,EAAE,KAAK,CAAC;AAAA,IACrB;AACA,cAAU,KAAK,EAAE,MAAM,QAAA,CAAS;AAChC,WAAO,iBAAiB,MAAM,OAAO;AAAA,EACvC;AAEA,QAAM,UAAU,MAAM;AACpB,eAAW,EAAE,MAAM,QAAA,KAAa,WAAW;AACzC,aAAO,oBAAoB,MAAM,OAAO;AAAA,IAC1C;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,QAAA;AACnB;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface FixtureOptions {
|
|
2
|
+
container?: HTMLElement;
|
|
3
|
+
attributes?: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
declare function createFixtureSync<T extends HTMLElement = HTMLElement>(html: string, options?: FixtureOptions): T;
|
|
6
|
+
declare function createFixture<T extends HTMLElement = HTMLElement>(html: string, options?: FixtureOptions): Promise<T>;
|
|
7
|
+
declare function cleanupFixtures(): void;
|
|
8
|
+
export { createFixture, createFixtureSync, cleanupFixtures };
|
|
9
|
+
export type { FixtureOptions };
|
|
10
|
+
//# sourceMappingURL=fixture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixture.d.ts","sourceRoot":"","sources":["../../source/testing/fixture.ts"],"names":[],"mappings":"AAEA,UAAU,cAAc;IACtB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,iBAAS,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAC5D,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,GACvB,CAAC,CAyBH;AAED,iBAAe,aAAa,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAC9D,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC,CAGZ;AAED,iBAAS,eAAe,IAAI,IAAI,CAG/B;AAED,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC;AAC7D,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const fixtures = /* @__PURE__ */ new Set();
|
|
2
|
+
function createFixtureSync(html, options) {
|
|
3
|
+
const trimmed = html.trim();
|
|
4
|
+
if (!trimmed) {
|
|
5
|
+
throw new Error("createFixtureSync: HTML string must not be empty");
|
|
6
|
+
}
|
|
7
|
+
const temp = document.createElement("div");
|
|
8
|
+
temp.innerHTML = trimmed;
|
|
9
|
+
const element = temp.firstElementChild;
|
|
10
|
+
if (!element) {
|
|
11
|
+
throw new Error("createFixtureSync: HTML string produced no element");
|
|
12
|
+
}
|
|
13
|
+
if (options?.attributes) {
|
|
14
|
+
for (const [name, value] of Object.entries(options.attributes)) {
|
|
15
|
+
element.setAttribute(name, value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const container = options?.container ?? document.body;
|
|
19
|
+
container.appendChild(element);
|
|
20
|
+
fixtures.add(element);
|
|
21
|
+
return element;
|
|
22
|
+
}
|
|
23
|
+
async function createFixture(html, options) {
|
|
24
|
+
const element = createFixtureSync(html, options);
|
|
25
|
+
return Promise.resolve(element);
|
|
26
|
+
}
|
|
27
|
+
function cleanupFixtures() {
|
|
28
|
+
fixtures.forEach((el) => el.remove());
|
|
29
|
+
fixtures.clear();
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
cleanupFixtures,
|
|
33
|
+
createFixture,
|
|
34
|
+
createFixtureSync
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=fixture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixture.js","sources":["../../source/testing/fixture.ts"],"sourcesContent":["const fixtures: Set<HTMLElement> = new Set();\n\ninterface FixtureOptions {\n container?: HTMLElement;\n attributes?: Record<string, string>;\n}\n\nfunction createFixtureSync<T extends HTMLElement = HTMLElement>(\n html: string,\n options?: FixtureOptions,\n): T {\n const trimmed = html.trim();\n if (!trimmed) {\n throw new Error('createFixtureSync: HTML string must not be empty');\n }\n\n const temp = document.createElement('div');\n temp.innerHTML = trimmed;\n\n const element = temp.firstElementChild as T | null;\n if (!element) {\n throw new Error('createFixtureSync: HTML string produced no element');\n }\n\n if (options?.attributes) {\n for (const [name, value] of Object.entries(options.attributes)) {\n element.setAttribute(name, value);\n }\n }\n\n const container = options?.container ?? document.body;\n container.appendChild(element);\n fixtures.add(element);\n\n return element;\n}\n\nasync function createFixture<T extends HTMLElement = HTMLElement>(\n html: string,\n options?: FixtureOptions,\n): Promise<T> {\n const element = createFixtureSync<T>(html, options);\n return Promise.resolve(element);\n}\n\nfunction cleanupFixtures(): void {\n fixtures.forEach((el) => el.remove());\n fixtures.clear();\n}\n\nexport { createFixture, createFixtureSync, cleanupFixtures };\nexport type { FixtureOptions };\n"],"names":[],"mappings":"AAAA,MAAM,+BAAiC,IAAA;AAOvC,SAAS,kBACP,MACA,SACG;AACH,QAAM,UAAU,KAAK,KAAA;AACrB,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AAEA,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,OAAK,YAAY;AAEjB,QAAM,UAAU,KAAK;AACrB,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AAEA,MAAI,SAAS,YAAY;AACvB,eAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,QAAQ,UAAU,GAAG;AAC9D,cAAQ,aAAa,MAAM,KAAK;AAAA,IAClC;AAAA,EACF;AAEA,QAAM,YAAY,SAAS,aAAa,SAAS;AACjD,YAAU,YAAY,OAAO;AAC7B,WAAS,IAAI,OAAO;AAEpB,SAAO;AACT;AAEA,eAAe,cACb,MACA,SACY;AACZ,QAAM,UAAU,kBAAqB,MAAM,OAAO;AAClD,SAAO,QAAQ,QAAQ,OAAO;AAChC;AAEA,SAAS,kBAAwB;AAC/B,WAAS,QAAQ,CAAC,OAAO,GAAG,QAAQ;AACpC,WAAS,MAAA;AACX;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createFixture, createFixtureSync, cleanupFixtures, } from './fixture';
|
|
2
|
+
export type { FixtureOptions } from './fixture';
|
|
3
|
+
export { queryShadow, queryShadowAll, getShadowStyles, getShadowHTML, } from './shadow';
|
|
4
|
+
export { simulateEvent, waitForEvent, captureEvents, } from './events';
|
|
5
|
+
export { createSlotContent, assertSlot, isAllowedElement, getSlotElements, } from './slots';
|
|
6
|
+
export { captureConsole, captureConsoleAsync, captureWarnings, captureWarningsAsync, } from './console';
|
|
7
|
+
export type { ConsoleMethod } from './console';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,GACd,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare function queryShadow<T extends Element = Element>(host: HTMLElement, selector: string): T | null;
|
|
2
|
+
declare function queryShadowAll<T extends Element = Element>(host: HTMLElement, selector: string): T[];
|
|
3
|
+
declare function getShadowStyles(host: HTMLElement): string | null;
|
|
4
|
+
declare function getShadowHTML(host: HTMLElement): string | null;
|
|
5
|
+
export { queryShadow, queryShadowAll, getShadowStyles, getShadowHTML };
|
|
6
|
+
//# sourceMappingURL=shadow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow.d.ts","sourceRoot":"","sources":["../../source/testing/shadow.ts"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAC9C,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,GACf,CAAC,GAAG,IAAI,CAEV;AAED,iBAAS,cAAc,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EACjD,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,GACf,CAAC,EAAE,CAGL;AAED,iBAAS,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAIzD;AAED,iBAAS,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAOvD;AAED,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function queryShadow(host, selector) {
|
|
2
|
+
return host.shadowRoot?.querySelector(selector) ?? null;
|
|
3
|
+
}
|
|
4
|
+
function queryShadowAll(host, selector) {
|
|
5
|
+
if (!host.shadowRoot) return [];
|
|
6
|
+
return Array.from(host.shadowRoot.querySelectorAll(selector));
|
|
7
|
+
}
|
|
8
|
+
function getShadowStyles(host) {
|
|
9
|
+
if (!host.shadowRoot) return null;
|
|
10
|
+
const style = host.shadowRoot.querySelector("style");
|
|
11
|
+
return style?.textContent ?? null;
|
|
12
|
+
}
|
|
13
|
+
function getShadowHTML(host) {
|
|
14
|
+
if (!host.shadowRoot) return null;
|
|
15
|
+
const temp = document.createElement("div");
|
|
16
|
+
temp.innerHTML = host.shadowRoot.innerHTML;
|
|
17
|
+
temp.querySelectorAll("style").forEach((el) => el.remove());
|
|
18
|
+
const result = temp.innerHTML.trim();
|
|
19
|
+
return result || null;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
getShadowHTML,
|
|
23
|
+
getShadowStyles,
|
|
24
|
+
queryShadow,
|
|
25
|
+
queryShadowAll
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=shadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow.js","sources":["../../source/testing/shadow.ts"],"sourcesContent":["function queryShadow<T extends Element = Element>(\n host: HTMLElement,\n selector: string,\n): T | null {\n return host.shadowRoot?.querySelector<T>(selector) ?? null;\n}\n\nfunction queryShadowAll<T extends Element = Element>(\n host: HTMLElement,\n selector: string,\n): T[] {\n if (!host.shadowRoot) return [];\n return Array.from(host.shadowRoot.querySelectorAll<T>(selector));\n}\n\nfunction getShadowStyles(host: HTMLElement): string | null {\n if (!host.shadowRoot) return null;\n const style = host.shadowRoot.querySelector('style');\n return style?.textContent ?? null;\n}\n\nfunction getShadowHTML(host: HTMLElement): string | null {\n if (!host.shadowRoot) return null;\n const temp = document.createElement('div');\n temp.innerHTML = host.shadowRoot.innerHTML;\n temp.querySelectorAll('style').forEach((el) => el.remove());\n const result = temp.innerHTML.trim();\n return result || null;\n}\n\nexport { queryShadow, queryShadowAll, getShadowStyles, getShadowHTML };\n"],"names":[],"mappings":"AAAA,SAAS,YACP,MACA,UACU;AACV,SAAO,KAAK,YAAY,cAAiB,QAAQ,KAAK;AACxD;AAEA,SAAS,eACP,MACA,UACK;AACL,MAAI,CAAC,KAAK,WAAY,QAAO,CAAA;AAC7B,SAAO,MAAM,KAAK,KAAK,WAAW,iBAAoB,QAAQ,CAAC;AACjE;AAEA,SAAS,gBAAgB,MAAkC;AACzD,MAAI,CAAC,KAAK,WAAY,QAAO;AAC7B,QAAM,QAAQ,KAAK,WAAW,cAAc,OAAO;AACnD,SAAO,OAAO,eAAe;AAC/B;AAEA,SAAS,cAAc,MAAkC;AACvD,MAAI,CAAC,KAAK,WAAY,QAAO;AAC7B,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,OAAK,YAAY,KAAK,WAAW;AACjC,OAAK,iBAAiB,OAAO,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ;AAC1D,QAAM,SAAS,KAAK,UAAU,KAAA;AAC9B,SAAO,UAAU;AACnB;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare function createSlotContent(slotName: string | undefined, content: string | HTMLElement, tag?: string): HTMLElement;
|
|
2
|
+
declare function getSlotElements(host: HTMLElement, slotName?: string): Element[];
|
|
3
|
+
declare function isAllowedElement(element: Element, allowed: string[]): boolean;
|
|
4
|
+
declare function assertSlot(host: HTMLElement, slotName: string, options?: {
|
|
5
|
+
exists?: boolean;
|
|
6
|
+
count?: number;
|
|
7
|
+
allowedElements?: string[];
|
|
8
|
+
}): void;
|
|
9
|
+
export { createSlotContent, assertSlot, isAllowedElement, getSlotElements };
|
|
10
|
+
//# sourceMappingURL=slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../source/testing/slots.ts"],"names":[],"mappings":"AAAA,iBAAS,iBAAiB,CACxB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,MAAM,GAAG,WAAW,EAC7B,GAAG,SAAS,GACX,WAAW,CAcb;AAED,iBAAS,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CASxE;AAED,iBAAS,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAQtE;AAED,iBAAS,UAAU,CACjB,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,GACA,IAAI,CA2BN;AAED,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function createSlotContent(slotName, content, tag = "span") {
|
|
2
|
+
const element = document.createElement(tag);
|
|
3
|
+
if (slotName !== void 0) {
|
|
4
|
+
element.setAttribute("slot", slotName);
|
|
5
|
+
}
|
|
6
|
+
if (typeof content === "string") {
|
|
7
|
+
element.textContent = content;
|
|
8
|
+
} else {
|
|
9
|
+
element.appendChild(content);
|
|
10
|
+
}
|
|
11
|
+
return element;
|
|
12
|
+
}
|
|
13
|
+
function getSlotElements(host, slotName) {
|
|
14
|
+
if (slotName === void 0 || slotName === "default") {
|
|
15
|
+
return Array.from(host.children).filter(
|
|
16
|
+
(child) => !child.hasAttribute("slot")
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return Array.from(host.children).filter(
|
|
20
|
+
(child) => child.getAttribute("slot") === slotName
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
function isAllowedElement(element, allowed) {
|
|
24
|
+
const tagName = element.tagName.toLowerCase();
|
|
25
|
+
return allowed.some((pattern) => {
|
|
26
|
+
if (pattern === "h*") {
|
|
27
|
+
return /^h\d+$/.test(tagName);
|
|
28
|
+
}
|
|
29
|
+
return tagName === pattern.toLowerCase();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function assertSlot(host, slotName, options) {
|
|
33
|
+
const shouldExist = options?.exists ?? true;
|
|
34
|
+
const elements = getSlotElements(host, slotName);
|
|
35
|
+
if (shouldExist && elements.length === 0) {
|
|
36
|
+
throw new Error(`assertSlot: slot "${slotName}" expected content but found none`);
|
|
37
|
+
}
|
|
38
|
+
if (!shouldExist && elements.length > 0) {
|
|
39
|
+
throw new Error(`assertSlot: slot "${slotName}" expected no content but found ${elements.length} element(s)`);
|
|
40
|
+
}
|
|
41
|
+
if (options?.count !== void 0 && elements.length !== options.count) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`assertSlot: slot "${slotName}" expected ${options.count} element(s) but found ${elements.length}`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (options?.allowedElements && elements.length > 0) {
|
|
47
|
+
for (const el of elements) {
|
|
48
|
+
if (!isAllowedElement(el, options.allowedElements)) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`assertSlot: slot "${slotName}" contains disallowed element <${el.tagName.toLowerCase()}>. Allowed: ${options.allowedElements.join(", ")}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
assertSlot,
|
|
58
|
+
createSlotContent,
|
|
59
|
+
getSlotElements,
|
|
60
|
+
isAllowedElement
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=slots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.js","sources":["../../source/testing/slots.ts"],"sourcesContent":["function createSlotContent(\n slotName: string | undefined,\n content: string | HTMLElement,\n tag = 'span',\n): HTMLElement {\n const element = document.createElement(tag);\n\n if (slotName !== undefined) {\n element.setAttribute('slot', slotName);\n }\n\n if (typeof content === 'string') {\n element.textContent = content;\n } else {\n element.appendChild(content);\n }\n\n return element;\n}\n\nfunction getSlotElements(host: HTMLElement, slotName?: string): Element[] {\n if (slotName === undefined || slotName === 'default') {\n return Array.from(host.children).filter(\n (child) => !child.hasAttribute('slot'),\n );\n }\n return Array.from(host.children).filter(\n (child) => child.getAttribute('slot') === slotName,\n );\n}\n\nfunction isAllowedElement(element: Element, allowed: string[]): boolean {\n const tagName = element.tagName.toLowerCase();\n return allowed.some((pattern) => {\n if (pattern === 'h*') {\n return /^h\\d+$/.test(tagName);\n }\n return tagName === pattern.toLowerCase();\n });\n}\n\nfunction assertSlot(\n host: HTMLElement,\n slotName: string,\n options?: {\n exists?: boolean;\n count?: number;\n allowedElements?: string[];\n },\n): void {\n const shouldExist = options?.exists ?? true;\n const elements = getSlotElements(host, slotName);\n\n if (shouldExist && elements.length === 0) {\n throw new Error(`assertSlot: slot \"${slotName}\" expected content but found none`);\n }\n\n if (!shouldExist && elements.length > 0) {\n throw new Error(`assertSlot: slot \"${slotName}\" expected no content but found ${elements.length} element(s)`);\n }\n\n if (options?.count !== undefined && elements.length !== options.count) {\n throw new Error(\n `assertSlot: slot \"${slotName}\" expected ${options.count} element(s) but found ${elements.length}`,\n );\n }\n\n if (options?.allowedElements && elements.length > 0) {\n for (const el of elements) {\n if (!isAllowedElement(el, options.allowedElements)) {\n throw new Error(\n `assertSlot: slot \"${slotName}\" contains disallowed element <${el.tagName.toLowerCase()}>. Allowed: ${options.allowedElements.join(', ')}`,\n );\n }\n }\n }\n}\n\nexport { createSlotContent, assertSlot, isAllowedElement, getSlotElements };\n"],"names":[],"mappings":"AAAA,SAAS,kBACP,UACA,SACA,MAAM,QACO;AACb,QAAM,UAAU,SAAS,cAAc,GAAG;AAE1C,MAAI,aAAa,QAAW;AAC1B,YAAQ,aAAa,QAAQ,QAAQ;AAAA,EACvC;AAEA,MAAI,OAAO,YAAY,UAAU;AAC/B,YAAQ,cAAc;AAAA,EACxB,OAAO;AACL,YAAQ,YAAY,OAAO;AAAA,EAC7B;AAEA,SAAO;AACT;AAEA,SAAS,gBAAgB,MAAmB,UAA8B;AACxE,MAAI,aAAa,UAAa,aAAa,WAAW;AACpD,WAAO,MAAM,KAAK,KAAK,QAAQ,EAAE;AAAA,MAC/B,CAAC,UAAU,CAAC,MAAM,aAAa,MAAM;AAAA,IAAA;AAAA,EAEzC;AACA,SAAO,MAAM,KAAK,KAAK,QAAQ,EAAE;AAAA,IAC/B,CAAC,UAAU,MAAM,aAAa,MAAM,MAAM;AAAA,EAAA;AAE9C;AAEA,SAAS,iBAAiB,SAAkB,SAA4B;AACtE,QAAM,UAAU,QAAQ,QAAQ,YAAA;AAChC,SAAO,QAAQ,KAAK,CAAC,YAAY;AAC/B,QAAI,YAAY,MAAM;AACpB,aAAO,SAAS,KAAK,OAAO;AAAA,IAC9B;AACA,WAAO,YAAY,QAAQ,YAAA;AAAA,EAC7B,CAAC;AACH;AAEA,SAAS,WACP,MACA,UACA,SAKM;AACN,QAAM,cAAc,SAAS,UAAU;AACvC,QAAM,WAAW,gBAAgB,MAAM,QAAQ;AAE/C,MAAI,eAAe,SAAS,WAAW,GAAG;AACxC,UAAM,IAAI,MAAM,qBAAqB,QAAQ,mCAAmC;AAAA,EAClF;AAEA,MAAI,CAAC,eAAe,SAAS,SAAS,GAAG;AACvC,UAAM,IAAI,MAAM,qBAAqB,QAAQ,mCAAmC,SAAS,MAAM,aAAa;AAAA,EAC9G;AAEA,MAAI,SAAS,UAAU,UAAa,SAAS,WAAW,QAAQ,OAAO;AACrE,UAAM,IAAI;AAAA,MACR,qBAAqB,QAAQ,cAAc,QAAQ,KAAK,yBAAyB,SAAS,MAAM;AAAA,IAAA;AAAA,EAEpG;AAEA,MAAI,SAAS,mBAAmB,SAAS,SAAS,GAAG;AACnD,eAAW,MAAM,UAAU;AACzB,UAAI,CAAC,iBAAiB,IAAI,QAAQ,eAAe,GAAG;AAClD,cAAM,IAAI;AAAA,UACR,qBAAqB,QAAQ,kCAAkC,GAAG,QAAQ,aAAa,eAAe,QAAQ,gBAAgB,KAAK,IAAI,CAAC;AAAA,QAAA;AAAA,MAE5I;AAAA,IACF;AAAA,EACF;AACF;"}
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cleanupFixtures, createFixture, createFixtureSync } from "./testing/fixture.js";
|
|
2
|
+
import { getShadowHTML, getShadowStyles, queryShadow, queryShadowAll } from "./testing/shadow.js";
|
|
3
|
+
import { captureEvents, simulateEvent, waitForEvent } from "./testing/events.js";
|
|
4
|
+
import { assertSlot, createSlotContent, getSlotElements, isAllowedElement } from "./testing/slots.js";
|
|
5
|
+
import { captureConsole, captureConsoleAsync, captureWarnings, captureWarningsAsync } from "./testing/console.js";
|
|
6
|
+
export {
|
|
7
|
+
assertSlot,
|
|
8
|
+
captureConsole,
|
|
9
|
+
captureConsoleAsync,
|
|
10
|
+
captureEvents,
|
|
11
|
+
captureWarnings,
|
|
12
|
+
captureWarningsAsync,
|
|
13
|
+
cleanupFixtures,
|
|
14
|
+
createFixture,
|
|
15
|
+
createFixtureSync,
|
|
16
|
+
createSlotContent,
|
|
17
|
+
getShadowHTML,
|
|
18
|
+
getShadowStyles,
|
|
19
|
+
getSlotElements,
|
|
20
|
+
isAllowedElement,
|
|
21
|
+
queryShadow,
|
|
22
|
+
queryShadowAll,
|
|
23
|
+
simulateEvent,
|
|
24
|
+
waitForEvent
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|