@arcgis/lumina-compiler 5.2.0-next.2 → 5.2.0-next.21
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/context/index.d.ts +158 -296
- package/dist/context/types.d.ts +18 -34
- package/dist/defaultAssetsUrl.d.ts +6 -6
- package/dist/dependencies/discover.d.ts +43 -35
- package/dist/dependencies/updateLumina.d.ts +10 -11
- package/dist/docs/vsCodeCustomData/types.d.ts +5 -42
- package/dist/docs/webTypes/types.d.ts +5 -76
- package/dist/index.d.ts +20 -20
- package/dist/index.js +12 -8
- package/dist/jsxToLitHtml/config.d.ts +93 -121
- package/dist/options.d.ts +675 -0
- package/dist/puppeteerTesting/index.d.ts +18 -11
- package/dist/puppeteerTesting/index.js +104 -7
- package/dist/puppeteerTesting/puppeteer/element.d.ts +250 -217
- package/dist/puppeteerTesting/puppeteer/events.d.ts +15 -21
- package/dist/puppeteerTesting/puppeteer/page.d.ts +8 -5
- package/dist/puppeteerTesting/puppeteer/types.d.ts +130 -132
- package/dist/puppeteerTesting/vitest/matchers/index.d.ts +33 -30
- package/dist/testing/index.d.ts +4 -11
- package/dist/testing/mount.d.ts +113 -93
- package/dist/testing/wrapController.d.ts +5 -11
- package/dist/useLumina.d.ts +5 -2
- package/package.json +15 -7
- package/dist/context/logger.d.ts +0 -8
- package/dist/context/typeScript.d.ts +0 -6
- package/dist/context/utils.d.ts +0 -4
- package/dist/dependencies/arcgisCore.d.ts +0 -30
- package/dist/dependencies/index.d.ts +0 -12
- package/dist/dependencies/loaders.d.ts +0 -5
- package/dist/dependencies/lumina.d.ts +0 -3
- package/dist/dependencies/stencil.d.ts +0 -17
- package/dist/dependencies/testSetupFiles.d.ts +0 -13
- package/dist/dependencies/utils.d.ts +0 -15
- package/dist/docs/config.d.ts +0 -9
- package/dist/docs/index.d.ts +0 -10
- package/dist/docs/stencilDocsJson.d.ts +0 -130
- package/dist/docs/types.d.ts +0 -1
- package/dist/docs/vsCodeCustomData/index.d.ts +0 -16
- package/dist/docs/vsCodeCustomData/utils.d.ts +0 -3
- package/dist/docs/webTypes/description.d.ts +0 -2
- package/dist/docs/webTypes/index.d.ts +0 -19
- package/dist/docs/webTypes/utils.d.ts +0 -6
- package/dist/entrypoints/addNonLazyImports.d.ts +0 -13
- package/dist/entrypoints/config.d.ts +0 -17
- package/dist/entrypoints/dtsUtils.d.ts +0 -19
- package/dist/entrypoints/findUtils.d.ts +0 -6
- package/dist/entrypoints/handleComponentImports.d.ts +0 -13
- package/dist/entrypoints/resolveTagName.d.ts +0 -18
- package/dist/jsxToLitHtml/autoAddNothing.d.ts +0 -8
- package/dist/jsxToLitHtml/comments.d.ts +0 -19
- package/dist/jsxToLitHtml/convertProps.d.ts +0 -10
- package/dist/jsxToLitHtml/imports.d.ts +0 -27
- package/dist/jsxToLitHtml/importsConfig.d.ts +0 -17
- package/dist/jsxToLitHtml/index.d.ts +0 -20
- package/dist/jsxToLitHtml/inferPropType.d.ts +0 -40
- package/dist/jsxToLitHtml/insertRepeatCall.d.ts +0 -51
- package/dist/jsxToLitHtml/jsxVisitor.d.ts +0 -15
- package/dist/jsxToLitHtml/templateParts.d.ts +0 -17
- package/dist/jsxToLitHtml/throwOnImportingExternalized.d.ts +0 -10
- package/dist/jsxToLitHtml/types.d.ts +0 -74
- package/dist/jsxToLitHtml/utils.d.ts +0 -14
- package/dist/loader/css.d.ts +0 -20
- package/dist/loader/extractor.d.ts +0 -2
- package/dist/loader/index.d.ts +0 -21
- package/dist/loader/lazy.d.ts +0 -21
- package/dist/loader/storybookApiJson.d.ts +0 -6
- package/dist/plugins/buildCdn.d.ts +0 -73
- package/dist/plugins/buildWebApp.d.ts +0 -3
- package/dist/plugins/buildWrappers.d.ts +0 -4
- package/dist/plugins/configureVite.d.ts +0 -20
- package/dist/plugins/externalizeDependencies.d.ts +0 -30
- package/dist/plugins/handleDynamicAssets.d.ts +0 -8
- package/dist/plugins/handleStaticAssets.d.ts +0 -9
- package/dist/plugins/loadLitCss.d.ts +0 -127
- package/dist/plugins/printTotalBuildSize.d.ts +0 -7
- package/dist/plugins/provideAssets.d.ts +0 -35
- package/dist/plugins/setAssetsPath.d.ts +0 -10
- package/dist/plugins/updatePackageJson.d.ts +0 -14
- package/dist/publicTypes.d.ts +0 -653
- package/dist/puppeteerTesting/globalSetup.d.ts +0 -73
- package/dist/puppeteerTesting/injected.d.ts +0 -8
- package/dist/puppeteerTesting/puppeteer/browser.d.ts +0 -6
- package/dist/puppeteerTesting/vitest/matchers/attributes.d.ts +0 -4
- package/dist/puppeteerTesting/vitest/matchers/classList.d.ts +0 -4
- package/dist/puppeteerTesting/vitest/matchers/events.d.ts +0 -7
- package/dist/puppeteerTesting/vitest/matchers/text.d.ts +0 -2
- package/dist/puppeteerTesting/vitest/matchers/utils.d.ts +0 -1
- package/dist/puppeteerTesting/vitest/runner.d.ts +0 -19
- package/dist/puppeteerTesting/vitest/setupFile.d.ts +0 -1
- package/dist/puppeteerTesting/vitest/types.d.ts +0 -6
- package/dist/testing/failOnConsole.d.ts +0 -6
- package/dist/testing/setupFile.d.ts +0 -1
- package/dist/testing/snapshotSerializer.d.ts +0 -12
- package/dist/tests/utils.d.ts +0 -4
- package/dist/transformers/customElementDeclaration.d.ts +0 -2
- package/dist/transformers/index.d.ts +0 -20
- package/dist/transformers/injectRuntimeOptions.d.ts +0 -18
- package/dist/transformers/liftDecorators.d.ts +0 -21
- package/dist/transformers/members.d.ts +0 -10
- package/dist/transformers/property.d.ts +0 -10
- package/dist/transformers/propertyOptions.d.ts +0 -110
- package/dist/transformers/utils.d.ts +0 -9
|
@@ -1,149 +1,147 @@
|
|
|
1
|
-
import { HTTPResponse, Page, WaitForOptions } from
|
|
2
|
-
import { EventSpy } from
|
|
3
|
-
import { E2EElement } from
|
|
1
|
+
import type { HTTPResponse, Page, WaitForOptions } from "puppeteer";
|
|
2
|
+
import type { EventSpy } from "./events.js";
|
|
3
|
+
import type { E2EElement } from "./element.js";
|
|
4
|
+
|
|
4
5
|
export interface PageDiagnostic {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type: "error" | "pageerror" | "requestfailed";
|
|
7
|
+
message?: string;
|
|
8
|
+
location?: string;
|
|
8
9
|
}
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* The E2EPage is a wrapper utility to Puppeteer in order to
|
|
11
13
|
* to create easier to write and read end-to-end tests.
|
|
12
14
|
*/
|
|
13
15
|
export interface E2EPage extends Page {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
_isWaitingForAllReady: boolean;
|
|
107
|
-
/** @private */
|
|
108
|
-
_unhandledError: unknown;
|
|
16
|
+
/** Sets a debugger; */
|
|
17
|
+
debugger(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Find an element that matches the selector, which is the same as
|
|
20
|
+
* `document.querySelector(selector)`. Use `>>>` within the
|
|
21
|
+
* selector to find an element within the host element's shadow root.
|
|
22
|
+
* For example, to select the first `div` inside of the component
|
|
23
|
+
* `my-cmp`, the call would be `page.find('my-cmp >>> div')`.
|
|
24
|
+
* Returns `null` if an element was not found.
|
|
25
|
+
*
|
|
26
|
+
* @param selector
|
|
27
|
+
*/
|
|
28
|
+
find(selector: FindSelector): Promise<E2EElement>;
|
|
29
|
+
/**
|
|
30
|
+
* Find all elements that match the selector, which is the same as
|
|
31
|
+
* `document.querySelectorAll(selector)`. Use `>>>` within the
|
|
32
|
+
* selector to find elements within the host element's shadow root.
|
|
33
|
+
* For example, to select all of the `li` elements inside of the component
|
|
34
|
+
* `my-cmp`, the call would be `page.findAll('my-cmp >>> li')`.
|
|
35
|
+
* Returns an empty array if no elements were found.
|
|
36
|
+
*
|
|
37
|
+
* @param selector
|
|
38
|
+
*/
|
|
39
|
+
findAll(selector: string): Promise<E2EElement[]>;
|
|
40
|
+
/**
|
|
41
|
+
* During an end-to-end test, a dev-server is started so `page.goto(url)` can be used
|
|
42
|
+
* on the app being tested. Urls are always relative since the dev server provides
|
|
43
|
+
* a localhost address. A shortcut to `page.goto(url)` is to set the `url` option
|
|
44
|
+
* when creating a new page, such as `const page = await newE2EPage({ url })`.
|
|
45
|
+
*
|
|
46
|
+
* @param url
|
|
47
|
+
* @param options
|
|
48
|
+
*/
|
|
49
|
+
goTo(url: string, options?: WaitForOptions): Promise<HTTPResponse | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Instead of testing a url directly, html content can be mocked using
|
|
52
|
+
* `page.setContent(html)`. A shortcut to `page.setContent(html)` is to set
|
|
53
|
+
* the `html` option when creating a new page, such as
|
|
54
|
+
* `const page = await newE2EPage({ html })`.
|
|
55
|
+
*
|
|
56
|
+
* @param html
|
|
57
|
+
* @param options
|
|
58
|
+
*/
|
|
59
|
+
setContent(html: string, options?: WaitForOptions): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Used to test if an event was, or was not dispatched. This method
|
|
62
|
+
* returns a promise, that resolves with an EventSpy. The EventSpy
|
|
63
|
+
* can be used along with `expect(spy).toHaveReceivedEvent()`,
|
|
64
|
+
* `expect(spy).toHaveReceivedEventTimes(x)` and
|
|
65
|
+
* `expect(spy).toHaveReceivedEventDetail({...})`.
|
|
66
|
+
*
|
|
67
|
+
* @param eventName
|
|
68
|
+
* @param selector
|
|
69
|
+
*/
|
|
70
|
+
spyOnEvent<Detail = unknown>(eventName: string, selector?: "document" | "window"): Promise<EventSpy<Detail>>;
|
|
71
|
+
/**
|
|
72
|
+
* Puppeteer has asynchronous architecture. Since all calls are async, it's
|
|
73
|
+
* required that `await page.waitForChanges()` is called when changes are
|
|
74
|
+
* made to components.
|
|
75
|
+
* An error will be thrown if changes were made to a component but
|
|
76
|
+
* `waitForChanges()` was not called.
|
|
77
|
+
*
|
|
78
|
+
* @param delay - The number of milliseconds to wait after components
|
|
79
|
+
* finish updating. Default value is determined by the
|
|
80
|
+
* `puppeteerTesting.waitForChangesDelay` option passed to useLumina().
|
|
81
|
+
*/
|
|
82
|
+
waitForChanges(delay?: number): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Waits for the event to be received on `window`. The optional second argument
|
|
85
|
+
* allows the listener to be set to `document` if needed.
|
|
86
|
+
*
|
|
87
|
+
* @param eventName
|
|
88
|
+
*/
|
|
89
|
+
waitForEvent<Detail = unknown>(eventName: string): Promise<SerializedEvent<Detail>>;
|
|
90
|
+
getDiagnostics(): PageDiagnostic[];
|
|
91
|
+
isClosed(): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Causes your script to wait for the given number of milliseconds.
|
|
94
|
+
*
|
|
95
|
+
* It's generally recommended to not wait for a number of seconds, but instead
|
|
96
|
+
* use Frame.waitForSelector, Frame.waitForXPath or
|
|
97
|
+
* Frame.waitForFunction to wait for exactly the conditions you want.
|
|
98
|
+
*
|
|
99
|
+
* @param milliseconds - the number of milliseconds to wait.
|
|
100
|
+
* @example
|
|
101
|
+
* Wait for 1 second:
|
|
102
|
+
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* await page.waitForTimeout(1000);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
waitForTimeout(milliseconds: number): Promise<void>;
|
|
109
108
|
}
|
|
109
|
+
|
|
110
110
|
export interface SerializedEvent<Detail = unknown> {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
111
|
+
bubbles: boolean;
|
|
112
|
+
cancelable: boolean;
|
|
113
|
+
composed: boolean;
|
|
114
|
+
currentTarget: SerializedElement;
|
|
115
|
+
defaultPrevented: boolean;
|
|
116
|
+
detail: Detail;
|
|
117
|
+
eventPhase: number;
|
|
118
|
+
isTrusted: boolean;
|
|
119
|
+
target: SerializedElement;
|
|
120
|
+
timeStamp: number;
|
|
121
|
+
type: string;
|
|
122
|
+
isSerializedEvent: boolean;
|
|
123
123
|
}
|
|
124
|
+
|
|
124
125
|
export type SerializedElement = Record<string, unknown> | null;
|
|
126
|
+
|
|
125
127
|
export type FindSelector = FindSelectorOptions | string;
|
|
128
|
+
|
|
126
129
|
export interface FindSelectorOptions {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
*/
|
|
135
|
-
contains?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Finds an element with text content matching this
|
|
132
|
+
* exact value after the whitespace has been trimmed.
|
|
133
|
+
*/
|
|
134
|
+
text?: string;
|
|
135
|
+
/** Finds an element with text content containing this value. */
|
|
136
|
+
contains?: string;
|
|
136
137
|
}
|
|
138
|
+
|
|
137
139
|
export interface WaitForEventOptions {
|
|
138
|
-
|
|
140
|
+
timeout?: number;
|
|
139
141
|
}
|
|
142
|
+
|
|
140
143
|
export interface WaitForEvent {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
puppeteerAwaitAllReady: () => Promise<void>;
|
|
146
|
-
puppeteerOnEvent: (id: number, event: SerializedEvent) => void;
|
|
147
|
-
puppeteerSerializeEvent: <Detail = unknown>(event: CustomEvent | Event) => SerializedEvent<Detail>;
|
|
148
|
-
puppeteerSerializeEventTarget: (target: Element | EventTarget | null) => SerializedElement;
|
|
149
|
-
}
|
|
144
|
+
eventName: string;
|
|
145
|
+
/** @param event */
|
|
146
|
+
callback(event: SerializedEvent): void;
|
|
147
|
+
}
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
toHaveAttribute: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
|
|
6
|
-
toHaveClass: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
|
|
7
|
-
toHaveClasses: (element: unknown, expectClassNames: string[]) => import('@vitest/expect').SyncExpectationResult;
|
|
8
|
-
toMatchClasses: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
|
|
9
|
-
toHaveReceivedEvent: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
|
|
10
|
-
toHaveReceivedEventTimes: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
|
|
11
|
-
toHaveReceivedEventDetail: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
|
|
12
|
-
toHaveFirstReceivedEventDetail: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
|
|
13
|
-
toHaveLastReceivedEventDetail: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
|
|
14
|
-
toHaveNthReceivedEventDetail: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
|
|
15
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* @knipIgnore Used in ../../index.ts inside a namespace
|
|
4
|
+
*/
|
|
16
5
|
export interface PuppeteerMatchers<R = unknown> {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
/** @internal */
|
|
7
|
+
toEqualAttribute: (expectedAttribute: string, expectedValue: unknown) => R;
|
|
8
|
+
/** @internal */
|
|
9
|
+
toEqualAttributes: (expectedAttributes: Record<string, unknown>) => R;
|
|
10
|
+
/** @internal */
|
|
11
|
+
toEqualHtml: (expectedHtml: string) => R;
|
|
12
|
+
/** @internal */
|
|
13
|
+
toEqualLightHtml: (expectedHtml: string) => R;
|
|
14
|
+
/** @internal */
|
|
15
|
+
toEqualText: (expectedTextContent: string) => R;
|
|
16
|
+
/** @internal */
|
|
17
|
+
toHaveAttribute: (expectedAttributeName: string) => R;
|
|
18
|
+
/** @internal */
|
|
19
|
+
toHaveClass: (classNames: string) => R;
|
|
20
|
+
/** @internal */
|
|
21
|
+
toHaveClasses: (classNames: string[]) => R;
|
|
22
|
+
/** @internal */
|
|
23
|
+
toHaveReceivedEvent: () => R;
|
|
24
|
+
/** @internal */
|
|
25
|
+
toHaveReceivedEventTimes: (count: number) => R;
|
|
26
|
+
/** @internal */
|
|
27
|
+
toHaveReceivedEventDetail: (eventDetail: unknown) => R;
|
|
28
|
+
/** @internal */
|
|
29
|
+
toHaveFirstReceivedEventDetail: (eventDetail: unknown) => R;
|
|
30
|
+
/** @internal */
|
|
31
|
+
toHaveLastReceivedEventDetail: (eventDetail: unknown) => R;
|
|
32
|
+
/** @internal */
|
|
33
|
+
toHaveNthReceivedEventDetail: (index: number, eventDetail: unknown) => R;
|
|
34
|
+
}
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Thus, make sure to not import anything from the rest of the lumina-compiler
|
|
6
|
-
* in this bundle.
|
|
7
|
-
*/
|
|
8
|
-
export type { RenderOptions, RenderResult } from './mount.ts';
|
|
9
|
-
export { mount, findFirstComponent } from './mount.ts';
|
|
10
|
-
export { setupLuminaTest } from './setupFile.ts';
|
|
11
|
-
export { wrapController } from './wrapController.ts';
|
|
1
|
+
export { type RenderOptions, type RenderResult } from "./mount.js";
|
|
2
|
+
export { mount, findFirstComponent } from "./mount.js";
|
|
3
|
+
export { wrapController } from "./wrapController.js";
|
|
4
|
+
|
package/dist/testing/mount.d.ts
CHANGED
|
@@ -1,89 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
1
|
+
import type { DeclareElements, JsxNode, LitElement, ToElement } from "@arcgis/lumina";
|
|
2
|
+
import type { TemplateResult } from "lit";
|
|
3
|
+
|
|
4
|
+
export interface RenderResult<Component extends HTMLElement> {
|
|
5
|
+
/**
|
|
6
|
+
* The custom element proxy that is attached to the DOM.
|
|
7
|
+
*
|
|
8
|
+
* This element will contain all the public properties and public methods of
|
|
9
|
+
* your custom element, but it will not contain any internal members.
|
|
10
|
+
*/
|
|
11
|
+
readonly el: ToElement<Component> & { shadowRoot: ShadowRoot; };
|
|
12
|
+
/**
|
|
13
|
+
* This is the actual LitElement that you authored in the code.
|
|
14
|
+
*
|
|
15
|
+
* It is not directly connected to the DOM (instead, a proxy element is used
|
|
16
|
+
* to facilitate lazy-loading).
|
|
17
|
+
*
|
|
18
|
+
* All public and private members of your custom element are available here.
|
|
19
|
+
*/
|
|
20
|
+
readonly component: Component;
|
|
21
|
+
/**
|
|
22
|
+
* The container element that was used to render the component.
|
|
23
|
+
*
|
|
24
|
+
* This element is useful to inspect for functional components and components
|
|
25
|
+
* that do not use shadow DOM.
|
|
26
|
+
*/
|
|
27
|
+
readonly container: HTMLElement;
|
|
28
|
+
/**
|
|
29
|
+
* A callback for triggering component re-render. Optionally, if the first
|
|
30
|
+
* argument to `mount()` was a function, that function will be called
|
|
31
|
+
* again to get a new template.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* let someValue = 1;
|
|
36
|
+
* const { el, component, reRender } = await mount<ArcgisCounter>(
|
|
37
|
+
* ()=><arcgis-counter someProp={someValue} />
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* someValue = 2;
|
|
41
|
+
* await reRender();
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* The above is roughly equivalent to manually setting `el.someProp = 2`.
|
|
45
|
+
*/
|
|
46
|
+
reRender(): Promise<boolean>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface RenderOptions<Component extends HTMLElement = HTMLElement> {
|
|
50
|
+
/**
|
|
51
|
+
* The parent to attach this component to.
|
|
52
|
+
*
|
|
53
|
+
* @default document.body
|
|
54
|
+
*/
|
|
55
|
+
readonly parent?: DocumentFragment | HTMLElement;
|
|
56
|
+
/**
|
|
57
|
+
* `mount()` will return a promise that resolves after the element
|
|
58
|
+
* is connected to the DOM, fully loaded and rendered.
|
|
59
|
+
*
|
|
60
|
+
* This callback is for executing code right after the element is connected to
|
|
61
|
+
* the DOM, but before it is fully loaded and rendered.
|
|
62
|
+
*
|
|
63
|
+
* @param el
|
|
64
|
+
*/
|
|
65
|
+
afterConnect?(el: ToElement<Component> & { shadowRoot: ShadowRoot; }): Promise<void> | void;
|
|
66
|
+
/**
|
|
67
|
+
* This option only needs to be used if you created the custom element
|
|
68
|
+
* dynamically (inside the test file), rather than in a separate .tsx file.
|
|
69
|
+
* Also, if you already passed the dynamic custom element class as the first
|
|
70
|
+
* argument to `mount()`, you don't need to provide it again here.
|
|
71
|
+
*/
|
|
72
|
+
readonly dynamicComponents?: (typeof LitElement)[];
|
|
73
|
+
/**
|
|
74
|
+
* Whether to cleanup the document body after the test. Set this to false if
|
|
75
|
+
* you wish to reuse the same component between different test() blocks.
|
|
76
|
+
*
|
|
77
|
+
* @default true
|
|
78
|
+
*/
|
|
79
|
+
readonly cleanupAfterTest?: boolean;
|
|
80
|
+
}
|
|
81
|
+
|
|
81
82
|
/**
|
|
82
83
|
* Render Lit Element in a test environment.
|
|
83
84
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
85
|
+
* @param tagName
|
|
86
|
+
* @param options
|
|
87
|
+
* @see https://webgis.esri.com/references/lumina/testing
|
|
87
88
|
* @example
|
|
88
89
|
* ```tsx
|
|
89
90
|
* // Create component based on a tag name
|
|
@@ -93,8 +94,7 @@ export type RenderOptions<Component extends HTMLElement = HTMLElement> = {
|
|
|
93
94
|
* // You can also use the component class as the explicit type annotation:
|
|
94
95
|
* const { el, component } = await mount<ArcgisCounter>(<arcgis-counter />);
|
|
95
96
|
* ```
|
|
96
|
-
*
|
|
97
|
-
* @remarks
|
|
97
|
+
* @example
|
|
98
98
|
* In it's simplest form, what this function is doing is the following:
|
|
99
99
|
*
|
|
100
100
|
* ```tsx
|
|
@@ -104,17 +104,37 @@ export type RenderOptions<Component extends HTMLElement = HTMLElement> = {
|
|
|
104
104
|
* await el.componentOnReady();
|
|
105
105
|
* ```
|
|
106
106
|
*/
|
|
107
|
-
export
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
export
|
|
107
|
+
export function mount<const TagName extends keyof DeclareElements>(tagName: TagName, options?: RenderOptions<DeclareElements[TagName]>): Promise<RenderResult<DeclareElements[TagName]>>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param template
|
|
111
|
+
* @param options
|
|
112
|
+
*/
|
|
113
|
+
export function mount<Class extends typeof LitElement>(template: TemplateResult | (() => JsxNode), options?: RenderOptions<InstanceType<Class>> & { dynamicComponents: [Class]; }): Promise<RenderResult<InstanceType<Class>>>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @param jsx
|
|
117
|
+
* @param options
|
|
118
|
+
*/
|
|
119
|
+
export function mount<TagName extends keyof DeclareElements = never>(jsx: TemplateResult | (() => JsxNode), options?: RenderOptions<[TagName] extends [never] ? LitElement : DeclareElements[TagName]>): Promise<RenderResult<[TagName] extends [never] ? LitElement : DeclareElements[TagName]>>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param template
|
|
123
|
+
* @param options
|
|
124
|
+
*/
|
|
125
|
+
export function mount<Class extends typeof LitElement>(template: Class | TemplateResult | (() => JsxNode), options?: RenderOptions<InstanceType<Class>>): Promise<RenderResult<InstanceType<Class>>>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param template
|
|
129
|
+
* @param options
|
|
130
|
+
*/
|
|
131
|
+
export function mount<Component extends LitElement>(template: TemplateResult | (() => JsxNode) | (new () => Component), options?: RenderOptions<Component>): Promise<RenderResult<Component>>;
|
|
132
|
+
|
|
114
133
|
/**
|
|
115
134
|
* Find the first direct child Lumina component element. If failed to find a
|
|
116
135
|
* direct child, do a priority-first search in the children of the children.
|
|
117
136
|
*
|
|
137
|
+
* @param container
|
|
118
138
|
* @experimental
|
|
119
139
|
*/
|
|
120
|
-
export
|
|
140
|
+
export function findFirstComponent(container: ParentNode): Element | undefined;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { LitElement } from
|
|
1
|
+
import type { LitElement } from "@arcgis/lumina";
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Wrap a controller in a small component - useful when you are interested in
|
|
4
5
|
* only testing the controller behavior.
|
|
5
6
|
*
|
|
7
|
+
* @param controller
|
|
8
|
+
* @param afterConstruct
|
|
6
9
|
* @example
|
|
7
10
|
* ```ts
|
|
8
11
|
* const testController = (): string => makeController(()=>'a');
|
|
9
12
|
* const { component } = await mount(wrapController(testController));
|
|
10
13
|
* expect(component.controller).toEqual("a");
|
|
11
14
|
* ```
|
|
12
|
-
*
|
|
13
15
|
* @example
|
|
14
16
|
* ```ts
|
|
15
17
|
* class TestController extends Controller {
|
|
@@ -21,12 +23,4 @@ import { LitElement } from '@arcgis/lumina';
|
|
|
21
23
|
* expect(controller.a).toEqual("a");
|
|
22
24
|
* ```
|
|
23
25
|
*/
|
|
24
|
-
export
|
|
25
|
-
/**
|
|
26
|
-
* An optional callback to call right after controller constructor
|
|
27
|
-
*/
|
|
28
|
-
afterConstruct?: (component: LitElement & {
|
|
29
|
-
controller: T;
|
|
30
|
-
}) => Promise<void> | void): typeof LitElement & (new () => LitElement & {
|
|
31
|
-
controller: T;
|
|
32
|
-
});
|
|
26
|
+
export function wrapController<T>(controller: ((component: LitElement) => T) | (new (component: LitElement) => T), afterConstruct?: (component: LitElement & { controller: T; }) => Promise<void> | void): typeof LitElement & (new () => LitElement & { controller: T; });
|