@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,114 +0,0 @@
|
|
|
1
|
-
import { html } from "lit-html";
|
|
2
|
-
import { TypeBadgeColor, TypeBadgeSize, BadgeType } from "typings/custom";
|
|
3
|
-
|
|
4
|
-
const BADGE_COLOR_OPTIONS: Array<TypeBadgeColor> = [
|
|
5
|
-
"default",
|
|
6
|
-
"hot-orange",
|
|
7
|
-
"orange",
|
|
8
|
-
"yellow",
|
|
9
|
-
"green",
|
|
10
|
-
"teal",
|
|
11
|
-
"cloud-blue",
|
|
12
|
-
"blue",
|
|
13
|
-
"indigo",
|
|
14
|
-
"purple",
|
|
15
|
-
"violet",
|
|
16
|
-
"pink",
|
|
17
|
-
"red",
|
|
18
|
-
"analytics",
|
|
19
|
-
"employees",
|
|
20
|
-
"marketing",
|
|
21
|
-
"partners",
|
|
22
|
-
"commerce",
|
|
23
|
-
"sales",
|
|
24
|
-
"success",
|
|
25
|
-
"integration",
|
|
26
|
-
"platform",
|
|
27
|
-
"industries",
|
|
28
|
-
"learning",
|
|
29
|
-
"service"
|
|
30
|
-
];
|
|
31
|
-
const SIZE_OPTIONS: Array<TypeBadgeSize> = ["default", "small"];
|
|
32
|
-
const BADGE_TYPE_OPTIONS: Array<BadgeType> = ["metadata", "content-type"];
|
|
33
|
-
|
|
34
|
-
export default {
|
|
35
|
-
title: "dx/dx-type-badge",
|
|
36
|
-
component: "dx-type-badge",
|
|
37
|
-
argTypes: {
|
|
38
|
-
color: {
|
|
39
|
-
control: {
|
|
40
|
-
type: "select"
|
|
41
|
-
},
|
|
42
|
-
options: BADGE_COLOR_OPTIONS
|
|
43
|
-
},
|
|
44
|
-
type: {
|
|
45
|
-
control: {
|
|
46
|
-
type: "select"
|
|
47
|
-
},
|
|
48
|
-
options: BADGE_TYPE_OPTIONS
|
|
49
|
-
},
|
|
50
|
-
size: {
|
|
51
|
-
control: {
|
|
52
|
-
type: "select"
|
|
53
|
-
},
|
|
54
|
-
options: SIZE_OPTIONS
|
|
55
|
-
},
|
|
56
|
-
value: {
|
|
57
|
-
control: {
|
|
58
|
-
type: "text"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const Base = (args: any) => html`
|
|
65
|
-
<dx-type-badge
|
|
66
|
-
value="${args.value}"
|
|
67
|
-
color="${args.color}"
|
|
68
|
-
size="${args.size}"
|
|
69
|
-
type="${args.type}"
|
|
70
|
-
></dx-type-badge>
|
|
71
|
-
`;
|
|
72
|
-
Base.args = {
|
|
73
|
-
color: BADGE_COLOR_OPTIONS[0],
|
|
74
|
-
type: BADGE_TYPE_OPTIONS[0],
|
|
75
|
-
size: SIZE_OPTIONS[0],
|
|
76
|
-
value: "Developer Experience"
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const CSSHooked = () => html`
|
|
80
|
-
<style>
|
|
81
|
-
.hooks {
|
|
82
|
-
--dx-c-type-badge-color: var(--dx-g-green-vibrant-40);
|
|
83
|
-
--dx-c-type-badge-background: var(--dx-g-green-vibrant-90);
|
|
84
|
-
--dx-c-type-badge-border-radius: var(--dx-g-spacing-xl);
|
|
85
|
-
--dx-c-type-badge-height: var(--dx-g-spacing-xl);
|
|
86
|
-
}
|
|
87
|
-
.hookinfo {
|
|
88
|
-
color: gray;
|
|
89
|
-
font-size: 12px;
|
|
90
|
-
}
|
|
91
|
-
</style>
|
|
92
|
-
|
|
93
|
-
<p class="hookinfo">
|
|
94
|
-
<b>--dx-c-type-badge-color:</b> <i>var(--dx-g-green-vibrant-40);</i>
|
|
95
|
-
</p>
|
|
96
|
-
<p class="hookinfo">
|
|
97
|
-
<b>--dx-c-type-badge-background:</b>
|
|
98
|
-
<i>var(--dx-g-green-vibrant-90);</i>
|
|
99
|
-
</p>
|
|
100
|
-
<p class="hookinfo">
|
|
101
|
-
<b>--dx-c-type-badge-border-radius:</b>
|
|
102
|
-
<i>var(--dx-g-spacing-xl);</i>
|
|
103
|
-
</p>
|
|
104
|
-
<p class="hookinfo">
|
|
105
|
-
<b>--dx-c-type-badge-height:</b>
|
|
106
|
-
<i>var(--dx-g-spacing-xl);</i>
|
|
107
|
-
</p>
|
|
108
|
-
<br />
|
|
109
|
-
|
|
110
|
-
<dx-type-badge
|
|
111
|
-
class="hooks"
|
|
112
|
-
value="Hey I am a very loooong text"
|
|
113
|
-
></dx-type-badge>
|
|
114
|
-
`;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import TypeBadge from "dx/typeBadge";
|
|
2
|
-
import TypeBadgeGroup from "dx/typeBadgeGroup";
|
|
3
|
-
import { TypeBadgeSize } from "typings/custom";
|
|
4
|
-
import { createRenderComponent } from "utils-internal/tests";
|
|
5
|
-
import mockProps, { badges } from "./mockProps";
|
|
6
|
-
|
|
7
|
-
const TAG = "dx-type-badge-group";
|
|
8
|
-
const render = createRenderComponent(TAG, TypeBadgeGroup);
|
|
9
|
-
|
|
10
|
-
describe(TAG, () => {
|
|
11
|
-
it("renders correct number of badges", () => {
|
|
12
|
-
const expectedSize: TypeBadgeSize = "medium";
|
|
13
|
-
const element = render(mockProps);
|
|
14
|
-
|
|
15
|
-
const els: Array<TypeBadge> =
|
|
16
|
-
element.shadowRoot.querySelectorAll("dx-type-badge");
|
|
17
|
-
expect(els).toHaveLength(badges.length);
|
|
18
|
-
els.forEach((el, index) => {
|
|
19
|
-
expect(el.value).toBe(badges[index]);
|
|
20
|
-
expect(el.size).toBe(expectedSize);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
return expect(element).toBeAccessible();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("can render a comma delimited string", () => {
|
|
27
|
-
const expectedSize: TypeBadgeSize = "small";
|
|
28
|
-
const element = render({
|
|
29
|
-
badges: "test1,test2,test3",
|
|
30
|
-
size: expectedSize
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const els: Array<TypeBadge> =
|
|
34
|
-
element.shadowRoot.querySelectorAll("dx-type-badge");
|
|
35
|
-
expect(els).toHaveLength(3);
|
|
36
|
-
els.forEach((el) => expect(el.size).toBe(expectedSize));
|
|
37
|
-
expect(els[0].value).toBe("test1");
|
|
38
|
-
expect(els[1].value).toBe("test2");
|
|
39
|
-
expect(els[2].value).toBe("test3");
|
|
40
|
-
|
|
41
|
-
return expect(element).toBeAccessible();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("can render single string value", () => {
|
|
45
|
-
const expectedBadge = "testsinglebadge";
|
|
46
|
-
const element = render({ badges: expectedBadge });
|
|
47
|
-
|
|
48
|
-
const els: Array<TypeBadge> =
|
|
49
|
-
element.shadowRoot.querySelectorAll("dx-type-badge");
|
|
50
|
-
expect(els).toHaveLength(1);
|
|
51
|
-
expect(els[0].value).toBe(expectedBadge);
|
|
52
|
-
|
|
53
|
-
return expect(element).toBeAccessible();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("can render a regular array of string", () => {
|
|
57
|
-
const element = render({ badges });
|
|
58
|
-
|
|
59
|
-
const els: Array<TypeBadge> =
|
|
60
|
-
element.shadowRoot.querySelectorAll("dx-type-badge");
|
|
61
|
-
expect(els).toHaveLength(badges.length);
|
|
62
|
-
els.forEach((el, index) => expect(el.value).toBe(badges[index]));
|
|
63
|
-
|
|
64
|
-
return expect(element).toBeAccessible();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("throws an error if badges value is not compatible", () => {
|
|
68
|
-
expect(() => render({ badges: { test: "badges" } })).toThrow(
|
|
69
|
-
/Key must be a string or number/
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { html } from "lit-html";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: "dx/dx-type-badge-group",
|
|
5
|
-
component: "dx-type-badge-group"
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const Base = () => html`
|
|
9
|
-
<dx-type-badge-group
|
|
10
|
-
badges="Developer Experience, Search Optimization, Analytics"
|
|
11
|
-
></dx-type-badge-group>
|
|
12
|
-
`;
|
|
13
|
-
|
|
14
|
-
export const Small = () => html`
|
|
15
|
-
<dx-type-badge-group
|
|
16
|
-
badges='["Testing", "Traffic Monitoring"]'
|
|
17
|
-
size="small"
|
|
18
|
-
></dx-type-badge-group>
|
|
19
|
-
`;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<dx-feature-grid>
|
|
3
|
-
<dx-feature button-label="Feature 1" title="Feature 1"></dx-feature>
|
|
4
|
-
<dx-feature button-label="Feature 2" title="Feature 2"></dx-feature>
|
|
5
|
-
<dx-feature button-label="Feature 3" title="Feature 3"></dx-feature>
|
|
6
|
-
</dx-feature-grid>
|
|
7
|
-
</template>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { LightningElement } from "lwc";
|
|
2
|
-
import { track } from "dx/instrumentation";
|
|
3
|
-
|
|
4
|
-
export default class InstrumentationTest extends LightningElement {
|
|
5
|
-
handleButtonClick(e: MouseEvent) {
|
|
6
|
-
track(e.currentTarget, "buttonClick", { buttonName: "default" });
|
|
7
|
-
}
|
|
8
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { createElement } from "lwc";
|
|
2
|
-
import CodeBlock from "dx/codeBlock";
|
|
3
|
-
import { highlightTerms } from "utils/highlight";
|
|
4
|
-
import { mockContent, allowedTags } from "./mockProps";
|
|
5
|
-
|
|
6
|
-
const container = document.createElement("div");
|
|
7
|
-
|
|
8
|
-
describe("highlight utility", () => {
|
|
9
|
-
afterEach(() => (container.innerHTML = ""));
|
|
10
|
-
|
|
11
|
-
it("highlights text that matches search criteria", () => {
|
|
12
|
-
container.innerHTML = mockContent;
|
|
13
|
-
highlightTerms(
|
|
14
|
-
container.querySelectorAll(allowedTags.join(",")),
|
|
15
|
-
"apex"
|
|
16
|
-
);
|
|
17
|
-
expect(container.querySelectorAll("mark")).toHaveLength(14);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("doesn't highlight elements that contains dx/docs components", () => {
|
|
21
|
-
const searchTerm = "customreport";
|
|
22
|
-
const codeBlock = createElement("dx-code-block", { is: CodeBlock });
|
|
23
|
-
Object.assign(codeBlock, {
|
|
24
|
-
codeBlock: searchTerm,
|
|
25
|
-
language: "text"
|
|
26
|
-
});
|
|
27
|
-
container.appendChild(document.createElement("p"));
|
|
28
|
-
container.firstElementChild?.appendChild(codeBlock);
|
|
29
|
-
highlightTerms(
|
|
30
|
-
container.querySelectorAll(allowedTags.join(",")),
|
|
31
|
-
searchTerm
|
|
32
|
-
);
|
|
33
|
-
expect(container.querySelectorAll("mark")).toHaveLength(0);
|
|
34
|
-
expect(codeBlock.shadowRoot.innerHTML).toMatch(searchTerm); // sanity check
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("doesn't highlight terms separated by html tags", () => {
|
|
38
|
-
container.innerHTML = "<p>loadData<span>within</span></p>";
|
|
39
|
-
highlightTerms(
|
|
40
|
-
container.querySelectorAll(allowedTags.join(",")),
|
|
41
|
-
"loadDatawithin"
|
|
42
|
-
);
|
|
43
|
-
expect(container.querySelectorAll("mark")).toHaveLength(0);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("escapes regex especial characters", () => {
|
|
47
|
-
container.innerHTML = mockContent;
|
|
48
|
-
highlightTerms(
|
|
49
|
-
container.querySelectorAll(allowedTags.join(",")),
|
|
50
|
-
"apex.+"
|
|
51
|
-
);
|
|
52
|
-
expect(container.querySelectorAll("mark")).toHaveLength(0);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("cleans previous search result before searching for a new term", () => {
|
|
56
|
-
const firstSearch = "apex";
|
|
57
|
-
const secondSearch = "salesforce";
|
|
58
|
-
|
|
59
|
-
container.innerHTML = mockContent;
|
|
60
|
-
|
|
61
|
-
highlightTerms(
|
|
62
|
-
container.querySelectorAll(allowedTags.join(",")),
|
|
63
|
-
firstSearch
|
|
64
|
-
);
|
|
65
|
-
const firstMarks = container.querySelectorAll("mark");
|
|
66
|
-
expect(firstMarks).toHaveLength(14);
|
|
67
|
-
firstMarks.forEach(({ textContent }) =>
|
|
68
|
-
expect(textContent?.toLowerCase()).toBe(firstSearch)
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
highlightTerms(
|
|
72
|
-
container.querySelectorAll(allowedTags.join(",")),
|
|
73
|
-
secondSearch
|
|
74
|
-
);
|
|
75
|
-
const secondMarks = container.querySelectorAll("mark");
|
|
76
|
-
expect(secondMarks).toHaveLength(4);
|
|
77
|
-
secondMarks.forEach(({ textContent }) =>
|
|
78
|
-
expect(textContent?.toLowerCase()).toBe(secondSearch)
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("cleans all marks if the search term is empty string", () => {
|
|
83
|
-
const firstSearch = "apex";
|
|
84
|
-
const secondSearch = "";
|
|
85
|
-
|
|
86
|
-
container.innerHTML = mockContent;
|
|
87
|
-
|
|
88
|
-
highlightTerms(
|
|
89
|
-
container.querySelectorAll(allowedTags.join(",")),
|
|
90
|
-
firstSearch
|
|
91
|
-
);
|
|
92
|
-
const firstMarks = container.querySelectorAll("mark");
|
|
93
|
-
expect(firstMarks).toHaveLength(14);
|
|
94
|
-
firstMarks.forEach(({ textContent }) =>
|
|
95
|
-
expect(textContent?.toLowerCase()).toBe(firstSearch)
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
highlightTerms(
|
|
99
|
-
container.querySelectorAll(allowedTags.join(",")),
|
|
100
|
-
secondSearch
|
|
101
|
-
);
|
|
102
|
-
const secondMarks = container.querySelectorAll("mark");
|
|
103
|
-
expect(secondMarks).toHaveLength(0);
|
|
104
|
-
secondMarks.forEach(({ textContent }) =>
|
|
105
|
-
expect(textContent?.toLowerCase()).toBe(secondSearch)
|
|
106
|
-
);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export const mockContent = `<div><a name='apex_dev_guide'><!-- --></a><h1 class='helpHead1'>Apex Developer Guide</h1><div class='shortdesc'>Salesforce has changed the way organizations do business by moving enterprise
|
|
2
|
-
applications that were traditionally client-server-based into the Lightning Platform, an
|
|
3
|
-
on-demand, multitenant Web environment. This environment enables you to run and customize
|
|
4
|
-
applications, such as Salesforce Automation and Service & Support, and build new custom
|
|
5
|
-
applications based on particular business needs. </div><div id='sfdc:seealso' class='related-links'>
|
|
6
|
-
<ul class='ullinks'>
|
|
7
|
-
<li class='link ulchildlink'>
|
|
8
|
-
<strong><a href='atlas.en-us.apexcode.meta/apexcode/apex_intro_get_started.htm'>Getting Started with Apex</a></strong><br>
|
|
9
|
-
Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the Lightning Platform server, in conjunction with calls to the API.</li>
|
|
10
|
-
<li class='link ulchildlink'>
|
|
11
|
-
<strong><a href='atlas.en-us.apexcode.meta/apexcode/apex_writing.htm'>Writing Apex</a></strong><br>
|
|
12
|
-
Apex is like Java for Salesforce. It enables you to add and interact with data in the Lightning Platform persistence layer. It uses classes, data types, variables, and if-else statements. You can make it execute based on a condition, or have a block of code execute repeatedly.</li>
|
|
13
|
-
<li class='link ulchildlink'>
|
|
14
|
-
<strong><a href='atlas.en-us.apexcode.meta/apexcode/apex_running.htm'>Running Apex</a></strong><br>
|
|
15
|
-
You can access many features of the Salesforce user interface programmatically in Apex, and you can integrate with external SOAP and REST Web services. You can run Apex code using a variety of mechanisms. Apex code runs in atomic transactions. </li>
|
|
16
|
-
<li class='link ulchildlink'>
|
|
17
|
-
<strong><a href='atlas.en-us.apexcode.meta/apexcode/apex_debug_test_deploy.htm'>Debugging, Testing, and Deploying Apex</a></strong><br>
|
|
18
|
-
Develop your Apex code in a sandbox and debug it with the Developer Console and debug logs. Unit-test your code, then distribute it to customers using packages.</li>
|
|
19
|
-
<li class='link ulchildlink'>
|
|
20
|
-
<strong><a href='atlas.en-us.apexcode.meta/apexcode/apex_reference.htm'>Apex Language Reference</a></strong><br>
|
|
21
|
-
This Apex reference goes into detail about DML statements and the built-in Apex classes and interfaces.</li>
|
|
22
|
-
<li class='link ulchildlink'>
|
|
23
|
-
<strong><a href='atlas.en-us.apexcode.meta/apexcode/apex_appendices.htm'>Appendices</a></strong><br>
|
|
24
|
-
</li>
|
|
25
|
-
<li class='link ulchildlink'>
|
|
26
|
-
<strong><a href='atlas.en-us.apexcode.meta/apexcode/glossary_apex.htm'>Glossary</a></strong><br>
|
|
27
|
-
</li>
|
|
28
|
-
</ul>
|
|
29
|
-
</div><!--DRC 228.7--></div>`;
|
|
30
|
-
|
|
31
|
-
export const allowedTags = [
|
|
32
|
-
"p",
|
|
33
|
-
".p",
|
|
34
|
-
".shortdesc",
|
|
35
|
-
"h1",
|
|
36
|
-
"h2",
|
|
37
|
-
"h3",
|
|
38
|
-
"h4",
|
|
39
|
-
"h5",
|
|
40
|
-
"h6",
|
|
41
|
-
"li",
|
|
42
|
-
"dl",
|
|
43
|
-
"th",
|
|
44
|
-
"td"
|
|
45
|
-
];
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const mockMediaMatch = (matches: boolean) => (query: string) => ({
|
|
2
|
-
matches,
|
|
3
|
-
media: query,
|
|
4
|
-
onchange: null,
|
|
5
|
-
addListener: jest.fn(),
|
|
6
|
-
removeListener: jest.fn(),
|
|
7
|
-
addEventListener: jest.fn(),
|
|
8
|
-
removeEventListener: jest.fn(),
|
|
9
|
-
dispatchEvent: jest.fn()
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export const createMediaMock = (
|
|
13
|
-
defaultMatch = false,
|
|
14
|
-
matchesList: Array<boolean> = []
|
|
15
|
-
) => {
|
|
16
|
-
const mediaMock = jest.fn(mockMediaMatch(defaultMatch));
|
|
17
|
-
matchesList.forEach((value) =>
|
|
18
|
-
mediaMock.mockImplementationOnce(mockMediaMatch(value))
|
|
19
|
-
);
|
|
20
|
-
return mediaMock;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const matchMediaMock = createMediaMock();
|
|
24
|
-
|
|
25
|
-
export const mockLocalStorage = function () {
|
|
26
|
-
let store: { [key: string]: string } = {};
|
|
27
|
-
return {
|
|
28
|
-
getItem: function (key: string) {
|
|
29
|
-
return store[key] || null;
|
|
30
|
-
},
|
|
31
|
-
setItem: function (key: string, value: string) {
|
|
32
|
-
store[key] = value.toString();
|
|
33
|
-
},
|
|
34
|
-
removeItem: function (key: string) {
|
|
35
|
-
delete store[key];
|
|
36
|
-
},
|
|
37
|
-
clear: function () {
|
|
38
|
-
store = {};
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const mockQueryParameter = (q: string): void => {
|
|
44
|
-
global.window = Object.create(window);
|
|
45
|
-
const search = q ? `?q=${q}` : "";
|
|
46
|
-
const href = `http://dummy.com${search}`;
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
delete window.location.value;
|
|
49
|
-
Object.defineProperty(window, "location", {
|
|
50
|
-
value: {
|
|
51
|
-
href,
|
|
52
|
-
search
|
|
53
|
-
},
|
|
54
|
-
writable: true
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const unmockQueryParameter = () => mockQueryParameter("");
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RecentSearches,
|
|
3
|
-
LOCAL_STORAGE_KEY,
|
|
4
|
-
LIMIT
|
|
5
|
-
} from "utils-internal/recentSearches";
|
|
6
|
-
|
|
7
|
-
describe("recentSearches", () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
window.localStorage.clear();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("initializes correctly from local storage", () => {
|
|
13
|
-
const initial = ["test", "test1", "test2"];
|
|
14
|
-
|
|
15
|
-
window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(initial));
|
|
16
|
-
const searches = new RecentSearches();
|
|
17
|
-
|
|
18
|
-
expect(searches.get()).toEqual(initial);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("ignores exact duplicate additions", () => {
|
|
22
|
-
const searches = new RecentSearches();
|
|
23
|
-
|
|
24
|
-
const item = "test";
|
|
25
|
-
|
|
26
|
-
searches.add(item);
|
|
27
|
-
searches.add(item);
|
|
28
|
-
|
|
29
|
-
expect(searches.get().length).toEqual(1);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("ignores duplicate additions with extraneous white space", () => {
|
|
33
|
-
const searches = new RecentSearches();
|
|
34
|
-
|
|
35
|
-
const item1 = "test";
|
|
36
|
-
const item2 = " test ";
|
|
37
|
-
|
|
38
|
-
searches.add(item1);
|
|
39
|
-
searches.add(item2);
|
|
40
|
-
|
|
41
|
-
expect(searches.get().length).toEqual(1);
|
|
42
|
-
expect(searches.get()[0]).toEqual(item1);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("prioritizes the last searched item", () => {
|
|
46
|
-
const searches = new RecentSearches();
|
|
47
|
-
|
|
48
|
-
const item1 = "test1";
|
|
49
|
-
const item2 = "test2";
|
|
50
|
-
|
|
51
|
-
searches.add(item1);
|
|
52
|
-
searches.add(item2);
|
|
53
|
-
|
|
54
|
-
expect(searches.get().length).toEqual(2);
|
|
55
|
-
|
|
56
|
-
expect(searches.get()[0]).toEqual(item2);
|
|
57
|
-
expect(searches.get()[1]).toEqual(item1);
|
|
58
|
-
|
|
59
|
-
searches.add(item1);
|
|
60
|
-
|
|
61
|
-
expect(searches.get().length).toEqual(2);
|
|
62
|
-
expect(searches.get()[0]).toEqual(item1);
|
|
63
|
-
expect(searches.get()[1]).toEqual(item2);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("will not exceed the limit", () => {
|
|
67
|
-
const searches = new RecentSearches();
|
|
68
|
-
|
|
69
|
-
Array.apply(null, Array(LIMIT + 1)).forEach((_, i) => {
|
|
70
|
-
searches.add(i.toString());
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
expect(searches.get().length).toEqual(LIMIT);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("doesn't add a bogus value", () => {
|
|
77
|
-
const searches = new RecentSearches();
|
|
78
|
-
|
|
79
|
-
[null, "", " ", " ", 5].forEach((v) => searches.add(v));
|
|
80
|
-
|
|
81
|
-
expect(searches.get().length).toEqual(0);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { html } from "lit-html";
|
|
2
|
-
|
|
3
|
-
export const createRenderComponents =
|
|
4
|
-
(component: string) =>
|
|
5
|
-
(num: number = 12, props: string = "") => {
|
|
6
|
-
let shell = ``;
|
|
7
|
-
for (let i = 0; i < num; i++) {
|
|
8
|
-
const insertIndex = component.indexOf(">");
|
|
9
|
-
const _component = [
|
|
10
|
-
component.slice(0, insertIndex),
|
|
11
|
-
` ${props}`,
|
|
12
|
-
component.slice(insertIndex)
|
|
13
|
-
].join("");
|
|
14
|
-
shell = `
|
|
15
|
-
${shell}
|
|
16
|
-
${_component}
|
|
17
|
-
`;
|
|
18
|
-
}
|
|
19
|
-
return shell;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const renderStyle = (componentTag: string) => html`
|
|
23
|
-
<style>
|
|
24
|
-
span {
|
|
25
|
-
color: grey;
|
|
26
|
-
}
|
|
27
|
-
${componentTag} {
|
|
28
|
-
margin-top: 16px;
|
|
29
|
-
margin-bottom: 36px;
|
|
30
|
-
}
|
|
31
|
-
</style>
|
|
32
|
-
`;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createElement, LightningElement } from "lwc";
|
|
2
|
-
|
|
3
|
-
export const renderLightningElement = (
|
|
4
|
-
element: LightningElement,
|
|
5
|
-
properties = {}
|
|
6
|
-
) => {
|
|
7
|
-
Object.assign(element, properties);
|
|
8
|
-
document.body.appendChild(element as unknown as Node);
|
|
9
|
-
return element;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const createRenderComponent =
|
|
13
|
-
(tag: string, LWC: new () => LightningElement) =>
|
|
14
|
-
(properties = {}) => {
|
|
15
|
-
const component = createElement(tag, {
|
|
16
|
-
is: LWC
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
renderLightningElement(component, properties);
|
|
20
|
-
return component;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const mockSlottedElement = <T extends HTMLElement>(
|
|
24
|
-
element: any,
|
|
25
|
-
elementType = "button",
|
|
26
|
-
slotName?: string
|
|
27
|
-
): { slottedElement: T; slot: HTMLSlotElement } => {
|
|
28
|
-
const slot: HTMLSlotElement = element.shadowRoot.querySelector(
|
|
29
|
-
`slot${slotName ? `[name='${slotName}` : ""}']`
|
|
30
|
-
);
|
|
31
|
-
expect(slot).not.toBeNull();
|
|
32
|
-
|
|
33
|
-
const slottedElement = document.createElement(elementType) as T;
|
|
34
|
-
slot.assignedElements = jest.fn(() => [slottedElement]);
|
|
35
|
-
slot.dispatchEvent(new Event("slotchange"));
|
|
36
|
-
|
|
37
|
-
return { slottedElement, slot };
|
|
38
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { fetchWordpressPosts } from "../wordpress";
|
|
2
|
-
|
|
3
|
-
global.fetch = jest.fn(() =>
|
|
4
|
-
Promise.resolve({
|
|
5
|
-
json: () => Promise.resolve({ res: { status: 404 } })
|
|
6
|
-
})
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
describe("wordpress network request", () => {
|
|
10
|
-
it("displays a console error and returns null on unsuccessful request", async () => {
|
|
11
|
-
const res = await fetchWordpressPosts("", "");
|
|
12
|
-
|
|
13
|
-
expect(res).toBeNull();
|
|
14
|
-
});
|
|
15
|
-
});
|