@salesforcedevs/dx-components 0.26.1 → 0.27.1
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/lwc.config.json +2 -1
- package/package.json +2 -6
- package/src/modules/{utils-internal → base-elements}/archiveCard/archiveCard.ts +0 -0
- package/src/modules/{utils-internal → base-elements}/headerBase/headerBase.ts +0 -0
- package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.ts +1 -1
- package/src/modules/dx/cardCallout/cardCallout.ts +1 -1
- package/src/modules/dx/cardContent/cardContent.ts +2 -2
- package/src/modules/dx/cardDocs/cardDocs.ts +1 -1
- package/src/modules/dx/cardExpanded/cardExpanded.ts +1 -1
- package/src/modules/dx/cardMinimal/cardMinimal.ts +1 -1
- package/src/modules/dx/cardNews/cardNews.ts +1 -1
- package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.ts +1 -1
- package/src/modules/dx/cardSmall/cardSmall.ts +1 -1
- package/src/modules/dx/codeBlock/codeBlock.ts +1 -1
- package/src/modules/dx/dropdown/dropdown.ts +1 -1
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.ts +1 -1
- package/src/modules/dx/groupText/groupText.ts +1 -1
- package/src/modules/dx/header/header.ts +1 -1
- package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.ts +1 -1
- package/src/modules/dx/headerSearch/headerSearch.ts +1 -1
- package/src/modules/dx/icon/icon.ts +1 -1
- package/src/modules/dx/iconBadge/iconBadge.ts +1 -1
- package/src/modules/dx/input/input.ts +1 -1
- package/src/modules/dx/modalDrawer/modalDrawer.css +40 -0
- package/src/modules/dx/modalDrawer/modalDrawer.html +11 -0
- package/src/modules/dx/modalDrawer/modalDrawer.ts +27 -0
- package/src/modules/dx/podcastSubscription/podcastSubscription.css +1 -2
- package/src/modules/dx/popover/popover.ts +1 -1
- package/src/modules/dx/section/section.ts +1 -1
- package/src/modules/dx/sidebar/sidebar.ts +1 -1
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +2 -5
- package/src/modules/dx/slackCta/slackCta.css +14 -8
- package/src/modules/dx/slackCta/slackCta.html +2 -2
- package/src/modules/dx/slackCta/slackCta.ts +0 -1
- package/src/modules/dx/typeBadge/typeBadge.ts +1 -1
- package/src/modules/{utils-internal → utils}/coveo/coveo.ts +0 -0
- package/src/modules/{utils-internal → utils}/css/css.ts +0 -0
- package/src/modules/{utils-internal → utils}/devices/devices.ts +0 -0
- package/src/modules/utils/highlight/highlight.ts +1 -1
- package/src/modules/{utils-internal → utils}/options/options.ts +0 -0
- package/src/modules/{utils-internal → utils}/prismjs/prismjs.html +0 -0
- package/src/modules/{utils-internal → utils}/prismjs/prismjs.ts +0 -0
- package/src/modules/{utils-internal → utils}/recentSearches/recentSearches.ts +0 -0
- package/src/modules/{utils-internal → utils}/regexps/regexps.ts +0 -0
- package/src/modules/{utils-internal → utils}/seo/seo.ts +0 -0
- package/src/modules/{utils-internal → utils}/slot/slot.ts +0 -0
- package/src/modules/{utils-internal → utils}/wordpress/wordpress.ts +0 -0
- package/src/modules/dx/banner/__tests__/banner.test.ts +0 -33
- package/src/modules/dx/brandThemeProvider/__tests__/brandThemeProvider.test.ts +0 -49
- package/src/modules/dx/brandThemeProvider/brandThemeProvider.stories.ts +0 -321
- package/src/modules/dx/breadcrumbs/__tests__/breadcrumbs.test.ts +0 -140
- package/src/modules/dx/breadcrumbs/__tests__/mockProps.ts +0 -28
- package/src/modules/dx/breadcrumbs/breadcrumbs.stories.ts +0 -39
- package/src/modules/dx/button/__tests__/button.test.ts +0 -107
- package/src/modules/dx/button/button.stories.ts +0 -150
- package/src/modules/dx/cardBlogPost/__tests__/cardBlogPost.test.ts +0 -26
- package/src/modules/dx/cardBlogPost/__tests__/mockProps.ts +0 -12
- package/src/modules/dx/cardBlogPost/cardBlogPost.stories.ts +0 -164
- package/src/modules/dx/cardBlogPostProvider/__tests__/cardBlogPostProvider.test.ts +0 -34
- package/src/modules/dx/cardBlogPostProvider/__tests__/mockWordpressPosts.ts +0 -44
- package/src/modules/dx/cardCallout/__tests__/cardCallout.test.ts +0 -20
- package/src/modules/dx/cardCallout/__tests__/mockProps.ts +0 -7
- package/src/modules/dx/cardCallout/cardCallout.stories.ts +0 -33
- package/src/modules/dx/cardContent/__tests__/cardContent.test.ts +0 -100
- package/src/modules/dx/cardContent/__tests__/mockProps.ts +0 -13
- package/src/modules/dx/cardContent/cardContent.stories.ts +0 -127
- package/src/modules/dx/cardDemo/cardDemo.stories.ts +0 -115
- package/src/modules/dx/cardDocs/__tests__/cardDocs.test.ts +0 -48
- package/src/modules/dx/cardDocs/__tests__/mockProps.ts +0 -9
- package/src/modules/dx/cardDocs/cardDocs.stories.ts +0 -299
- package/src/modules/dx/cardEvent/__tests__/cardEvent.test.ts +0 -95
- package/src/modules/dx/cardEvent/__tests__/mockProps.ts +0 -10
- package/src/modules/dx/cardEvent/cardEvent.stories.ts +0 -153
- package/src/modules/dx/cardExpanded/__tests__/cardExpanded.test.ts +0 -193
- package/src/modules/dx/cardExpanded/__tests__/mockProps.ts +0 -21
- package/src/modules/dx/cardExpanded/cardExpanded.stories.ts +0 -59
- package/src/modules/dx/cardGrid/__tests__/cardMockProps.ts +0 -431
- package/src/modules/dx/cardGrid/__tests__/mockProps.ts +0 -15
- package/src/modules/dx/cardGrid/cardGrid.stories.ts +0 -111
- package/src/modules/dx/cardMinimal/__tests__/cardMinimal.test.ts +0 -87
- package/src/modules/dx/cardMinimal/__tests__/mockProps.ts +0 -10
- package/src/modules/dx/cardMinimal/cardMinimal.stories.ts +0 -32
- package/src/modules/dx/cardNews/__tests__/cardNews.test.ts +0 -58
- package/src/modules/dx/cardNews/__tests__/mockProps.ts +0 -7
- package/src/modules/dx/cardNews/cardNews.stories.ts +0 -115
- package/src/modules/dx/cardPodcastEpisode/__tests__/cardPodcastEpisode.test.ts +0 -68
- package/src/modules/dx/cardPodcastEpisode/cardPodcastEpisode.stories.ts +0 -31
- package/src/modules/dx/cardPodcastEpisodeProvider/__tests__/cardPodcastEpisodeProvider.test.ts +0 -36
- package/src/modules/dx/cardPodcastEpisodeProvider/__tests__/mockWordpressEpisodes.ts +0 -50
- package/src/modules/dx/cardSmall/__tests__/cardSmall.test.ts +0 -66
- package/src/modules/dx/cardSmall/__tests__/mockProps.ts +0 -8
- package/src/modules/dx/cardSmall/cardSmall.stories.ts +0 -166
- package/src/modules/dx/cardTitle/__tests__/cardTitle.test.ts +0 -46
- package/src/modules/dx/cardTrailheadModule/__tests__/cardTrailheadModule.test.ts +0 -18
- package/src/modules/dx/cardTrailheadModule/__tests__/mockProps.ts +0 -11
- package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.stories.ts +0 -122
- package/src/modules/dx/cardVideoPreview/__tests__/cardVideoPreview.test.ts +0 -22
- package/src/modules/dx/cardVideoPreview/__tests__/mockProps.ts +0 -11
- package/src/modules/dx/cardVideoPreview/cardVideoPreview.stories.ts +0 -147
- package/src/modules/dx/checkbox/__tests__/checkbox.test.ts +0 -85
- package/src/modules/dx/checkbox/__tests__/mockProps.ts +0 -5
- package/src/modules/dx/checkbox/checkbox.stories.ts +0 -38
- package/src/modules/dx/checkboxGroup/__tests__/checkboxGroup.test.ts +0 -80
- package/src/modules/dx/checkboxGroup/__tests__/mockProps.ts +0 -14
- package/src/modules/dx/checkboxGroup/checkboxGroup.stories.ts +0 -33
- package/src/modules/dx/codeBlock/__tests__/codeBlock.test.ts +0 -238
- package/src/modules/dx/codeBlock/__tests__/mockProps.ts +0 -160
- package/src/modules/dx/codeBlock/codeBlock.stories.ts +0 -143
- package/src/modules/dx/dropdown/__tests__/dropdown.test.ts +0 -165
- package/src/modules/dx/dropdown/__tests__/mockNestedOptions.ts +0 -96
- package/src/modules/dx/dropdown/__tests__/mockOptions.ts +0 -10
- package/src/modules/dx/dropdown/__tests__/mockProps.ts +0 -6
- package/src/modules/dx/dropdown/dropdown.stories.ts +0 -89
- package/src/modules/dx/dropdownOption/__tests__/dropdownOption.test.ts +0 -112
- package/src/modules/dx/dropdownOption/__tests__/mockProps.ts +0 -20
- package/src/modules/dx/emptyState/__tests__/emptyState.test.ts +0 -52
- package/src/modules/dx/emptyState/__tests__/mockProps.ts +0 -4
- package/src/modules/dx/emptyState/emptyState.stories.ts +0 -45
- package/src/modules/dx/feature/__tests__/feature.test.ts +0 -51
- package/src/modules/dx/feature/__tests__/mockProps.ts +0 -8
- package/src/modules/dx/featureGrid/__tests__/featureGrid.test.ts +0 -21
- package/src/modules/dx/featureGrid/featureGrid.stories.ts +0 -120
- package/src/modules/dx/featuredContentHeader/__tests__/featuredContentHeader.test.ts +0 -178
- package/src/modules/dx/featuredContentHeader/__tests__/mockProps.ts +0 -73
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.stories.ts +0 -153
- package/src/modules/dx/featuresList/__tests__/featuresList.test.ts +0 -43
- package/src/modules/dx/featuresList/__tests__/mockProps.ts +0 -17
- package/src/modules/dx/featuresList/featuresList.stories.ts +0 -30
- package/src/modules/dx/footer/__tests__/footer.test.ts +0 -147
- package/src/modules/dx/footer/__tests__/mockLocales.ts +0 -7
- package/src/modules/dx/footer/footer.stories.ts +0 -88
- package/src/modules/dx/footerOption/__tests__/footerOption.test.ts +0 -34
- package/src/modules/dx/footerOption/__tests__/mockProps.ts +0 -7
- package/src/modules/dx/formattedDateTime/__tests__/formattedDateTime.test.ts +0 -25
- package/src/modules/dx/formattedDateTime/__tests__/mockProps.ts +0 -13
- package/src/modules/dx/formattedDateTime/formattedDateTime.stories.ts +0 -103
- package/src/modules/dx/grid/__tests__/grid.test.ts +0 -32
- package/src/modules/dx/grid/grid.stories.ts +0 -134
- package/src/modules/dx/groupBio/__tests__/groupBio.test.ts +0 -82
- package/src/modules/dx/groupBio/__tests__/mockProps.ts +0 -15
- package/src/modules/dx/groupBio/groupBio.stories.ts +0 -66
- package/src/modules/dx/groupText/__tests__/groupText.test.ts +0 -69
- package/src/modules/dx/groupText/__tests__/mockProps.ts +0 -35
- package/src/modules/dx/groupText/groupText.stories.ts +0 -81
- package/src/modules/dx/header/__tests__/header.test.ts +0 -236
- package/src/modules/dx/header/__tests__/mockNavArchitects.ts +0 -169
- package/src/modules/dx/header/__tests__/mockNavDevelopers.ts +0 -419
- package/src/modules/dx/header/__tests__/mockNavs.ts +0 -115
- package/src/modules/dx/header/__tests__/mockProps.ts +0 -164
- package/src/modules/dx/header/header.stories.ts +0 -172
- package/src/modules/dx/headerMobileNavMenu/__tests__/headerMobileNavMenu.test.ts +0 -123
- package/src/modules/dx/headerMobileNavMenuOption/__tests__/headerMobileNavMenuOption.test.ts +0 -38
- package/src/modules/dx/headerNav/__tests__/headerNav.test.ts +0 -49
- package/src/modules/dx/headerSearch/__tests__/headerSearch.test.ts +0 -182
- package/src/modules/dx/headerSearch/__tests__/mockData.ts +0 -11
- package/src/modules/dx/headerSearch/__tests__/mockProps.ts +0 -6
- package/src/modules/dx/helmet/__tests__/helmet.test.ts +0 -52
- package/src/modules/dx/helmet/helmet.stories.ts +0 -53
- package/src/modules/dx/hr/__tests__/hr.test.ts +0 -53
- package/src/modules/dx/hr/__tests__/mockProps.ts +0 -16
- package/src/modules/dx/hr/hr.stories.ts +0 -50
- package/src/modules/dx/icon/__tests__/icon.test.ts +0 -54
- package/src/modules/dx/icon/icon.stories.ts +0 -100
- package/src/modules/dx/iconBadge/__tests__/iconBadge.test.ts +0 -17
- package/src/modules/dx/iconBadge/iconBadge.stories.ts +0 -32
- package/src/modules/dx/imageAndLabel/__tests__/imageAndLabel.test.ts +0 -39
- package/src/modules/dx/imageAndLabel/__tests__/mockProps.ts +0 -6
- package/src/modules/dx/imageAndLabel/imageAndLabel.stories.ts +0 -48
- package/src/modules/dx/input/__tests__/input.test.ts +0 -357
- package/src/modules/dx/input/input.stories.ts +0 -102
- package/src/modules/dx/instrumentation/__tests__/instrumentation.test.ts +0 -86
- package/src/modules/dx/interactiveImage/__tests__/interactiveImage.test.ts +0 -83
- package/src/modules/dx/interactiveImage/__tests__/mockProps.ts +0 -39
- package/src/modules/dx/interactiveImage/interactiveImage.stories.ts +0 -31
- package/src/modules/dx/lazy/__tests__/lazy.test.ts +0 -43
- package/src/modules/dx/lazy/lazy.stories.ts +0 -132
- package/src/modules/dx/pagination/__tests__/pagination.test.ts +0 -121
- package/src/modules/dx/pagination/pagination.stories.ts +0 -88
- package/src/modules/dx/podcastHost/__tests__/mockProps.ts +0 -8
- package/src/modules/dx/podcastHost/__tests__/podcastHost.test.ts +0 -21
- package/src/modules/dx/podcastHost/podcastHost.stories.ts +0 -17
- package/src/modules/dx/podcastPlayer/__tests__/podcastPlayer.test.ts +0 -20
- package/src/modules/dx/podcastPlayer/podcastPlayer.stories.ts +0 -13
- package/src/modules/dx/podcastSubscription/__tests__/podcastSubscription.test.ts +0 -16
- package/src/modules/dx/podcastSubscription/podcastSubscription.stories.ts +0 -23
- package/src/modules/dx/popover/__tests__/mockProps.ts +0 -8
- package/src/modules/dx/popover/__tests__/popover.test.ts +0 -313
- package/src/modules/dx/popover/popover.stories.ts +0 -82
- package/src/modules/dx/radioGroup/__tests__/mockProps.ts +0 -12
- package/src/modules/dx/radioGroup/__tests__/radioGroup.test.ts +0 -42
- package/src/modules/dx/radioGroup/radioGroup.stories.ts +0 -25
- package/src/modules/dx/relativeDateTime/__tests__/mockProps.ts +0 -55
- package/src/modules/dx/relativeDateTime/__tests__/relativeDateTime.test.ts +0 -52
- package/src/modules/dx/relativeDateTime/relativeDateTime.stories.ts +0 -83
- package/src/modules/dx/searchResults/searchResults.stories.ts +0 -36
- package/src/modules/dx/section/__tests__/section.test.ts +0 -17
- package/src/modules/dx/section/section.stories.ts +0 -381
- package/src/modules/dx/sectionSignup/__tests__/sectionSignup.test.ts +0 -66
- package/src/modules/dx/sectionSignup/sectionSignup.stories.ts +0 -49
- package/src/modules/dx/select/select.stories.ts +0 -59
- package/src/modules/dx/sidebar/__tests__/mockProps.ts +0 -181
- package/src/modules/dx/sidebar/__tests__/mockSearchChangeEmptyEvent.ts +0 -6
- package/src/modules/dx/sidebar/__tests__/mockSearchChangeEvent.ts +0 -527
- package/src/modules/dx/sidebar/__tests__/sidebar.test.ts +0 -568
- package/src/modules/dx/sidebar/sidebar.stories.ts +0 -188
- package/src/modules/dx/sidebarOld/__tests__/mockProps.ts +0 -178
- package/src/modules/dx/sidebarOld/__tests__/sidebarOld.test.ts +0 -570
- package/src/modules/dx/sidebarOld/sidebarOld.stories.ts +0 -139
- package/src/modules/dx/sidebarSearch/__tests__/mockPreloadedState.ts +0 -1686
- package/src/modules/dx/sidebarSearch/__tests__/sidebarSearch.test.ts +0 -175
- package/src/modules/dx/sidebarSearchResult/__tests__/sidebarSearchResult.test.ts +0 -96
- package/src/modules/dx/slackCta/__tests__/slackCta.test.ts +0 -48
- package/src/modules/dx/slackCta/slackCta.stories.ts +0 -25
- package/src/modules/dx/socials/__tests__/socials.test.ts +0 -114
- package/src/modules/dx/socials/socials.stories.ts +0 -24
- package/src/modules/dx/spinner/__tests__/spinner.test.ts +0 -37
- package/src/modules/dx/spinner/spinner.stories.ts +0 -69
- package/src/modules/dx/tab/__tests__/tab.test.ts +0 -129
- package/src/modules/dx/tab/tab.stories.ts +0 -57
- package/src/modules/dx/toc/__tests__/mockProps.ts +0 -28
- package/src/modules/dx/toc/__tests__/toc.test.ts +0 -109
- package/src/modules/dx/toc/toc.stories.ts +0 -26
- package/src/modules/dx/tooltip/__tests__/tooltip.test.ts +0 -22
- package/src/modules/dx/tooltip/tooltip.stories.ts +0 -46
- package/src/modules/dx/topics/__tests__/mockProps.ts +0 -3
- package/src/modules/dx/topics/__tests__/topics.test.ts +0 -31
- package/src/modules/dx/tree/__tests__/mockProps.ts +0 -215
- package/src/modules/dx/tree/__tests__/tree.test.ts +0 -346
- package/src/modules/dx/tree/__tests__/treeHandler.test.ts +0 -194
- package/src/modules/dx/tree/tree.stories.ts +0 -65
- package/src/modules/dx/treeItem/__tests__/mockProps.ts +0 -46
- package/src/modules/dx/treeItem/__tests__/treeItem.test.ts +0 -377
- package/src/modules/dx/treeTile/__tests__/mockProps.ts +0 -16
- package/src/modules/dx/treeTile/__tests__/treeTile.test.ts +0 -168
- package/src/modules/dx/typeBadge/__tests__/typeBadge.test.ts +0 -77
- package/src/modules/dx/typeBadge/typeBadge.stories.ts +0 -114
- package/src/modules/dx/typeBadgeGroup/__tests__/mockProps.ts +0 -11
- package/src/modules/dx/typeBadgeGroup/__tests__/typeBadgeGroup.test.ts +0 -72
- package/src/modules/dx/typeBadgeGroup/typeBadgeGroup.stories.ts +0 -19
- package/src/modules/test-components/buttonTest/buttonTest.html +0 -3
- package/src/modules/test-components/buttonTest/buttonTest.ts +0 -3
- package/src/modules/test-components/codeBlockTest/codeBlockTest.js +0 -4
- package/src/modules/test-components/featureGridTest/featureGridTest.html +0 -7
- package/src/modules/test-components/featureGridTest/featureGridTest.ts +0 -5
- package/src/modules/test-components/instrumentationTest/instrumentationTest.html +0 -4
- package/src/modules/test-components/instrumentationTest/instrumentationTest.ts +0 -8
- package/src/modules/test-components/popoverTest/popoverTest.html +0 -6
- package/src/modules/test-components/popoverTest/popoverTest.ts +0 -5
- package/src/modules/utils/highlight/__tests__/highlight.test.ts +0 -108
- package/src/modules/utils/highlight/__tests__/mockProps.ts +0 -45
- package/src/modules/utils-internal/jest/jest.ts +0 -58
- package/src/modules/utils-internal/recentSearches/__tests__/recentSearches.test.ts +0 -83
- package/src/modules/utils-internal/storybook/storybook.ts +0 -32
- package/src/modules/utils-internal/tests/tests.ts +0 -38
- package/src/modules/utils-internal/wordpress/__tests__/wordpress.test.ts +0 -15
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import Input from "dx/input";
|
|
2
|
-
import { createRenderComponent } from "utils-internal/tests";
|
|
3
|
-
|
|
4
|
-
const TAG = "dx-input";
|
|
5
|
-
const render = createRenderComponent(TAG, Input);
|
|
6
|
-
|
|
7
|
-
const shortcutKey = "k";
|
|
8
|
-
|
|
9
|
-
const windowsUserAgent =
|
|
10
|
-
"Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape6/6.1";
|
|
11
|
-
const macUserAgent =
|
|
12
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15";
|
|
13
|
-
|
|
14
|
-
const mockUserAgent = (userAgent: string) => {
|
|
15
|
-
Object.defineProperty(window.navigator, "userAgent", {
|
|
16
|
-
get: function () {
|
|
17
|
-
return userAgent;
|
|
18
|
-
},
|
|
19
|
-
configurable: true
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const assertErrorRender = (element: any, errorMessage: string) =>
|
|
24
|
-
Promise.resolve().then(() => {
|
|
25
|
-
const inputContainer: HTMLElement =
|
|
26
|
-
element.shadowRoot.querySelector(".input-container");
|
|
27
|
-
expect(inputContainer.classList).toHaveLength(2);
|
|
28
|
-
expect(inputContainer.classList).toContain("has-error");
|
|
29
|
-
|
|
30
|
-
const errorBox: HTMLElement =
|
|
31
|
-
element.shadowRoot.querySelector(".error-message-box");
|
|
32
|
-
expect(errorBox).not.toBeNull();
|
|
33
|
-
expect(errorBox.textContent).toBe(errorMessage);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const assertErrorMissing = (element: any) => {
|
|
37
|
-
const inputContainer: HTMLElement =
|
|
38
|
-
element.shadowRoot.querySelector(".input-container");
|
|
39
|
-
expect(inputContainer.classList).toHaveLength(1);
|
|
40
|
-
expect(element.shadowRoot.querySelector(".error-message-box")).toBeNull();
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
describe(TAG, () => {
|
|
44
|
-
it("renders an input", () => {
|
|
45
|
-
const ariaLabel = "Default label";
|
|
46
|
-
const element = render({ ariaLabel });
|
|
47
|
-
const inputEl = element.shadowRoot.querySelector("input");
|
|
48
|
-
expect(inputEl).not.toBeNull();
|
|
49
|
-
expect(inputEl.ariaLabel).toBe("Default label");
|
|
50
|
-
expect(
|
|
51
|
-
element.shadowRoot.querySelector(
|
|
52
|
-
"label, abbr, dx-icon, .shortcut, dx-button, .error-message-box"
|
|
53
|
-
)
|
|
54
|
-
).toBeNull();
|
|
55
|
-
return expect(element).toBeAccessible();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("renders an input, a label and an abbr", () => {
|
|
59
|
-
const label = "Test label";
|
|
60
|
-
const element = render({
|
|
61
|
-
ariaLabel: "Default label",
|
|
62
|
-
required: true,
|
|
63
|
-
label
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const labelEl: HTMLElement = element.shadowRoot.querySelector("label");
|
|
67
|
-
expect(labelEl).not.toBeNull();
|
|
68
|
-
expect(labelEl.textContent).toBe(`${label}*`);
|
|
69
|
-
|
|
70
|
-
const abbrEl: HTMLElement = labelEl.querySelector("abbr")!;
|
|
71
|
-
expect(abbrEl).not.toBeNull();
|
|
72
|
-
expect(abbrEl?.textContent).toBe("*");
|
|
73
|
-
|
|
74
|
-
const inputEl: HTMLElement = element.shadowRoot.querySelector("input");
|
|
75
|
-
expect(inputEl).not.toBeNull();
|
|
76
|
-
expect(inputEl.getAttribute("id")).toBe(labelEl.getAttribute("for"));
|
|
77
|
-
|
|
78
|
-
expect(
|
|
79
|
-
element.shadowRoot.querySelector(".error-message-box")
|
|
80
|
-
).toBeNull();
|
|
81
|
-
return expect(element).toBeAccessible();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("blurs input on escape", () => {
|
|
85
|
-
const element = render({ ariaLabel: "Default label" });
|
|
86
|
-
const inputEl = element.shadowRoot.querySelector("input");
|
|
87
|
-
const blurMock = jest.fn();
|
|
88
|
-
inputEl.onblur = blurMock;
|
|
89
|
-
inputEl.focus();
|
|
90
|
-
inputEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));
|
|
91
|
-
expect(blurMock).toHaveBeenCalled();
|
|
92
|
-
return expect(element).toBeAccessible();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("can render a specific icon", () => {
|
|
96
|
-
const element = render({ ariaLabel: "Search", iconSymbol: "search" });
|
|
97
|
-
const icons = element.shadowRoot.querySelectorAll("dx-icon");
|
|
98
|
-
const searchIcon = Array.from(icons).filter(
|
|
99
|
-
// @ts-ignore
|
|
100
|
-
(icon) => icon.symbol === "search"
|
|
101
|
-
);
|
|
102
|
-
expect(searchIcon).not.toBeNull();
|
|
103
|
-
return expect(element).toBeAccessible();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("has the correct shortcut elements and renders the control shortcut on windows", () => {
|
|
107
|
-
mockUserAgent(windowsUserAgent);
|
|
108
|
-
|
|
109
|
-
const element = render({ ariaLabel: "Search", shortcutKey: "k" });
|
|
110
|
-
|
|
111
|
-
const shortcutImg = element.shadowRoot.querySelector(".shortcut img");
|
|
112
|
-
expect(shortcutImg.src).toContain("/control.svg");
|
|
113
|
-
|
|
114
|
-
const shortcutSpan = element.shadowRoot.querySelector(".shortcut span");
|
|
115
|
-
expect(shortcutSpan.textContent).toBe(shortcutKey);
|
|
116
|
-
|
|
117
|
-
return expect(element).toBeAccessible();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("renders the command shortcut on mac", () => {
|
|
121
|
-
mockUserAgent(macUserAgent);
|
|
122
|
-
|
|
123
|
-
const element = render({ ariaLabel: "Search", shortcutKey: "k" });
|
|
124
|
-
|
|
125
|
-
const shortcutImg = element.shadowRoot.querySelector(".shortcut img");
|
|
126
|
-
expect(shortcutImg.src).toContain("/command.svg");
|
|
127
|
-
|
|
128
|
-
return expect(element).toBeAccessible();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("focuses the input on shortcut keydown", () => {
|
|
132
|
-
const element = render({ ariaLabel: "Search", shortcutKey });
|
|
133
|
-
|
|
134
|
-
const input = element.shadowRoot.querySelector("input");
|
|
135
|
-
|
|
136
|
-
window.dispatchEvent(
|
|
137
|
-
new KeyboardEvent("keydown", { key: shortcutKey, metaKey: true })
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
expect(input.isSameNode(element.shadowRoot.activeElement)).toBe(true);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it("renders submit button when given submit-label", () => {
|
|
144
|
-
const element = render({ ariaLabel: "Search", submitLabel: "Submit" });
|
|
145
|
-
const buttonEl = element.shadowRoot.querySelector("dx-button");
|
|
146
|
-
expect(buttonEl).not.toBeNull();
|
|
147
|
-
return expect(element).toBeAccessible();
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("fires onsubmit when enter pressed or submit button clicked", () => {
|
|
151
|
-
const element = render({ ariaLabel: "Search", submitLabel: "Submit" });
|
|
152
|
-
const submitMock = jest.fn();
|
|
153
|
-
element.addEventListener("submit", submitMock);
|
|
154
|
-
|
|
155
|
-
const inputEl = element.shadowRoot.querySelector("input");
|
|
156
|
-
inputEl.focus();
|
|
157
|
-
inputEl.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" }));
|
|
158
|
-
|
|
159
|
-
expect(submitMock).toHaveBeenCalledTimes(1);
|
|
160
|
-
|
|
161
|
-
const buttonEl = element.shadowRoot.querySelector("dx-button");
|
|
162
|
-
buttonEl.dispatchEvent(new MouseEvent("click"));
|
|
163
|
-
|
|
164
|
-
expect(submitMock).toHaveBeenCalledTimes(2);
|
|
165
|
-
return expect(element).toBeAccessible();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("fires onchange when input changes", () => {
|
|
169
|
-
const element = render({ ariaLabel: "Search", submitLabel: "Submit" });
|
|
170
|
-
const changeMock = jest.fn();
|
|
171
|
-
element.addEventListener("change", changeMock);
|
|
172
|
-
const inputEl = element.shadowRoot.querySelector("input");
|
|
173
|
-
inputEl.focus();
|
|
174
|
-
|
|
175
|
-
inputEl.value = "test";
|
|
176
|
-
inputEl.dispatchEvent(new KeyboardEvent("input"));
|
|
177
|
-
|
|
178
|
-
expect(changeMock).toHaveBeenCalledTimes(1);
|
|
179
|
-
expect(changeMock.mock.calls[0][0].detail).toEqual("test");
|
|
180
|
-
return expect(element).toBeAccessible();
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("value can be controlled", async () => {
|
|
184
|
-
const element = render({ ariaLabel: "Search", value: "test" });
|
|
185
|
-
const inputEl = element.shadowRoot.querySelector("input");
|
|
186
|
-
|
|
187
|
-
await Promise.resolve();
|
|
188
|
-
expect(inputEl.value).toEqual("test");
|
|
189
|
-
return expect(element).toBeAccessible();
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("applies disabled correctly", () => {
|
|
193
|
-
const element = render({
|
|
194
|
-
ariaLabel: "Search",
|
|
195
|
-
submitLabel: "submit",
|
|
196
|
-
disabled: true
|
|
197
|
-
});
|
|
198
|
-
const inputEl = element.shadowRoot.querySelector("input");
|
|
199
|
-
const buttonEl = element.shadowRoot.querySelector("dx-button");
|
|
200
|
-
expect(inputEl.disabled && buttonEl.disabled).toBeTruthy();
|
|
201
|
-
return expect(element).toBeAccessible();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
[
|
|
205
|
-
["default", {}, "size-small"],
|
|
206
|
-
["large", { size: "large" }, "size-large"]
|
|
207
|
-
].forEach(([size, props, className]) =>
|
|
208
|
-
it(`applies ${size} size correctly`, () => {
|
|
209
|
-
const element = render(props);
|
|
210
|
-
const container = element.shadowRoot.querySelector(".input-group");
|
|
211
|
-
const _className = container.getAttribute("class");
|
|
212
|
-
expect(_className.includes(className)).toBeTruthy();
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
it("shows error box if blurs when dx-input is required and has validityOnBlur as true", () => {
|
|
217
|
-
const missingErrorMessage = "This field is required";
|
|
218
|
-
const element = render({
|
|
219
|
-
ariaLabel: "Default label",
|
|
220
|
-
required: true,
|
|
221
|
-
label: "Test label",
|
|
222
|
-
missingErrorMessage,
|
|
223
|
-
validityOnBlur: true
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
assertErrorMissing(element);
|
|
227
|
-
|
|
228
|
-
const inputEl: HTMLElement = element.shadowRoot.querySelector("input");
|
|
229
|
-
expect(inputEl).not.toBeNull();
|
|
230
|
-
inputEl.dispatchEvent(new Event("blur"));
|
|
231
|
-
|
|
232
|
-
return assertErrorRender(element, missingErrorMessage);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it("has a reportValidity api and return if dx-input has a valid value", () => {
|
|
236
|
-
const element = render({
|
|
237
|
-
ariaLabel: "Default label",
|
|
238
|
-
type: "email",
|
|
239
|
-
label: "Test label"
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
const inputEl: HTMLInputElement =
|
|
243
|
-
element.shadowRoot.querySelector("input");
|
|
244
|
-
inputEl.value = "not_valid_email";
|
|
245
|
-
inputEl.dispatchEvent(new Event("input"));
|
|
246
|
-
|
|
247
|
-
assertErrorMissing(element);
|
|
248
|
-
|
|
249
|
-
const result = element.reportValidity();
|
|
250
|
-
expect(result).toBe(false);
|
|
251
|
-
|
|
252
|
-
return assertErrorRender(element, "Enter valid email");
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it("shows error box if blurs when dx-input format is invalid and has validityOnBlur as true", () => {
|
|
256
|
-
const formatErrorMessage = "The email format is incorrect, try again";
|
|
257
|
-
const element = render({
|
|
258
|
-
ariaLabel: "Default label",
|
|
259
|
-
formatErrorMessage,
|
|
260
|
-
label: "Test label",
|
|
261
|
-
type: "email",
|
|
262
|
-
validityOnBlur: true,
|
|
263
|
-
value: "not_valid_email"
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
assertErrorMissing(element);
|
|
267
|
-
|
|
268
|
-
const inputEl: HTMLInputElement =
|
|
269
|
-
element.shadowRoot.querySelector("input");
|
|
270
|
-
expect(inputEl).not.toBeNull();
|
|
271
|
-
inputEl.dispatchEvent(new Event("blur"));
|
|
272
|
-
|
|
273
|
-
return assertErrorRender(element, formatErrorMessage);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it("returns true and doesn't show errors if required field is populated", () => {
|
|
277
|
-
const element = render({
|
|
278
|
-
ariaLabel: "Default label",
|
|
279
|
-
required: true,
|
|
280
|
-
label: "Test label"
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
const inputEl: HTMLInputElement =
|
|
284
|
-
element.shadowRoot.querySelector("input");
|
|
285
|
-
inputEl.value = "I'm a value";
|
|
286
|
-
inputEl.dispatchEvent(new Event("input"));
|
|
287
|
-
|
|
288
|
-
assertErrorMissing(element);
|
|
289
|
-
|
|
290
|
-
const result = element.reportValidity();
|
|
291
|
-
expect(result).toBe(true);
|
|
292
|
-
|
|
293
|
-
return Promise.resolve().then(() => assertErrorMissing(element));
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it("doesn't show error message as value is a valid email", () => {
|
|
297
|
-
const element = render({
|
|
298
|
-
ariaLabel: "Default label",
|
|
299
|
-
type: "email",
|
|
300
|
-
label: "Test label",
|
|
301
|
-
validityOnBlur: true
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
const inputEl: HTMLInputElement =
|
|
305
|
-
element.shadowRoot.querySelector("input");
|
|
306
|
-
expect(inputEl).not.toBeNull();
|
|
307
|
-
inputEl.value = "email@email.com";
|
|
308
|
-
inputEl.dispatchEvent(new Event("input"));
|
|
309
|
-
|
|
310
|
-
assertErrorMissing(element);
|
|
311
|
-
|
|
312
|
-
inputEl.dispatchEvent(new Event("blur"));
|
|
313
|
-
|
|
314
|
-
return Promise.resolve().then(() => assertErrorMissing(element));
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
it("shows clear button if value is nonempty and clearable is true", () => {
|
|
318
|
-
const element = render({
|
|
319
|
-
value: "test",
|
|
320
|
-
clearable: true
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
const clearButton: HTMLButtonElement =
|
|
324
|
-
element.shadowRoot.querySelector(".clear-button");
|
|
325
|
-
expect(clearButton).not.toBeNull();
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it("doesn't show clear button if no value", () => {
|
|
329
|
-
const element = render({
|
|
330
|
-
value: "",
|
|
331
|
-
clearable: true
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
const clearButton: HTMLButtonElement =
|
|
335
|
-
element.shadowRoot.querySelector(".clear-button");
|
|
336
|
-
expect(clearButton).toBeNull();
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
it("clears input value on click of clear button", async () => {
|
|
340
|
-
const element = render({
|
|
341
|
-
value: "test",
|
|
342
|
-
clearable: true
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
const input: HTMLInputElement =
|
|
346
|
-
element.shadowRoot.querySelector("input");
|
|
347
|
-
expect(input.value).toEqual("test");
|
|
348
|
-
|
|
349
|
-
const clearButton: HTMLButtonElement =
|
|
350
|
-
element.shadowRoot.querySelector(".clear-button");
|
|
351
|
-
clearButton.dispatchEvent(new MouseEvent("click"));
|
|
352
|
-
|
|
353
|
-
await Promise.resolve();
|
|
354
|
-
|
|
355
|
-
expect(input.value).toEqual("");
|
|
356
|
-
});
|
|
357
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { html } from "lit-html";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: "dx/dx-input",
|
|
5
|
-
component: "dx-input"
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const createStyles = (properties: string) => html`
|
|
9
|
-
<style>
|
|
10
|
-
dx-input {
|
|
11
|
-
${properties}
|
|
12
|
-
}
|
|
13
|
-
</style>
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
export const Base = () => html`
|
|
17
|
-
${createStyles(`
|
|
18
|
-
display: block;
|
|
19
|
-
margin-bottom: 25px;
|
|
20
|
-
margin-top: 25px;
|
|
21
|
-
`)}
|
|
22
|
-
|
|
23
|
-
<dx-input placeholder="Example"></dx-input>
|
|
24
|
-
|
|
25
|
-
<dx-input placeholder="Example Clearable" clearable="true"></dx-input>
|
|
26
|
-
|
|
27
|
-
<dx-input placeholder="Example Large" size="large"></dx-input>
|
|
28
|
-
|
|
29
|
-
<dx-input placeholder="Example with Icon" icon-symbol="search"></dx-input>
|
|
30
|
-
|
|
31
|
-
<dx-input placeholder="Submit Example" submit-label="Submit"></dx-input>
|
|
32
|
-
|
|
33
|
-
<dx-input
|
|
34
|
-
placeholder="Submit Example Large"
|
|
35
|
-
submit-label="Submit"
|
|
36
|
-
size="large"
|
|
37
|
-
></dx-input>
|
|
38
|
-
|
|
39
|
-
<dx-input size="small" placeholder="Small Example"></dx-input>
|
|
40
|
-
|
|
41
|
-
<dx-input
|
|
42
|
-
size="small"
|
|
43
|
-
placeholder="Small Example with Icon"
|
|
44
|
-
icon-symbol="search"
|
|
45
|
-
></dx-input>
|
|
46
|
-
|
|
47
|
-
<dx-input
|
|
48
|
-
size="small"
|
|
49
|
-
placeholder="Shortcut Example"
|
|
50
|
-
icon-symbol="search"
|
|
51
|
-
shortcut-key="k"
|
|
52
|
-
></dx-input>
|
|
53
|
-
|
|
54
|
-
<dx-input size="small" placeholder="Enter Email" type="email"></dx-input>
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
export const FormInput = () => html`
|
|
58
|
-
${createStyles(`
|
|
59
|
-
display: block;
|
|
60
|
-
height: 77px;
|
|
61
|
-
`)}
|
|
62
|
-
|
|
63
|
-
<dx-input
|
|
64
|
-
label="Hello Input"
|
|
65
|
-
required="true"
|
|
66
|
-
placeholder="type something..."
|
|
67
|
-
validity-on-blur="true"
|
|
68
|
-
></dx-input>
|
|
69
|
-
|
|
70
|
-
<dx-input
|
|
71
|
-
label="Email"
|
|
72
|
-
placeholder="Email"
|
|
73
|
-
required="true"
|
|
74
|
-
size="small"
|
|
75
|
-
type="email"
|
|
76
|
-
missing-error-message="Enter your email address"
|
|
77
|
-
validity-on-blur="true"
|
|
78
|
-
></dx-input>
|
|
79
|
-
|
|
80
|
-
<dx-input
|
|
81
|
-
label="Custom error email"
|
|
82
|
-
placeholder="Email"
|
|
83
|
-
required="true"
|
|
84
|
-
size="small"
|
|
85
|
-
type="email"
|
|
86
|
-
format-error-message="Check the email format, it's incorrect"
|
|
87
|
-
validity-on-blur="true"
|
|
88
|
-
></dx-input>
|
|
89
|
-
|
|
90
|
-
<dx-input
|
|
91
|
-
label="Not required field"
|
|
92
|
-
size="small"
|
|
93
|
-
validity-on-blur="true"
|
|
94
|
-
></dx-input>
|
|
95
|
-
|
|
96
|
-
<dx-input
|
|
97
|
-
label="With assigned Error"
|
|
98
|
-
size="small"
|
|
99
|
-
error-message="Hey I'm custom"
|
|
100
|
-
validity-on-blur="true"
|
|
101
|
-
></dx-input>
|
|
102
|
-
`;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { track, developerwebTrackEventListener } from "dx/instrumentation";
|
|
2
|
-
import InstrumentationTest from "test-components/instrumentationTest";
|
|
3
|
-
import { createRenderComponent } from "utils-internal/tests";
|
|
4
|
-
|
|
5
|
-
const TAG = "dx-instrumentation";
|
|
6
|
-
const render = createRenderComponent(
|
|
7
|
-
"dx-instrumentation-test",
|
|
8
|
-
InstrumentationTest
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
describe(TAG, () => {
|
|
12
|
-
afterEach(() => {
|
|
13
|
-
delete (window as any).dataLayer;
|
|
14
|
-
delete (window as any).__DX_INSTRUMENTATION_QUEUE__;
|
|
15
|
-
delete (window as any).__DX_INSTRUMENTATION_IS_INITIALIZED__;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("catches bubbled events", () => {
|
|
19
|
-
const element = render();
|
|
20
|
-
|
|
21
|
-
const button = element.shadowRoot.querySelector("button");
|
|
22
|
-
button.dispatchEvent(new MouseEvent("click"));
|
|
23
|
-
expect((window as any).dataLayer.length).toBe(1);
|
|
24
|
-
expect((window as any).dataLayer[0]).toEqual({
|
|
25
|
-
event: "buttonClick",
|
|
26
|
-
buttonName: "default"
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("flushes events dispatched prior to render", () => {
|
|
31
|
-
track(document, "testEvent", { isSentBeforeRender: "yes" });
|
|
32
|
-
expect((window as any).__DX_INSTRUMENTATION_QUEUE__.length).toBe(1);
|
|
33
|
-
|
|
34
|
-
render();
|
|
35
|
-
|
|
36
|
-
expect((window as any).__DX_INSTRUMENTATION_IS_INITIALIZED__).toBe(
|
|
37
|
-
true
|
|
38
|
-
);
|
|
39
|
-
expect((window as any).dataLayer.length).toBe(1);
|
|
40
|
-
expect((window as any).dataLayer[0]).toEqual({
|
|
41
|
-
event: "testEvent",
|
|
42
|
-
isSentBeforeRender: "yes"
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Because Jest runs tests in parallel, and because these tests interact
|
|
47
|
-
// with global scope, this `describe` block needs to remain within the
|
|
48
|
-
// parent one to ensure that it's working with a cleaned-up environment.
|
|
49
|
-
describe("developerwebTrackEventListener", () => {
|
|
50
|
-
let t: ReturnType<developerwebTrackEventListener> | null = null;
|
|
51
|
-
|
|
52
|
-
afterEach(() => {
|
|
53
|
-
if (t !== null) {
|
|
54
|
-
t.remove();
|
|
55
|
-
}
|
|
56
|
-
delete (window as any).dataLayer;
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("catches tracked events", () => {
|
|
60
|
-
// Marked instrumentation as initialized, so we can capture the event
|
|
61
|
-
(window as any).__DX_INSTRUMENTATION_IS_INITIALIZED__ = true;
|
|
62
|
-
|
|
63
|
-
const spy = { track: jest.fn() };
|
|
64
|
-
t = developerwebTrackEventListener([spy]);
|
|
65
|
-
t.add();
|
|
66
|
-
track(document, "testEvent", { isTestEvent: "yes" });
|
|
67
|
-
|
|
68
|
-
expect(spy.track).toHaveBeenCalledTimes(1);
|
|
69
|
-
const { detail, composed, bubbles } = spy.track.mock.calls[0][0];
|
|
70
|
-
expect(detail).toEqual({
|
|
71
|
-
event: "testEvent",
|
|
72
|
-
payload: {
|
|
73
|
-
isTestEvent: "yes"
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
expect(composed).toBe(true);
|
|
77
|
-
expect(bubbles).toBe(true);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("throws an exception if no trackerFns provided", () => {
|
|
81
|
-
expect(() => developerwebTrackEventListener([])).toThrow(
|
|
82
|
-
"No tracker functions passed"
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import Dropdown from "dx/dropdown";
|
|
2
|
-
import InteractiveImage from "dx/interactiveImage";
|
|
3
|
-
import { createRenderComponent } from "utils-internal/tests";
|
|
4
|
-
import {
|
|
5
|
-
mockSingleDownloadPropsAsArray,
|
|
6
|
-
mockSingleDownloadPropsAsString,
|
|
7
|
-
mockMultipleDownloadProps,
|
|
8
|
-
mockMultipleDownloadOptions
|
|
9
|
-
} from "./mockProps";
|
|
10
|
-
|
|
11
|
-
const TAG = "dx-interactive-image";
|
|
12
|
-
const render = createRenderComponent(TAG, InteractiveImage);
|
|
13
|
-
|
|
14
|
-
describe(TAG, () => {
|
|
15
|
-
describe("single download", () => {
|
|
16
|
-
it("is accessible", () => {
|
|
17
|
-
const element = render(mockSingleDownloadPropsAsArray);
|
|
18
|
-
|
|
19
|
-
const sectionEl = element.shadowRoot.querySelector("article");
|
|
20
|
-
expect(sectionEl).not.toBeNull();
|
|
21
|
-
return expect(sectionEl).toBeAccessible();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("has the right download URL when URL passed as string", () => {
|
|
25
|
-
const element = render(mockSingleDownloadPropsAsString);
|
|
26
|
-
|
|
27
|
-
const dropdownEl = element.shadowRoot.querySelector("dx-dropdown");
|
|
28
|
-
expect(dropdownEl).toBeNull();
|
|
29
|
-
const buttonEl =
|
|
30
|
-
element.shadowRoot.querySelector("header dx-button");
|
|
31
|
-
expect(buttonEl).not.toBeNull();
|
|
32
|
-
expect(buttonEl.href).toBe(
|
|
33
|
-
mockSingleDownloadPropsAsString.downloadUrls
|
|
34
|
-
);
|
|
35
|
-
expect(buttonEl.download).toBe("FUsyxR5.jpg");
|
|
36
|
-
return expect(element).toBeAccessible();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("has the right download URL when URL passed as array", () => {
|
|
40
|
-
const element = render(mockSingleDownloadPropsAsArray);
|
|
41
|
-
|
|
42
|
-
const dropdownEl = element.shadowRoot.querySelector("dx-dropdown");
|
|
43
|
-
expect(dropdownEl).toBeNull();
|
|
44
|
-
const buttonEl =
|
|
45
|
-
element.shadowRoot.querySelector("header dx-button");
|
|
46
|
-
expect(buttonEl).not.toBeNull();
|
|
47
|
-
expect(buttonEl.href).toBe(
|
|
48
|
-
mockSingleDownloadPropsAsArray.downloadUrls[0]
|
|
49
|
-
);
|
|
50
|
-
expect(buttonEl.download).toBe("FUsyxR5.jpg");
|
|
51
|
-
return expect(element).toBeAccessible();
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe("multiple downloads", () => {
|
|
56
|
-
it("is accessible", () => {
|
|
57
|
-
const element = render(mockMultipleDownloadProps);
|
|
58
|
-
|
|
59
|
-
const sectionEl = element.shadowRoot.querySelector("article");
|
|
60
|
-
expect(sectionEl).not.toBeNull();
|
|
61
|
-
return expect(sectionEl).toBeAccessible();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("renders a dropdown", () => {
|
|
65
|
-
const element = render(mockMultipleDownloadProps);
|
|
66
|
-
|
|
67
|
-
const dropdownEl: Dropdown =
|
|
68
|
-
element.shadowRoot.querySelector("dx-dropdown");
|
|
69
|
-
expect(dropdownEl).not.toBeNull();
|
|
70
|
-
const { options } = dropdownEl;
|
|
71
|
-
|
|
72
|
-
expect(options).toHaveLength(mockMultipleDownloadOptions.length);
|
|
73
|
-
options.forEach((option, index) => {
|
|
74
|
-
expect(option.id).toBe(mockMultipleDownloadOptions[index].id);
|
|
75
|
-
expect(option.label).toBe(
|
|
76
|
-
mockMultipleDownloadOptions[index].label
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
return expect(element).toBeAccessible();
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export const mockSingleDownloadPropsAsString = {
|
|
2
|
-
title:
|
|
3
|
-
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu",
|
|
4
|
-
featuredSrc: "https://i.imgur.com/FUsyxR5.jpg",
|
|
5
|
-
downloadUrls: "https://i.imgur.com/FUsyxR5.jpg"
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const mockSingleDownloadPropsAsArray = {
|
|
9
|
-
title:
|
|
10
|
-
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu",
|
|
11
|
-
featuredSrc: "https://i.imgur.com/FUsyxR5.jpg",
|
|
12
|
-
downloadUrls: ["https://i.imgur.com/FUsyxR5.jpg"]
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const mockMultipleDownloadProps = {
|
|
16
|
-
title:
|
|
17
|
-
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu",
|
|
18
|
-
featuredSrc: "https://i.imgur.com/FUsyxR5.jpg",
|
|
19
|
-
downloadUrls: [
|
|
20
|
-
"https://i.imgur.com/FUsyxR5.jpg",
|
|
21
|
-
"https://i.imgur.com/FUsyxR5.png",
|
|
22
|
-
"https://i.imgur.com/FUsyxR5.bmp"
|
|
23
|
-
]
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const mockMultipleDownloadOptions = [
|
|
27
|
-
{
|
|
28
|
-
label: "Download as JPG",
|
|
29
|
-
id: mockMultipleDownloadProps.downloadUrls[0]
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
label: "Download as PNG",
|
|
33
|
-
id: mockMultipleDownloadProps.downloadUrls[1]
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
label: "Download as BMP",
|
|
37
|
-
id: mockMultipleDownloadProps.downloadUrls[2]
|
|
38
|
-
}
|
|
39
|
-
];
|