@salesforcedevs/dx-components 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/modules/dx/codeBlock/__tests__/codeBlock.test.ts +0 -4
- package/src/modules/dx/grid/__tests__/grid.test.ts +2 -7
- package/src/modules/dx/headerSearch/__tests__/headerSearch.test.ts +0 -1
- package/src/modules/dx/minimalCard/__tests__/minimalCard.test.ts +87 -0
- package/src/modules/dx/minimalCard/__tests__/mockProps.ts +10 -0
- package/src/modules/dx/minimalCard/minimalCard.css +32 -0
- package/src/modules/dx/minimalCard/minimalCard.html +13 -0
- package/src/modules/dx/minimalCard/minimalCard.stories.ts +32 -0
- package/src/modules/dx/minimalCard/minimalCard.ts +35 -0
- package/src/modules/dx/popover/__tests__/popover.test.ts +26 -37
- package/src/modules/dx/sidebar/__tests__/sidebar.test.ts +0 -4
- package/src/modules/dx/sidebarOld/__tests__/sidebarOld.test.ts +0 -4
- package/src/modules/dx/socials/__tests__/socials.test.ts +12 -22
- package/src/modules/dx/tree/__tests__/tree.test.ts +17 -28
- package/src/modules/dx/treeItem/__tests__/treeItem.test.ts +36 -59
- package/src/modules/dx/typeBadge/typeBadge.css +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"@types/debounce": "^1.2.0",
|
|
30
30
|
"@types/lodash.get": "^4.4.6"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "4a6bdaf5c490103e5620c3199b24528b4d3d26f0"
|
|
33
33
|
}
|
|
@@ -25,10 +25,6 @@ describe(TAG, () => {
|
|
|
25
25
|
const oldNavigator = window.navigator;
|
|
26
26
|
const oldError = console.error;
|
|
27
27
|
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
jest.clearAllMocks();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
28
|
afterAll(() => {
|
|
33
29
|
Object.assign(window.navigator, oldNavigator);
|
|
34
30
|
Object.assign(console.error, oldError);
|
|
@@ -5,10 +5,6 @@ const TAG = "dx-grid";
|
|
|
5
5
|
const render = createRenderComponent(TAG, Grid);
|
|
6
6
|
|
|
7
7
|
describe(TAG, () => {
|
|
8
|
-
afterEach(() => {
|
|
9
|
-
jest.clearAllMocks();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
8
|
[
|
|
13
9
|
[4, "four", "dynamic"],
|
|
14
10
|
[8, "four", "dynamic"],
|
|
@@ -21,9 +17,8 @@ describe(TAG, () => {
|
|
|
21
17
|
].forEach(([numElements, calculatedColumns, columns]) =>
|
|
22
18
|
it(`choses ${calculatedColumns} columns when there are ${numElements} elements`, () => {
|
|
23
19
|
const element = render({ columns });
|
|
24
|
-
const slot: HTMLSlotElement =
|
|
25
|
-
"slot"
|
|
26
|
-
);
|
|
20
|
+
const slot: HTMLSlotElement =
|
|
21
|
+
element.shadowRoot.querySelector("slot");
|
|
27
22
|
const div = document.createElement("div");
|
|
28
23
|
slot.assignedElements = jest
|
|
29
24
|
.fn()
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import MinimalCard from "dx/minimalCard";
|
|
2
|
+
import TypeBadge from "dx/typeBadge";
|
|
3
|
+
import { createRenderComponent } from "utils/tests";
|
|
4
|
+
import { createMediaMock } from "utils/jest";
|
|
5
|
+
import { blogPostMock, podcastEpisodeMock } from "./mockProps";
|
|
6
|
+
|
|
7
|
+
const MOBILE_QUERY = "(max-width: 640px)";
|
|
8
|
+
const TAG = "dx-minimal-card";
|
|
9
|
+
const render = createRenderComponent(TAG, MinimalCard);
|
|
10
|
+
|
|
11
|
+
describe(TAG, () => {
|
|
12
|
+
describe("default render", () => {
|
|
13
|
+
beforeAll(() => {
|
|
14
|
+
window.matchMedia = createMediaMock();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("renders a blog post", () => {
|
|
18
|
+
const component = render(blogPostMock);
|
|
19
|
+
const link: HTMLAnchorElement =
|
|
20
|
+
component.shadowRoot.querySelector("a");
|
|
21
|
+
expect(link).not.toBeNull();
|
|
22
|
+
expect(link.href).toMatch(blogPostMock.href);
|
|
23
|
+
expect(link.target).toBe("_self");
|
|
24
|
+
|
|
25
|
+
const heading = link.querySelector("h4");
|
|
26
|
+
expect(heading).not.toBeNull();
|
|
27
|
+
expect(heading?.textContent).toBe(blogPostMock.title);
|
|
28
|
+
|
|
29
|
+
const typeBadge: TypeBadge =
|
|
30
|
+
component.shadowRoot.querySelector("dx-type-badge");
|
|
31
|
+
expect(typeBadge).not.toBeNull();
|
|
32
|
+
expect(typeBadge.value).toBe("Blog");
|
|
33
|
+
expect(typeBadge.color).toBe("teal");
|
|
34
|
+
expect(typeBadge.size).toBe("default");
|
|
35
|
+
|
|
36
|
+
expect(window.matchMedia).toBeCalledTimes(1);
|
|
37
|
+
expect(window.matchMedia).toBeCalledWith(MOBILE_QUERY);
|
|
38
|
+
|
|
39
|
+
return expect(component).toBeAccessible();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("renders a podcast episode with target blank", () => {
|
|
43
|
+
const target = "_blank";
|
|
44
|
+
const component = render({ ...podcastEpisodeMock, target });
|
|
45
|
+
const link: HTMLAnchorElement =
|
|
46
|
+
component.shadowRoot.querySelector("a");
|
|
47
|
+
expect(link).not.toBeNull();
|
|
48
|
+
expect(link.href).toMatch(podcastEpisodeMock.href);
|
|
49
|
+
expect(link.target).toBe(target);
|
|
50
|
+
|
|
51
|
+
const heading = link.querySelector("h4");
|
|
52
|
+
expect(heading).not.toBeNull();
|
|
53
|
+
expect(heading?.textContent).toBe(podcastEpisodeMock.title);
|
|
54
|
+
|
|
55
|
+
const typeBadge: TypeBadge =
|
|
56
|
+
component.shadowRoot.querySelector("dx-type-badge");
|
|
57
|
+
expect(typeBadge).not.toBeNull();
|
|
58
|
+
expect(typeBadge.value).toBe(podcastEpisodeMock.contentType);
|
|
59
|
+
expect(typeBadge.color).toBe("blue");
|
|
60
|
+
expect(typeBadge.size).toBe("default");
|
|
61
|
+
|
|
62
|
+
expect(window.matchMedia).toBeCalledTimes(1);
|
|
63
|
+
expect(window.matchMedia).toBeCalledWith(MOBILE_QUERY);
|
|
64
|
+
|
|
65
|
+
return expect(component).toBeAccessible();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe("render mobile", () => {
|
|
69
|
+
beforeAll(() => {
|
|
70
|
+
window.matchMedia = createMediaMock(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("renders dx-type-badge as small", () => {
|
|
74
|
+
const component = render(podcastEpisodeMock);
|
|
75
|
+
const typeBadge =
|
|
76
|
+
component.shadowRoot.querySelector("dx-type-badge");
|
|
77
|
+
expect(typeBadge).not.toBeNull();
|
|
78
|
+
expect(typeBadge.value).toBe(podcastEpisodeMock.contentType);
|
|
79
|
+
expect(typeBadge.color).toBe("blue");
|
|
80
|
+
expect(typeBadge.size).toBe("small");
|
|
81
|
+
expect(window.matchMedia).toBeCalledTimes(1);
|
|
82
|
+
expect(window.matchMedia).toBeCalledWith(MOBILE_QUERY);
|
|
83
|
+
|
|
84
|
+
return expect(component).toBeAccessible();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const blogPostMock = {
|
|
2
|
+
title: "Lightning Web Components for Your Inbox",
|
|
3
|
+
href: "/awesome-post"
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const podcastEpisodeMock = {
|
|
7
|
+
title: "Episode 100: Trailhead Engineering with Jeff Douglas",
|
|
8
|
+
href: "/awesome-episode",
|
|
9
|
+
contentType: "Podcast"
|
|
10
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@import "helpers/reset";
|
|
2
|
+
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
a {
|
|
8
|
+
color: var(--dx-g-blue-vibrant-50);
|
|
9
|
+
display: -webkit-box;
|
|
10
|
+
flex-grow: 1;
|
|
11
|
+
font-family: var(--dx-g-font-sans);
|
|
12
|
+
font-size: var(--dx-g-text-sm);
|
|
13
|
+
font-weight: var(--dx-g-font-demi);
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
-webkit-line-clamp: var(--dx-c-title-max-lines, 3);
|
|
16
|
+
-webkit-box-orient: vertical;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
a:hover {
|
|
20
|
+
color: var(--dx-g-blue-vibrant-40);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
a + * {
|
|
24
|
+
margin-left: var(--dx-g-spacing-sm);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.card-container {
|
|
28
|
+
align-items: center;
|
|
29
|
+
border-bottom: 1px solid var(--sds-g-gray-4);
|
|
30
|
+
display: flex;
|
|
31
|
+
padding: var(--dx-g-spacing-smd) 0;
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { html } from "lit-html";
|
|
2
|
+
import { blogPostMock, podcastEpisodeMock } from "./__tests__/mockProps";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "dx/dx-minimal-card",
|
|
6
|
+
component: "dx-minimal-card"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const BlogPost = (args: { title: string; href: string }) => html`
|
|
10
|
+
<dx-minimal-card
|
|
11
|
+
title="${args.title}"
|
|
12
|
+
href="${args.href}"
|
|
13
|
+
></dx-minimal-card>
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
BlogPost.args = {
|
|
17
|
+
title: blogPostMock.title,
|
|
18
|
+
href: blogPostMock.href
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const PodcastEpisode = (args: { title: string; href: string }) => html`
|
|
22
|
+
<dx-minimal-card
|
|
23
|
+
title="${args.title}"
|
|
24
|
+
href="${args.href}"
|
|
25
|
+
content-type="${podcastEpisodeMock.contentType}"
|
|
26
|
+
></dx-minimal-card>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
PodcastEpisode.args = {
|
|
30
|
+
title: podcastEpisodeMock.title,
|
|
31
|
+
href: podcastEpisodeMock.href
|
|
32
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import { Color, LinkTarget } from "typings/custom";
|
|
3
|
+
|
|
4
|
+
const MOBILE_QUERY = "(max-width: 640px)";
|
|
5
|
+
|
|
6
|
+
export default class MinimalCard extends LightningElement {
|
|
7
|
+
@api contentType: "Blog" | "Podcast" = "Blog";
|
|
8
|
+
@api href!: string;
|
|
9
|
+
@api target: LinkTarget = "_self";
|
|
10
|
+
@api title!: string;
|
|
11
|
+
|
|
12
|
+
private matchMedia!: MediaQueryList;
|
|
13
|
+
private mobile = false;
|
|
14
|
+
|
|
15
|
+
get badgeColor(): Color {
|
|
16
|
+
return this.contentType === "Blog" ? "teal" : "blue";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get badgeSize(): string {
|
|
20
|
+
return (this.mobile && "small") || "default";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
connectedCallback(): void {
|
|
24
|
+
this.matchMedia = window.matchMedia(MOBILE_QUERY);
|
|
25
|
+
this.onMediaChange(this.matchMedia);
|
|
26
|
+
this.matchMedia.addEventListener("change", this.onMediaChange);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
disconnectedCallback(): void {
|
|
30
|
+
this.matchMedia.removeEventListener("change", this.onMediaChange);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private onMediaChange = (e: MediaQueryListEvent | MediaQueryList) =>
|
|
34
|
+
(this.mobile = e.matches);
|
|
35
|
+
}
|
|
@@ -16,10 +16,6 @@ describe(TAG, () => {
|
|
|
16
16
|
global.console = { ...global.console, error: jest.fn() };
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
jest.clearAllMocks();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
19
|
afterAll(() => {
|
|
24
20
|
global.console = originalConsole;
|
|
25
21
|
});
|
|
@@ -29,15 +25,13 @@ describe(TAG, () => {
|
|
|
29
25
|
|
|
30
26
|
expect(console.error).not.toBeCalled();
|
|
31
27
|
|
|
32
|
-
const menuEl: HTMLElement =
|
|
33
|
-
".popover-container"
|
|
34
|
-
);
|
|
28
|
+
const menuEl: HTMLElement =
|
|
29
|
+
component.shadowRoot.querySelector(".popover-container");
|
|
35
30
|
expect(menuEl).not.toBeNull();
|
|
36
31
|
expect(menuEl.classList).toHaveLength(1);
|
|
37
32
|
|
|
38
|
-
const popoverDiv: HTMLElement =
|
|
39
|
-
"div.popover"
|
|
40
|
-
)!;
|
|
33
|
+
const popoverDiv: HTMLElement =
|
|
34
|
+
menuEl.querySelector("div.popover")!;
|
|
41
35
|
expect(popoverDiv).not.toBeNull();
|
|
42
36
|
expect(popoverDiv.classList).toHaveLength(1);
|
|
43
37
|
|
|
@@ -47,15 +41,13 @@ describe(TAG, () => {
|
|
|
47
41
|
it("renders with api properties", () => {
|
|
48
42
|
const component = render(mockProps);
|
|
49
43
|
expect(console.error).not.toBeCalled();
|
|
50
|
-
const menuEl: HTMLElement =
|
|
51
|
-
".popover-container"
|
|
52
|
-
);
|
|
44
|
+
const menuEl: HTMLElement =
|
|
45
|
+
component.shadowRoot.querySelector(".popover-container");
|
|
53
46
|
expect(menuEl).not.toBeNull();
|
|
54
47
|
expect(menuEl.classList).toHaveLength(1);
|
|
55
48
|
|
|
56
|
-
const popoverDiv: HTMLElement =
|
|
57
|
-
"div.popover"
|
|
58
|
-
)!;
|
|
49
|
+
const popoverDiv: HTMLElement =
|
|
50
|
+
menuEl.querySelector("div.popover")!;
|
|
59
51
|
expect(popoverDiv).not.toBeNull();
|
|
60
52
|
expect(popoverDiv.classList).toHaveLength(4);
|
|
61
53
|
expect(popoverDiv.classList).toContain(
|
|
@@ -74,9 +66,8 @@ describe(TAG, () => {
|
|
|
74
66
|
|
|
75
67
|
expect(console.error).not.toBeCalled();
|
|
76
68
|
|
|
77
|
-
const popoverDiv: HTMLElement =
|
|
78
|
-
"div.popover"
|
|
79
|
-
);
|
|
69
|
+
const popoverDiv: HTMLElement =
|
|
70
|
+
component.shadowRoot.querySelector("div.popover");
|
|
80
71
|
expect(popoverDiv.classList).toHaveLength(2);
|
|
81
72
|
expect(popoverDiv.classList).toContain("popover-fullwidth");
|
|
82
73
|
});
|
|
@@ -89,9 +80,8 @@ describe(TAG, () => {
|
|
|
89
80
|
'The "width" and "full-width" properties cannot be provided simultaneously.'
|
|
90
81
|
);
|
|
91
82
|
|
|
92
|
-
const popoverDiv: HTMLElement =
|
|
93
|
-
"div.popover"
|
|
94
|
-
);
|
|
83
|
+
const popoverDiv: HTMLElement =
|
|
84
|
+
component.shadowRoot.querySelector("div.popover");
|
|
95
85
|
expect(popoverDiv.style).not.toBeNull();
|
|
96
86
|
expect(popoverDiv.classList).toHaveLength(5);
|
|
97
87
|
expect(popoverDiv.classList).toContain(
|
|
@@ -120,9 +110,8 @@ describe(TAG, () => {
|
|
|
120
110
|
|
|
121
111
|
it("doesn't render menu content before interaction", async () => {
|
|
122
112
|
const component = render();
|
|
123
|
-
const content =
|
|
124
|
-
".popover-content"
|
|
125
|
-
);
|
|
113
|
+
const content =
|
|
114
|
+
component.shadowRoot.querySelector(".popover-content");
|
|
126
115
|
|
|
127
116
|
expect(content).toBeNull();
|
|
128
117
|
|
|
@@ -130,9 +119,8 @@ describe(TAG, () => {
|
|
|
130
119
|
|
|
131
120
|
await Promise.resolve();
|
|
132
121
|
|
|
133
|
-
const contentAfterOpen =
|
|
134
|
-
".popover-content"
|
|
135
|
-
);
|
|
122
|
+
const contentAfterOpen =
|
|
123
|
+
component.shadowRoot.querySelector(".popover-content");
|
|
136
124
|
|
|
137
125
|
expect(contentAfterOpen).not.toBeNull();
|
|
138
126
|
|
|
@@ -145,9 +133,8 @@ describe(TAG, () => {
|
|
|
145
133
|
|
|
146
134
|
const renderComponent = createRenderComponent(TAG, Popover);
|
|
147
135
|
const component = renderComponent();
|
|
148
|
-
const content =
|
|
149
|
-
".popover-content"
|
|
150
|
-
);
|
|
136
|
+
const content =
|
|
137
|
+
component.shadowRoot.querySelector(".popover-content");
|
|
151
138
|
|
|
152
139
|
expect(content).not.toBeNull();
|
|
153
140
|
});
|
|
@@ -183,9 +170,12 @@ describe(TAG, () => {
|
|
|
183
170
|
it("doesn't fire open if passed control is disabled", () => {
|
|
184
171
|
const element = render();
|
|
185
172
|
|
|
186
|
-
const { slot: controlSlot, slottedElement } =
|
|
187
|
-
HTMLButtonElement
|
|
188
|
-
|
|
173
|
+
const { slot: controlSlot, slottedElement } =
|
|
174
|
+
mockSlottedElement<HTMLButtonElement>(
|
|
175
|
+
element,
|
|
176
|
+
"button",
|
|
177
|
+
"control"
|
|
178
|
+
);
|
|
189
179
|
expect(controlSlot.assignedElements).toBeCalledTimes(1);
|
|
190
180
|
expect(slottedElement.ariaHasPopup).toBe("true");
|
|
191
181
|
expect(slottedElement.style.cursor).toBe("cursor");
|
|
@@ -237,9 +227,8 @@ describe(TAG, () => {
|
|
|
237
227
|
const closeEvent = jest.fn();
|
|
238
228
|
component.addEventListener("close", closeEvent);
|
|
239
229
|
|
|
240
|
-
const popoverDiv: HTMLElement =
|
|
241
|
-
".popover"
|
|
242
|
-
);
|
|
230
|
+
const popoverDiv: HTMLElement =
|
|
231
|
+
component.shadowRoot.querySelector(".popover");
|
|
243
232
|
expect(popoverDiv).not.toBeNull();
|
|
244
233
|
|
|
245
234
|
expect(component.open).toBe(true);
|
|
@@ -25,10 +25,6 @@ const GTM_EVENT_NAME = "custEv_leftNavLinkClick";
|
|
|
25
25
|
const TOGGLE_BUTTON_LABEL = "Toggle Sidebar";
|
|
26
26
|
|
|
27
27
|
describe(TAG, () => {
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
jest.clearAllMocks();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
28
|
describe("desktop", () => {
|
|
33
29
|
beforeEach(() => {
|
|
34
30
|
unmockQueryParameter();
|
|
@@ -19,10 +19,6 @@ const GTM_EVENT_NAME = "custEv_leftNavLinkClick";
|
|
|
19
19
|
const TOGGLE_BUTTON_LABEL = "Toggle Sidebar";
|
|
20
20
|
|
|
21
21
|
describe(TAG, () => {
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
jest.clearAllMocks();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
22
|
describe("desktop", () => {
|
|
27
23
|
describe("component render", () => {
|
|
28
24
|
it("should render as expanded with all the elements that sidebar includes", () => {
|
|
@@ -14,10 +14,6 @@ describe(TAG, () => {
|
|
|
14
14
|
global.console = { ...global.console, error: jest.fn() };
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
afterEach(() => {
|
|
18
|
-
jest.clearAllMocks();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
17
|
afterAll(() => {
|
|
22
18
|
global.console = originalConsole;
|
|
23
19
|
});
|
|
@@ -25,9 +21,8 @@ describe(TAG, () => {
|
|
|
25
21
|
it("renders dx-icon-badge for each social link", () => {
|
|
26
22
|
const component = render();
|
|
27
23
|
|
|
28
|
-
const links: Array<HTMLAnchorElement> =
|
|
29
|
-
"a"
|
|
30
|
-
);
|
|
24
|
+
const links: Array<HTMLAnchorElement> =
|
|
25
|
+
component.shadowRoot.querySelectorAll("a");
|
|
31
26
|
expect(links).toHaveLength(3);
|
|
32
27
|
|
|
33
28
|
const [facebookLink, twitterLink, linkedinLink] = links;
|
|
@@ -50,9 +45,8 @@ describe(TAG, () => {
|
|
|
50
45
|
expect(linkedinLink.target).toBe("_blank");
|
|
51
46
|
expect(linkedinLink.title).toBe("Linkedin");
|
|
52
47
|
|
|
53
|
-
const iconBadge: Array<IconBadge> =
|
|
54
|
-
"dx-icon-badge"
|
|
55
|
-
);
|
|
48
|
+
const iconBadge: Array<IconBadge> =
|
|
49
|
+
component.shadowRoot.querySelectorAll("dx-icon-badge");
|
|
56
50
|
expect(iconBadge).toHaveLength(3);
|
|
57
51
|
|
|
58
52
|
const [facebookIcon, twitterIcon, linkedinIcon] = iconBadge;
|
|
@@ -66,9 +60,8 @@ describe(TAG, () => {
|
|
|
66
60
|
expect(linkedinIcon.sprite).toBe("brand");
|
|
67
61
|
expect(linkedinIcon.symbol).toBe("linkedin-in");
|
|
68
62
|
|
|
69
|
-
const detailSection =
|
|
70
|
-
".details-section"
|
|
71
|
-
);
|
|
63
|
+
const detailSection =
|
|
64
|
+
component.shadowRoot.querySelector(".details-section");
|
|
72
65
|
expect(detailSection).toBeNull();
|
|
73
66
|
|
|
74
67
|
return expect(component).toBeAccessible();
|
|
@@ -78,9 +71,8 @@ describe(TAG, () => {
|
|
|
78
71
|
const expectedTarget = "_self";
|
|
79
72
|
const component = render({ linksTarget: expectedTarget });
|
|
80
73
|
|
|
81
|
-
const links: Array<HTMLAnchorElement> =
|
|
82
|
-
"a"
|
|
83
|
-
);
|
|
74
|
+
const links: Array<HTMLAnchorElement> =
|
|
75
|
+
component.shadowRoot.querySelectorAll("a");
|
|
84
76
|
expect(links).toHaveLength(3);
|
|
85
77
|
links.forEach(({ target }) => expect(target).toBe(expectedTarget));
|
|
86
78
|
|
|
@@ -93,9 +85,8 @@ describe(TAG, () => {
|
|
|
93
85
|
const testTarget = "not_valid_at_all";
|
|
94
86
|
const component = render({ linksTarget: testTarget });
|
|
95
87
|
|
|
96
|
-
const links: Array<HTMLAnchorElement> =
|
|
97
|
-
"a"
|
|
98
|
-
);
|
|
88
|
+
const links: Array<HTMLAnchorElement> =
|
|
89
|
+
component.shadowRoot.querySelectorAll("a");
|
|
99
90
|
expect(links).toHaveLength(3);
|
|
100
91
|
links.forEach(({ target }) => expect(target).toBe("_blank"));
|
|
101
92
|
|
|
@@ -110,9 +101,8 @@ describe(TAG, () => {
|
|
|
110
101
|
it("renders details section", () => {
|
|
111
102
|
const component = render({ details: "Test|Another Test" });
|
|
112
103
|
|
|
113
|
-
const details: Array<HTMLElement> =
|
|
114
|
-
".details-section span"
|
|
115
|
-
);
|
|
104
|
+
const details: Array<HTMLElement> =
|
|
105
|
+
component.shadowRoot.querySelectorAll(".details-section span");
|
|
116
106
|
expect(details).toHaveLength(2);
|
|
117
107
|
|
|
118
108
|
const [testDetail, anotherTestDetail] = details;
|
|
@@ -37,10 +37,6 @@ describe(TAG, () => {
|
|
|
37
37
|
mockInitialize.mockReturnValue(INITIALIZE_MOCK_RESULT);
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
afterEach(() => {
|
|
41
|
-
jest.clearAllMocks();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
40
|
describe("component render", () => {
|
|
45
41
|
it("should render dx-tree-item with appropiate properties", () => {
|
|
46
42
|
const component = renderComponent({
|
|
@@ -49,9 +45,8 @@ describe(TAG, () => {
|
|
|
49
45
|
expect(component.treeRoot).toEqual(INITIALIZE_MOCK_RESULT);
|
|
50
46
|
expect(component.value).toBeUndefined();
|
|
51
47
|
|
|
52
|
-
const treeItem: TreeItem =
|
|
53
|
-
"dx-tree-item"
|
|
54
|
-
);
|
|
48
|
+
const treeItem: TreeItem =
|
|
49
|
+
component.shadowRoot.querySelector("dx-tree-item");
|
|
55
50
|
expect(treeItem).not.toBeNull();
|
|
56
51
|
expect(treeItem.treeNode).toEqual(INITIALIZE_MOCK_RESULT);
|
|
57
52
|
expect(treeItem.isRoot).toBe(true);
|
|
@@ -81,9 +76,8 @@ describe(TAG, () => {
|
|
|
81
76
|
expect(component.treeRoot).toEqual(INITIALIZE_MOCK_RESULT);
|
|
82
77
|
expect(component.value).toBe(INITIALIZE_MOCK_PARAMETER.name);
|
|
83
78
|
|
|
84
|
-
const treeItem: TreeItem =
|
|
85
|
-
"dx-tree-item"
|
|
86
|
-
);
|
|
79
|
+
const treeItem: TreeItem =
|
|
80
|
+
component.shadowRoot.querySelector("dx-tree-item");
|
|
87
81
|
expect(treeItem).not.toBeNull();
|
|
88
82
|
expect(treeItem.treeNode).toEqual(INITIALIZE_MOCK_RESULT);
|
|
89
83
|
expect(treeItem.isRoot).toBe(true);
|
|
@@ -122,9 +116,8 @@ describe(TAG, () => {
|
|
|
122
116
|
value: INITIALIZE_MOCK_PARAMETER.name
|
|
123
117
|
});
|
|
124
118
|
|
|
125
|
-
const treeItem: TreeItem =
|
|
126
|
-
"dx-tree-item"
|
|
127
|
-
);
|
|
119
|
+
const treeItem: TreeItem =
|
|
120
|
+
component.shadowRoot.querySelector("dx-tree-item");
|
|
128
121
|
expect(treeItem).not.toBeNull();
|
|
129
122
|
expect(treeItem.selectedKey).toBe(validKey);
|
|
130
123
|
|
|
@@ -183,9 +176,8 @@ describe(TAG, () => {
|
|
|
183
176
|
expect(mockGetNode).not.toBeCalled();
|
|
184
177
|
|
|
185
178
|
return Promise.resolve().then(() => {
|
|
186
|
-
const treeItem: TreeItem =
|
|
187
|
-
"dx-tree-item"
|
|
188
|
-
);
|
|
179
|
+
const treeItem: TreeItem =
|
|
180
|
+
component.shadowRoot.querySelector("dx-tree-item");
|
|
189
181
|
expect(treeItem).not.toBeNull();
|
|
190
182
|
expect(treeItem.selectedKey).toBe(expectedKey);
|
|
191
183
|
|
|
@@ -241,9 +233,8 @@ describe(TAG, () => {
|
|
|
241
233
|
const mockTileSelected = jest.fn();
|
|
242
234
|
component.addEventListener("tileselected", mockTileSelected);
|
|
243
235
|
|
|
244
|
-
const treeItem: TreeItem =
|
|
245
|
-
"dx-tree-item"
|
|
246
|
-
);
|
|
236
|
+
const treeItem: TreeItem =
|
|
237
|
+
component.shadowRoot.querySelector("dx-tree-item");
|
|
247
238
|
treeItem.dispatchEvent(
|
|
248
239
|
new CustomEvent("tileselected", MOCK_TILE_DETAIL)
|
|
249
240
|
);
|
|
@@ -339,15 +330,13 @@ describe(TAG, () => {
|
|
|
339
330
|
const mockRegister = jest.fn();
|
|
340
331
|
component.addEventListener("register", mockRegister);
|
|
341
332
|
|
|
342
|
-
component.shadowRoot
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
})
|
|
350
|
-
);
|
|
333
|
+
component.shadowRoot.querySelector("dx-tree-item").dispatchEvent(
|
|
334
|
+
new CustomEvent("register", {
|
|
335
|
+
detail,
|
|
336
|
+
bubbles: true,
|
|
337
|
+
composed: true
|
|
338
|
+
})
|
|
339
|
+
);
|
|
351
340
|
|
|
352
341
|
expect(mockRegisterSetExpanded).toBeCalledTimes(1);
|
|
353
342
|
expect(mockRegisterSetExpanded).toBeCalledWith(detail);
|
|
@@ -31,9 +31,8 @@ describe(TAG, () => {
|
|
|
31
31
|
const link = component.shadowRoot.querySelector("a");
|
|
32
32
|
expect(link).not.toBeNull();
|
|
33
33
|
|
|
34
|
-
const tile: TreeTile =
|
|
35
|
-
"a > dx-tree-tile"
|
|
36
|
-
);
|
|
34
|
+
const tile: TreeTile =
|
|
35
|
+
component.shadowRoot.querySelector("a > dx-tree-tile");
|
|
37
36
|
expect(tile).not.toBeNull();
|
|
38
37
|
assertTile(tile, {
|
|
39
38
|
isRoot: true,
|
|
@@ -43,9 +42,8 @@ describe(TAG, () => {
|
|
|
43
42
|
isSelected: false
|
|
44
43
|
});
|
|
45
44
|
|
|
46
|
-
const childTreeItem =
|
|
47
|
-
"dx-tree-item"
|
|
48
|
-
);
|
|
45
|
+
const childTreeItem =
|
|
46
|
+
component.shadowRoot.querySelector("dx-tree-item");
|
|
49
47
|
expect(childTreeItem).toBeNull();
|
|
50
48
|
|
|
51
49
|
return expect(component).toBeAccessible();
|
|
@@ -57,9 +55,8 @@ describe(TAG, () => {
|
|
|
57
55
|
treeNode
|
|
58
56
|
});
|
|
59
57
|
|
|
60
|
-
const tile: TreeTile =
|
|
61
|
-
"a > dx-tree-tile"
|
|
62
|
-
);
|
|
58
|
+
const tile: TreeTile =
|
|
59
|
+
component.shadowRoot.querySelector("a > dx-tree-tile");
|
|
63
60
|
expect(tile).not.toBeNull();
|
|
64
61
|
assertTile(tile, {
|
|
65
62
|
isRoot: false,
|
|
@@ -69,9 +66,8 @@ describe(TAG, () => {
|
|
|
69
66
|
isSelected: false
|
|
70
67
|
});
|
|
71
68
|
|
|
72
|
-
const children: Array<TreeItem> =
|
|
73
|
-
"dx-tree-item"
|
|
74
|
-
);
|
|
69
|
+
const children: Array<TreeItem> =
|
|
70
|
+
component.shadowRoot.querySelectorAll("dx-tree-item");
|
|
75
71
|
expect(children).toHaveLength(NODE_WITH_CHILDREN.children!.length);
|
|
76
72
|
|
|
77
73
|
children.forEach((child, index) => {
|
|
@@ -99,9 +95,8 @@ describe(TAG, () => {
|
|
|
99
95
|
SINGLE_NODE_WITH_LINK.link!.target
|
|
100
96
|
);
|
|
101
97
|
|
|
102
|
-
const tile: TreeTile =
|
|
103
|
-
"a > dx-tree-tile"
|
|
104
|
-
);
|
|
98
|
+
const tile: TreeTile =
|
|
99
|
+
component.shadowRoot.querySelector("a > dx-tree-tile");
|
|
105
100
|
expect(tile).not.toBeNull();
|
|
106
101
|
assertTile(tile, {
|
|
107
102
|
isRoot: false,
|
|
@@ -111,9 +106,8 @@ describe(TAG, () => {
|
|
|
111
106
|
isSelected: true
|
|
112
107
|
});
|
|
113
108
|
|
|
114
|
-
const anyChild: TreeItem =
|
|
115
|
-
"dx-tree-item"
|
|
116
|
-
);
|
|
109
|
+
const anyChild: TreeItem =
|
|
110
|
+
component.shadowRoot.querySelector("dx-tree-item");
|
|
117
111
|
expect(anyChild).toBeNull();
|
|
118
112
|
|
|
119
113
|
return expect(component).toBeAccessible();
|
|
@@ -143,9 +137,8 @@ describe(TAG, () => {
|
|
|
143
137
|
selectedKey: "not_this"
|
|
144
138
|
});
|
|
145
139
|
|
|
146
|
-
const tile: TreeTile =
|
|
147
|
-
"a > dx-tree-tile"
|
|
148
|
-
);
|
|
140
|
+
const tile: TreeTile =
|
|
141
|
+
component.shadowRoot.querySelector("a > dx-tree-tile");
|
|
149
142
|
expect(tile).not.toBeNull();
|
|
150
143
|
assertTile(tile, {
|
|
151
144
|
isRoot: false,
|
|
@@ -163,10 +156,6 @@ describe(TAG, () => {
|
|
|
163
156
|
const mockExpandCollapse = jest.fn();
|
|
164
157
|
const mockTileSelected = jest.fn();
|
|
165
158
|
|
|
166
|
-
afterEach(() => {
|
|
167
|
-
jest.clearAllMocks();
|
|
168
|
-
});
|
|
169
|
-
|
|
170
159
|
it("should render the children when the dx-tree-tile emits iconclick", () => {
|
|
171
160
|
const component = renderComponent({
|
|
172
161
|
treeNode: NODE_WITH_CHILDREN
|
|
@@ -175,14 +164,12 @@ describe(TAG, () => {
|
|
|
175
164
|
component.addEventListener("expandcollapse", mockExpandCollapse);
|
|
176
165
|
component.addEventListener("tileselected", mockTileSelected);
|
|
177
166
|
|
|
178
|
-
const anyChild: TreeItem =
|
|
179
|
-
"dx-tree-item"
|
|
180
|
-
);
|
|
167
|
+
const anyChild: TreeItem =
|
|
168
|
+
component.shadowRoot.querySelector("dx-tree-item");
|
|
181
169
|
expect(anyChild).toBeNull();
|
|
182
170
|
|
|
183
|
-
const tile: HTMLElement =
|
|
184
|
-
"dx-tree-tile"
|
|
185
|
-
)!;
|
|
171
|
+
const tile: HTMLElement =
|
|
172
|
+
component.shadowRoot.querySelector("dx-tree-tile")!;
|
|
186
173
|
expect(tile).toHaveProperty("isExpanded", false);
|
|
187
174
|
tile.dispatchEvent(new CustomEvent("iconclick"));
|
|
188
175
|
|
|
@@ -193,9 +180,8 @@ describe(TAG, () => {
|
|
|
193
180
|
});
|
|
194
181
|
|
|
195
182
|
return Promise.resolve().then(() => {
|
|
196
|
-
const children: Array<TreeItem> =
|
|
197
|
-
"dx-tree-item"
|
|
198
|
-
);
|
|
183
|
+
const children: Array<TreeItem> =
|
|
184
|
+
component.shadowRoot.querySelectorAll("dx-tree-item");
|
|
199
185
|
expect(children).toHaveLength(
|
|
200
186
|
NODE_WITH_CHILDREN.children!.length
|
|
201
187
|
);
|
|
@@ -224,14 +210,12 @@ describe(TAG, () => {
|
|
|
224
210
|
component.addEventListener("expandcollapse", mockExpandCollapse);
|
|
225
211
|
component.addEventListener("tileselected", mockTileSelected);
|
|
226
212
|
|
|
227
|
-
const tile: HTMLElement =
|
|
228
|
-
"dx-tree-tile"
|
|
229
|
-
);
|
|
213
|
+
const tile: HTMLElement =
|
|
214
|
+
component.shadowRoot.querySelector("dx-tree-tile");
|
|
230
215
|
expect(tile).toHaveProperty("isExpanded", true);
|
|
231
216
|
|
|
232
|
-
const children: Array<TreeItem> =
|
|
233
|
-
"dx-tree-item"
|
|
234
|
-
);
|
|
217
|
+
const children: Array<TreeItem> =
|
|
218
|
+
component.shadowRoot.querySelectorAll("dx-tree-item");
|
|
235
219
|
expect(children).toHaveLength(NODE_WITH_CHILDREN.children!.length);
|
|
236
220
|
|
|
237
221
|
tile.dispatchEvent(new CustomEvent("iconclick"));
|
|
@@ -245,9 +229,8 @@ describe(TAG, () => {
|
|
|
245
229
|
return Promise.resolve().then(() => {
|
|
246
230
|
expect(tile).toHaveProperty("isExpanded", false);
|
|
247
231
|
|
|
248
|
-
const anyChild: TreeItem =
|
|
249
|
-
"dx-tree-item"
|
|
250
|
-
);
|
|
232
|
+
const anyChild: TreeItem =
|
|
233
|
+
component.shadowRoot.querySelector("dx-tree-item");
|
|
251
234
|
expect(anyChild).toBeNull();
|
|
252
235
|
|
|
253
236
|
expect(mockExpandCollapse).toBeCalledTimes(1);
|
|
@@ -313,9 +296,8 @@ describe(TAG, () => {
|
|
|
313
296
|
component.addEventListener("tileselected", mockTileSelected);
|
|
314
297
|
component.addEventListener("expandcollapse", mockExpandCollapse);
|
|
315
298
|
|
|
316
|
-
const tile: TreeTile =
|
|
317
|
-
"dx-tree-tile"
|
|
318
|
-
);
|
|
299
|
+
const tile: TreeTile =
|
|
300
|
+
component.shadowRoot.querySelector("dx-tree-tile");
|
|
319
301
|
expect(tile).toHaveProperty("isSelected", true);
|
|
320
302
|
|
|
321
303
|
const link: HTMLElement = component.shadowRoot.querySelector("a");
|
|
@@ -349,16 +331,13 @@ describe(TAG, () => {
|
|
|
349
331
|
});
|
|
350
332
|
|
|
351
333
|
expect(mockRegister).toBeCalledTimes(1);
|
|
352
|
-
const {
|
|
353
|
-
|
|
354
|
-
setExpanded
|
|
355
|
-
} = mockRegister.mock.calls[0][0].detail;
|
|
334
|
+
const { key: actualKey, setExpanded } =
|
|
335
|
+
mockRegister.mock.calls[0][0].detail;
|
|
356
336
|
expect(actualKey).toBe(NODE_WITH_CHILDREN.key);
|
|
357
337
|
expect(typeof setExpanded).toBe("function");
|
|
358
338
|
|
|
359
|
-
const tile: TreeTile =
|
|
360
|
-
"dx-tree-tile"
|
|
361
|
-
);
|
|
339
|
+
const tile: TreeTile =
|
|
340
|
+
component.shadowRoot.querySelector("dx-tree-tile");
|
|
362
341
|
expect(tile).not.toBeNull();
|
|
363
342
|
expect(tile).toHaveProperty("isExpanded", false);
|
|
364
343
|
|
|
@@ -371,9 +350,8 @@ describe(TAG, () => {
|
|
|
371
350
|
return Promise.resolve().then(() => {
|
|
372
351
|
expect(tile).toHaveProperty("isExpanded", true);
|
|
373
352
|
|
|
374
|
-
const trees =
|
|
375
|
-
"dx-tree-item"
|
|
376
|
-
);
|
|
353
|
+
const trees =
|
|
354
|
+
component.shadowRoot.querySelectorAll("dx-tree-item");
|
|
377
355
|
expect(trees).toHaveLength(NODE_WITH_CHILDREN.children!.length);
|
|
378
356
|
});
|
|
379
357
|
});
|
|
@@ -383,9 +361,8 @@ describe(TAG, () => {
|
|
|
383
361
|
treeNode: SINGLE_NODE_WITH_LINK
|
|
384
362
|
});
|
|
385
363
|
|
|
386
|
-
const link: HTMLAnchorElement =
|
|
387
|
-
"a"
|
|
388
|
-
);
|
|
364
|
+
const link: HTMLAnchorElement =
|
|
365
|
+
component.shadowRoot.querySelector("a");
|
|
389
366
|
expect(link).not.toBeNull();
|
|
390
367
|
|
|
391
368
|
link.click();
|