@salesforcedevs/dx-components 0.26.2 → 0.26.3-alpha.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 -7
- 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/newsletterForm/newsletterForm.html +3 -3
- 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/sidebarOld/sidebarOld.html +1 -1
- package/src/modules/dx/sidebarOld/sidebarOld.ts +22 -7
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +41 -25
- package/src/modules/dx/slackCta/slackCta.css +1 -1
- package/src/modules/dx/tooltip/microtip.css +1 -0
- package/src/modules/dx/tooltip/tooltip.css +1 -0
- 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 +28 -15
- 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/regexps/regexps.ts +12 -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/LICENSE +0 -12
- 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 -36
- 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/test-components/slackCtaTest/slackCtaTest.html +0 -3
- package/src/modules/test-components/slackCtaTest/slackCtaTest.ts +0 -3
- 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/regexps/regexps.ts +0 -5
- 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,377 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SINGLE_NODE,
|
|
3
|
-
NODE_WITH_CHILDREN,
|
|
4
|
-
SINGLE_NODE_WITH_LINK
|
|
5
|
-
} from "./mockProps";
|
|
6
|
-
import { track } from "dx/instrumentation";
|
|
7
|
-
import TreeItem from "dx/treeItem";
|
|
8
|
-
import TreeTile from "dx/treeTile";
|
|
9
|
-
import { createRenderComponent } from "utils-internal/tests";
|
|
10
|
-
|
|
11
|
-
const TAG = "dx-tree-item";
|
|
12
|
-
const renderComponent = createRenderComponent(TAG, TreeItem);
|
|
13
|
-
|
|
14
|
-
jest.mock("dx/instrumentation");
|
|
15
|
-
|
|
16
|
-
const GTM_EVENT_NAME = "custEv_leftNavLinkClick";
|
|
17
|
-
|
|
18
|
-
const assertTile = (tile: TreeTile, properties: { [key: string]: any }) =>
|
|
19
|
-
Object.keys(properties).forEach((key) =>
|
|
20
|
-
expect(tile).toHaveProperty(key, properties[key])
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
describe(TAG, () => {
|
|
24
|
-
describe("render", () => {
|
|
25
|
-
it("should render as the root with children collapsed", () => {
|
|
26
|
-
const component = renderComponent({
|
|
27
|
-
treeNode: NODE_WITH_CHILDREN,
|
|
28
|
-
isRoot: true
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const link = component.shadowRoot.querySelector("a");
|
|
32
|
-
expect(link).not.toBeNull();
|
|
33
|
-
|
|
34
|
-
const tile: TreeTile =
|
|
35
|
-
component.shadowRoot.querySelector("a > dx-tree-tile");
|
|
36
|
-
expect(tile).not.toBeNull();
|
|
37
|
-
assertTile(tile, {
|
|
38
|
-
isRoot: true,
|
|
39
|
-
treeNode: NODE_WITH_CHILDREN,
|
|
40
|
-
isExpanded: false,
|
|
41
|
-
hasChildren: true,
|
|
42
|
-
isSelected: false
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const childTreeItem =
|
|
46
|
-
component.shadowRoot.querySelector("dx-tree-item");
|
|
47
|
-
expect(childTreeItem).toBeNull();
|
|
48
|
-
|
|
49
|
-
return expect(component).toBeAccessible();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should render the children when it's expanded", () => {
|
|
53
|
-
const treeNode = { ...NODE_WITH_CHILDREN, isExpanded: true };
|
|
54
|
-
const component = renderComponent({
|
|
55
|
-
treeNode
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const tile: TreeTile =
|
|
59
|
-
component.shadowRoot.querySelector("a > dx-tree-tile");
|
|
60
|
-
expect(tile).not.toBeNull();
|
|
61
|
-
assertTile(tile, {
|
|
62
|
-
isRoot: false,
|
|
63
|
-
treeNode,
|
|
64
|
-
isExpanded: true,
|
|
65
|
-
hasChildren: true,
|
|
66
|
-
isSelected: false
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const children: Array<TreeItem> =
|
|
70
|
-
component.shadowRoot.querySelectorAll("dx-tree-item");
|
|
71
|
-
expect(children).toHaveLength(NODE_WITH_CHILDREN.children!.length);
|
|
72
|
-
|
|
73
|
-
children.forEach((child, index) => {
|
|
74
|
-
expect(child.treeNode).toEqual(
|
|
75
|
-
NODE_WITH_CHILDREN.children![index]
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return expect(component).toBeAccessible();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("should render as a selected link", () => {
|
|
83
|
-
const component = renderComponent({
|
|
84
|
-
treeNode: SINGLE_NODE_WITH_LINK,
|
|
85
|
-
selectedKey: SINGLE_NODE_WITH_LINK.key
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const link: HTMLElement = component.shadowRoot.querySelector("a");
|
|
89
|
-
expect(link).not.toBeNull();
|
|
90
|
-
|
|
91
|
-
expect(link.getAttribute("href")).toBe(
|
|
92
|
-
SINGLE_NODE_WITH_LINK.link!.href
|
|
93
|
-
);
|
|
94
|
-
expect(link.getAttribute("target")).toBe(
|
|
95
|
-
SINGLE_NODE_WITH_LINK.link!.target
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
const tile: TreeTile =
|
|
99
|
-
component.shadowRoot.querySelector("a > dx-tree-tile");
|
|
100
|
-
expect(tile).not.toBeNull();
|
|
101
|
-
assertTile(tile, {
|
|
102
|
-
isRoot: false,
|
|
103
|
-
treeNode: SINGLE_NODE_WITH_LINK,
|
|
104
|
-
isExpanded: false,
|
|
105
|
-
hasChildren: false,
|
|
106
|
-
isSelected: true
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const anyChild: TreeItem =
|
|
110
|
-
component.shadowRoot.querySelector("dx-tree-item");
|
|
111
|
-
expect(anyChild).toBeNull();
|
|
112
|
-
|
|
113
|
-
return expect(component).toBeAccessible();
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("should render as a link with default target", () => {
|
|
117
|
-
const expectedPath = "/path";
|
|
118
|
-
const component = renderComponent({
|
|
119
|
-
treeNode: {
|
|
120
|
-
...SINGLE_NODE_WITH_LINK,
|
|
121
|
-
link: { href: expectedPath }
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const link: HTMLElement = component.shadowRoot.querySelector("a");
|
|
126
|
-
expect(link).not.toBeNull();
|
|
127
|
-
|
|
128
|
-
expect(link.getAttribute("href")).toBe(expectedPath);
|
|
129
|
-
expect(link.getAttribute("target")).toBe("_self");
|
|
130
|
-
|
|
131
|
-
return expect(component).toBeAccessible();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("should not render as a selected node if key does not match", () => {
|
|
135
|
-
const component = renderComponent({
|
|
136
|
-
treeNode: SINGLE_NODE_WITH_LINK,
|
|
137
|
-
selectedKey: "not_this"
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
const tile: TreeTile =
|
|
141
|
-
component.shadowRoot.querySelector("a > dx-tree-tile");
|
|
142
|
-
expect(tile).not.toBeNull();
|
|
143
|
-
assertTile(tile, {
|
|
144
|
-
isRoot: false,
|
|
145
|
-
treeNode: SINGLE_NODE_WITH_LINK,
|
|
146
|
-
isExpanded: false,
|
|
147
|
-
hasChildren: false,
|
|
148
|
-
isSelected: false
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
return expect(component).toBeAccessible();
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
describe("interactions", () => {
|
|
156
|
-
const mockExpandCollapse = jest.fn();
|
|
157
|
-
const mockTileSelected = jest.fn();
|
|
158
|
-
|
|
159
|
-
it("should render the children when the dx-tree-tile emits iconclick", () => {
|
|
160
|
-
const component = renderComponent({
|
|
161
|
-
treeNode: NODE_WITH_CHILDREN
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
component.addEventListener("expandcollapse", mockExpandCollapse);
|
|
165
|
-
component.addEventListener("tileselected", mockTileSelected);
|
|
166
|
-
|
|
167
|
-
const anyChild: TreeItem =
|
|
168
|
-
component.shadowRoot.querySelector("dx-tree-item");
|
|
169
|
-
expect(anyChild).toBeNull();
|
|
170
|
-
|
|
171
|
-
const tile: HTMLElement =
|
|
172
|
-
component.shadowRoot.querySelector("dx-tree-tile")!;
|
|
173
|
-
expect(tile).toHaveProperty("isExpanded", false);
|
|
174
|
-
tile.dispatchEvent(new CustomEvent("iconclick"));
|
|
175
|
-
|
|
176
|
-
expect(track).toBeCalledTimes(1);
|
|
177
|
-
expect(track).toBeCalledWith(tile, GTM_EVENT_NAME, {
|
|
178
|
-
clickText: NODE_WITH_CHILDREN.label,
|
|
179
|
-
sideNavAction: "expand"
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
return Promise.resolve().then(() => {
|
|
183
|
-
const children: Array<TreeItem> =
|
|
184
|
-
component.shadowRoot.querySelectorAll("dx-tree-item");
|
|
185
|
-
expect(children).toHaveLength(
|
|
186
|
-
NODE_WITH_CHILDREN.children!.length
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
expect(tile).toHaveProperty("isExpanded", true);
|
|
190
|
-
|
|
191
|
-
expect(mockExpandCollapse).toBeCalledTimes(1);
|
|
192
|
-
expect(mockTileSelected).not.toBeCalled();
|
|
193
|
-
|
|
194
|
-
const [singleCall] = mockExpandCollapse.mock.calls[0];
|
|
195
|
-
expect(singleCall.detail).toEqual({
|
|
196
|
-
key: NODE_WITH_CHILDREN.key
|
|
197
|
-
});
|
|
198
|
-
expect(singleCall.composed).toBe(true);
|
|
199
|
-
expect(singleCall.bubbles).toBe(true);
|
|
200
|
-
|
|
201
|
-
return expect(component).toBeAccessible();
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it("should hide the children when the tile is expanded and dx-tree-tile emits iconclick", () => {
|
|
206
|
-
const component = renderComponent({
|
|
207
|
-
treeNode: { ...NODE_WITH_CHILDREN, isExpanded: true }
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
component.addEventListener("expandcollapse", mockExpandCollapse);
|
|
211
|
-
component.addEventListener("tileselected", mockTileSelected);
|
|
212
|
-
|
|
213
|
-
const tile: HTMLElement =
|
|
214
|
-
component.shadowRoot.querySelector("dx-tree-tile");
|
|
215
|
-
expect(tile).toHaveProperty("isExpanded", true);
|
|
216
|
-
|
|
217
|
-
const children: Array<TreeItem> =
|
|
218
|
-
component.shadowRoot.querySelectorAll("dx-tree-item");
|
|
219
|
-
expect(children).toHaveLength(NODE_WITH_CHILDREN.children!.length);
|
|
220
|
-
|
|
221
|
-
tile.dispatchEvent(new CustomEvent("iconclick"));
|
|
222
|
-
|
|
223
|
-
expect(track).toBeCalledTimes(1);
|
|
224
|
-
expect(track).toBeCalledWith(tile, GTM_EVENT_NAME, {
|
|
225
|
-
clickText: NODE_WITH_CHILDREN.label,
|
|
226
|
-
sideNavAction: "collapse"
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
return Promise.resolve().then(() => {
|
|
230
|
-
expect(tile).toHaveProperty("isExpanded", false);
|
|
231
|
-
|
|
232
|
-
const anyChild: TreeItem =
|
|
233
|
-
component.shadowRoot.querySelector("dx-tree-item");
|
|
234
|
-
expect(anyChild).toBeNull();
|
|
235
|
-
|
|
236
|
-
expect(mockExpandCollapse).toBeCalledTimes(1);
|
|
237
|
-
expect(mockTileSelected).not.toBeCalled();
|
|
238
|
-
|
|
239
|
-
const [singleCall] = mockExpandCollapse.mock.calls[0];
|
|
240
|
-
expect(singleCall.detail).toEqual({
|
|
241
|
-
key: NODE_WITH_CHILDREN.key
|
|
242
|
-
});
|
|
243
|
-
expect(singleCall.composed).toBe(true);
|
|
244
|
-
expect(singleCall.bubbles).toBe(true);
|
|
245
|
-
|
|
246
|
-
return expect(component).toBeAccessible();
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it("should dispatch selectedtile and expandcollapse event as it has children", () => {
|
|
251
|
-
const component = renderComponent({
|
|
252
|
-
treeNode: NODE_WITH_CHILDREN
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
component.addEventListener("tileselected", mockTileSelected);
|
|
256
|
-
component.addEventListener("expandcollapse", mockExpandCollapse);
|
|
257
|
-
|
|
258
|
-
const link: HTMLElement = component.shadowRoot.querySelector("a");
|
|
259
|
-
expect(link).not.toBeNull();
|
|
260
|
-
link.click();
|
|
261
|
-
|
|
262
|
-
expect(track).toBeCalledTimes(1);
|
|
263
|
-
expect(track).toBeCalledWith(link, GTM_EVENT_NAME, {
|
|
264
|
-
clickText: NODE_WITH_CHILDREN.label,
|
|
265
|
-
sideNavAction: "click"
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
return Promise.resolve().then(() => {
|
|
269
|
-
expect(mockExpandCollapse).toBeCalledTimes(1);
|
|
270
|
-
const [expandCall] = mockExpandCollapse.mock.calls[0];
|
|
271
|
-
expect(expandCall.detail).toEqual({
|
|
272
|
-
key: NODE_WITH_CHILDREN.key
|
|
273
|
-
});
|
|
274
|
-
expect(expandCall.composed).toBe(true);
|
|
275
|
-
expect(expandCall.bubbles).toBe(true);
|
|
276
|
-
|
|
277
|
-
expect(mockTileSelected).toBeCalledTimes(1);
|
|
278
|
-
const [tileCall] = mockTileSelected.mock.calls[0];
|
|
279
|
-
expect(tileCall.detail).toEqual({
|
|
280
|
-
name: NODE_WITH_CHILDREN.name,
|
|
281
|
-
key: NODE_WITH_CHILDREN.key
|
|
282
|
-
});
|
|
283
|
-
expect(tileCall.composed).toBe(true);
|
|
284
|
-
expect(tileCall.bubbles).toBe(true);
|
|
285
|
-
|
|
286
|
-
return expect(component).toBeAccessible();
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it("should keep the tile as selected and not dispatch expandcollapse", () => {
|
|
291
|
-
const component = renderComponent({
|
|
292
|
-
treeNode: SINGLE_NODE,
|
|
293
|
-
selectedKey: NODE_WITH_CHILDREN.key
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
component.addEventListener("tileselected", mockTileSelected);
|
|
297
|
-
component.addEventListener("expandcollapse", mockExpandCollapse);
|
|
298
|
-
|
|
299
|
-
const tile: TreeTile =
|
|
300
|
-
component.shadowRoot.querySelector("dx-tree-tile");
|
|
301
|
-
expect(tile).toHaveProperty("isSelected", true);
|
|
302
|
-
|
|
303
|
-
const link: HTMLElement = component.shadowRoot.querySelector("a");
|
|
304
|
-
expect(link).not.toBeNull();
|
|
305
|
-
link.click();
|
|
306
|
-
|
|
307
|
-
return Promise.resolve().then(() => {
|
|
308
|
-
expect(tile).toHaveProperty("isSelected", true);
|
|
309
|
-
expect(mockExpandCollapse).not.toBeCalled();
|
|
310
|
-
|
|
311
|
-
expect(mockTileSelected).toBeCalledTimes(1);
|
|
312
|
-
const [tileCall] = mockTileSelected.mock.calls[0];
|
|
313
|
-
expect(tileCall.detail).toEqual({
|
|
314
|
-
name: NODE_WITH_CHILDREN.name,
|
|
315
|
-
key: NODE_WITH_CHILDREN.key
|
|
316
|
-
});
|
|
317
|
-
expect(tileCall.composed).toBe(true);
|
|
318
|
-
expect(tileCall.bubbles).toBe(true);
|
|
319
|
-
|
|
320
|
-
return expect(component).toBeAccessible();
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it("should fire a register event when is connected and can expand with provided setExpanded function", () => {
|
|
325
|
-
const mockRegister = jest.fn();
|
|
326
|
-
document.addEventListener("register", mockRegister);
|
|
327
|
-
|
|
328
|
-
const component = renderComponent({
|
|
329
|
-
treeNode: NODE_WITH_CHILDREN,
|
|
330
|
-
isRoot: true
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
expect(mockRegister).toBeCalledTimes(1);
|
|
334
|
-
const { key: actualKey, setExpanded } =
|
|
335
|
-
mockRegister.mock.calls[0][0].detail;
|
|
336
|
-
expect(actualKey).toBe(NODE_WITH_CHILDREN.key);
|
|
337
|
-
expect(typeof setExpanded).toBe("function");
|
|
338
|
-
|
|
339
|
-
const tile: TreeTile =
|
|
340
|
-
component.shadowRoot.querySelector("dx-tree-tile");
|
|
341
|
-
expect(tile).not.toBeNull();
|
|
342
|
-
expect(tile).toHaveProperty("isExpanded", false);
|
|
343
|
-
|
|
344
|
-
expect(
|
|
345
|
-
component.shadowRoot.querySelector("dx-tree-item")
|
|
346
|
-
).toBeNull();
|
|
347
|
-
|
|
348
|
-
setExpanded(true);
|
|
349
|
-
|
|
350
|
-
return Promise.resolve().then(() => {
|
|
351
|
-
expect(tile).toHaveProperty("isExpanded", true);
|
|
352
|
-
|
|
353
|
-
const trees =
|
|
354
|
-
component.shadowRoot.querySelectorAll("dx-tree-item");
|
|
355
|
-
expect(trees).toHaveLength(NODE_WITH_CHILDREN.children!.length);
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
it("should call track from dx/instrumentation when link is clicked", () => {
|
|
360
|
-
const component = renderComponent({
|
|
361
|
-
treeNode: SINGLE_NODE_WITH_LINK
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
const link: HTMLAnchorElement =
|
|
365
|
-
component.shadowRoot.querySelector("a");
|
|
366
|
-
expect(link).not.toBeNull();
|
|
367
|
-
|
|
368
|
-
link.click();
|
|
369
|
-
|
|
370
|
-
expect(track).toBeCalledTimes(1);
|
|
371
|
-
expect(track).toBeCalledWith(link, GTM_EVENT_NAME, {
|
|
372
|
-
clickText: SINGLE_NODE_WITH_LINK.label,
|
|
373
|
-
sideNavAction: "click"
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { InternalTreeNode } from "typings/custom";
|
|
2
|
-
|
|
3
|
-
export const SINGLE_NODE: InternalTreeNode = {
|
|
4
|
-
label: "Test label",
|
|
5
|
-
name: "test-name",
|
|
6
|
-
key: "0.1",
|
|
7
|
-
level: 1
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const SINGLE_NODE_WITH_METHOD: InternalTreeNode = {
|
|
11
|
-
label: "Test label",
|
|
12
|
-
name: "test-name",
|
|
13
|
-
key: "0.1",
|
|
14
|
-
level: 1,
|
|
15
|
-
method: "get"
|
|
16
|
-
};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import TreeTile from "dx/treeTile";
|
|
2
|
-
import Icon from "dx/icon";
|
|
3
|
-
import { createRenderComponent } from "utils-internal/tests";
|
|
4
|
-
|
|
5
|
-
import { SINGLE_NODE, SINGLE_NODE_WITH_METHOD } from "./mockProps";
|
|
6
|
-
|
|
7
|
-
const TAG = "dx-tree-tile";
|
|
8
|
-
const render = createRenderComponent(TAG, TreeTile);
|
|
9
|
-
|
|
10
|
-
const assertLevelAndLabel = (container: HTMLElement) => {
|
|
11
|
-
const levelDiv: Element = container.querySelector(
|
|
12
|
-
`[aria-level="${SINGLE_NODE.level + 2}"]`
|
|
13
|
-
)!;
|
|
14
|
-
|
|
15
|
-
expect(levelDiv).not.toBeNull();
|
|
16
|
-
|
|
17
|
-
const tileLabel: Element = levelDiv.querySelector("span.tile-label")!;
|
|
18
|
-
expect(tileLabel).not.toBeNull();
|
|
19
|
-
expect(tileLabel.textContent).toBe(SINGLE_NODE.label);
|
|
20
|
-
expect(tileLabel.getAttribute("title")).toBe(SINGLE_NODE.label);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
describe(TAG, () => {
|
|
24
|
-
describe("render", () => {
|
|
25
|
-
it("should render as a leaf tile", () => {
|
|
26
|
-
const component = render({ treeNode: SINGLE_NODE, href: "/test" });
|
|
27
|
-
const tileAnchor: HTMLElement =
|
|
28
|
-
component.shadowRoot.querySelector("a.tile");
|
|
29
|
-
|
|
30
|
-
expect(tileAnchor.getAttribute("href")).toBe("/test");
|
|
31
|
-
expect(tileAnchor.classList).toHaveLength(2);
|
|
32
|
-
expect(tileAnchor).not.toBeNull();
|
|
33
|
-
assertLevelAndLabel(tileAnchor);
|
|
34
|
-
|
|
35
|
-
const arrowIcon: Icon =
|
|
36
|
-
component.shadowRoot.querySelector("dx-icon");
|
|
37
|
-
expect(arrowIcon).toBeNull();
|
|
38
|
-
|
|
39
|
-
const typeBadge =
|
|
40
|
-
component.shadowRoot.querySelector("dx-type-badge");
|
|
41
|
-
expect(typeBadge).toBeNull();
|
|
42
|
-
|
|
43
|
-
return expect(component).toBeAccessible();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should render as a root tile collapsed", () => {
|
|
47
|
-
const component = render({
|
|
48
|
-
treeNode: SINGLE_NODE,
|
|
49
|
-
isRoot: true,
|
|
50
|
-
hasChildren: true
|
|
51
|
-
});
|
|
52
|
-
const tileAnchor: HTMLElement =
|
|
53
|
-
component.shadowRoot.querySelector("a.tile.tile-root");
|
|
54
|
-
expect(tileAnchor).not.toBeNull();
|
|
55
|
-
expect(tileAnchor.classList).toHaveLength(3);
|
|
56
|
-
assertLevelAndLabel(tileAnchor);
|
|
57
|
-
|
|
58
|
-
const arrowIcon: Icon =
|
|
59
|
-
component.shadowRoot.querySelector("dx-icon")!;
|
|
60
|
-
expect(arrowIcon).not.toBeNull();
|
|
61
|
-
expect(arrowIcon.getAttribute("aria-expanded")).toBe("false");
|
|
62
|
-
expect(arrowIcon.size).toBe("small");
|
|
63
|
-
|
|
64
|
-
const typeBadge =
|
|
65
|
-
component.shadowRoot.querySelector("dx-type-badge");
|
|
66
|
-
expect(typeBadge).toBeNull();
|
|
67
|
-
|
|
68
|
-
return expect(component).toBeAccessible();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("should render an expanded tile with no brand method", () => {
|
|
72
|
-
const component = render({
|
|
73
|
-
treeNode: SINGLE_NODE_WITH_METHOD,
|
|
74
|
-
hasChildren: true,
|
|
75
|
-
isExpanded: true
|
|
76
|
-
});
|
|
77
|
-
const tileAnchor: HTMLElement = component.shadowRoot.querySelector(
|
|
78
|
-
"a.tile.tile-with-children"
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
expect(tileAnchor).not.toBeNull();
|
|
82
|
-
expect(tileAnchor.classList).toHaveLength(3);
|
|
83
|
-
assertLevelAndLabel(tileAnchor);
|
|
84
|
-
|
|
85
|
-
const arrowIcon: Icon =
|
|
86
|
-
component.shadowRoot.querySelector("dx-icon");
|
|
87
|
-
expect(arrowIcon).not.toBeNull();
|
|
88
|
-
expect(arrowIcon.getAttribute("aria-expanded")).toBe("true");
|
|
89
|
-
expect(arrowIcon.size).toBe("xsmall");
|
|
90
|
-
|
|
91
|
-
const typeBadge =
|
|
92
|
-
component.shadowRoot.querySelector("dx-type-badge");
|
|
93
|
-
expect(typeBadge).toBeNull();
|
|
94
|
-
|
|
95
|
-
return expect(component).toBeAccessible();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("should render a selected tile", () => {
|
|
99
|
-
const component = render({
|
|
100
|
-
treeNode: SINGLE_NODE,
|
|
101
|
-
isSelected: true
|
|
102
|
-
});
|
|
103
|
-
const tileAnchor: HTMLElement = component.shadowRoot.querySelector(
|
|
104
|
-
"a.tile.sidebar-item-selected"
|
|
105
|
-
);
|
|
106
|
-
expect(tileAnchor).not.toBeNull();
|
|
107
|
-
expect(tileAnchor.classList).toHaveLength(3);
|
|
108
|
-
|
|
109
|
-
return expect(component).toBeAccessible();
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("should render a leaf tile with a valid brand method", () => {
|
|
113
|
-
const component = render({ treeNode: SINGLE_NODE_WITH_METHOD });
|
|
114
|
-
const typeBadge =
|
|
115
|
-
component.shadowRoot.querySelector("dx-type-badge");
|
|
116
|
-
|
|
117
|
-
expect(typeBadge).not.toBeNull();
|
|
118
|
-
expect(typeBadge.classList).toHaveLength(3);
|
|
119
|
-
expect(typeBadge.classList).toContain(
|
|
120
|
-
SINGLE_NODE_WITH_METHOD.method!
|
|
121
|
-
);
|
|
122
|
-
expect(typeBadge.classList).toContain("flex");
|
|
123
|
-
expect(typeBadge.classList).toContain("tile-icon");
|
|
124
|
-
expect(typeBadge.value).toBe("GET");
|
|
125
|
-
|
|
126
|
-
return expect(component).toBeAccessible();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it("should render a leaf tile with a non valid brand method", () => {
|
|
130
|
-
const method = "not_valid";
|
|
131
|
-
const component = render({
|
|
132
|
-
treeNode: { ...SINGLE_NODE_WITH_METHOD, method }
|
|
133
|
-
});
|
|
134
|
-
const typeBadge =
|
|
135
|
-
component.shadowRoot.querySelector("dx-type-badge");
|
|
136
|
-
|
|
137
|
-
expect(typeBadge).not.toBeNull();
|
|
138
|
-
expect(typeBadge.classList).toHaveLength(3);
|
|
139
|
-
expect(typeBadge.classList).toContain(method);
|
|
140
|
-
expect(typeBadge.classList).toContain("flex");
|
|
141
|
-
expect(typeBadge.classList).toContain("tile-icon");
|
|
142
|
-
expect(typeBadge.value).toBe("");
|
|
143
|
-
|
|
144
|
-
return expect(component).toBeAccessible();
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe("interactions", () => {
|
|
149
|
-
it("should fire iconclick event when the icon is clicked", () => {
|
|
150
|
-
const component = render({
|
|
151
|
-
treeNode: SINGLE_NODE_WITH_METHOD,
|
|
152
|
-
hasChildren: true,
|
|
153
|
-
isExpanded: true
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
const arrowIcon: HTMLElement =
|
|
157
|
-
component.shadowRoot.querySelector("dx-icon");
|
|
158
|
-
|
|
159
|
-
const mockIconClick = jest.fn();
|
|
160
|
-
component.addEventListener("iconclick", mockIconClick);
|
|
161
|
-
|
|
162
|
-
expect(arrowIcon).not.toBeNull();
|
|
163
|
-
arrowIcon.click();
|
|
164
|
-
|
|
165
|
-
expect(mockIconClick).toBeCalledTimes(1);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import TypeBadge from "dx/typeBadge";
|
|
2
|
-
import { createRenderComponent } from "utils-internal/tests";
|
|
3
|
-
import { TypeBadgeSize, BadgeType } from "typings/custom";
|
|
4
|
-
|
|
5
|
-
const TAG = "dx-type-badge";
|
|
6
|
-
const render = createRenderComponent(TAG, TypeBadge);
|
|
7
|
-
|
|
8
|
-
const value = "banana";
|
|
9
|
-
|
|
10
|
-
const assertContainerClasses = (
|
|
11
|
-
container: HTMLElement,
|
|
12
|
-
type: BadgeType = "metadata",
|
|
13
|
-
size: TypeBadgeSize = "default"
|
|
14
|
-
) => {
|
|
15
|
-
expect(container).not.toBeNull();
|
|
16
|
-
expect(container.classList).toHaveLength(3);
|
|
17
|
-
expect(container.classList).toContain("typebadge");
|
|
18
|
-
expect(container.classList).toContain(`typebadge_${type}`);
|
|
19
|
-
expect(container.classList).toContain(`size-${size}`);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
describe(TAG, () => {
|
|
23
|
-
it("renders", () => {
|
|
24
|
-
const element = render({ value });
|
|
25
|
-
const el: HTMLElement = element.shadowRoot.querySelector(".typebadge");
|
|
26
|
-
assertContainerClasses(el);
|
|
27
|
-
expect(el.getAttribute("style")).toBe(null);
|
|
28
|
-
|
|
29
|
-
const spanLabel = el.querySelector("span");
|
|
30
|
-
expect(spanLabel?.textContent).toBe(value);
|
|
31
|
-
|
|
32
|
-
return expect(element).toBeAccessible();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("renders a content-type badge and size small", () => {
|
|
36
|
-
const element = render({ value, type: "content-type", size: "small" });
|
|
37
|
-
const el: HTMLElement = element.shadowRoot.querySelector(".typebadge");
|
|
38
|
-
assertContainerClasses(el, "content-type", "small");
|
|
39
|
-
expect(el.getAttribute("style")).toBe(null);
|
|
40
|
-
|
|
41
|
-
return expect(element).toBeAccessible();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("renders as default type in case type is falsy", () => {
|
|
45
|
-
const element = render({ value, type: null });
|
|
46
|
-
const container = element.shadowRoot.querySelector(".typebadge");
|
|
47
|
-
assertContainerClasses(container);
|
|
48
|
-
expect(container.getAttribute("style")).toBe(null);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("renders with an specific color", () => {
|
|
52
|
-
const element = render({ value, color: "blue" });
|
|
53
|
-
const el: HTMLElement = element.shadowRoot.querySelector(".typebadge");
|
|
54
|
-
|
|
55
|
-
expect(el.getAttribute("style")).toContain(
|
|
56
|
-
"--background: var(--dx-g-blue-vibrant-95)"
|
|
57
|
-
);
|
|
58
|
-
expect(el.getAttribute("style")).toContain(
|
|
59
|
-
"--color: var(--dx-g-blue-vibrant-40)"
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
return expect(element).toBeAccessible();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("can pass a brand as color", () => {
|
|
66
|
-
const element = render({ color: "industries", value });
|
|
67
|
-
|
|
68
|
-
const el = element.shadowRoot.querySelector(".typebadge");
|
|
69
|
-
expect(el.getAttribute("style")).toContain(
|
|
70
|
-
`--color: var(--dx-g-brand-industries-color)`
|
|
71
|
-
);
|
|
72
|
-
expect(el.getAttribute("style")).toContain(
|
|
73
|
-
`--background: var(--dx-g-brand-industries-color-background)`
|
|
74
|
-
);
|
|
75
|
-
return expect(element).toBeAccessible();
|
|
76
|
-
});
|
|
77
|
-
});
|