@salesforcedevs/docs-components 0.22.0 → 0.26.0-alpha.2

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.
Files changed (43) hide show
  1. package/package.json +2 -6
  2. package/src/modules/doc/header/header.css +5 -2
  3. package/src/modules/doc/header/header.html +1 -0
  4. package/src/modules/doc/header/header.ts +1 -1
  5. package/LICENSE +0 -12
  6. package/src/modules/doc/content/__tests__/content.test.ts +0 -312
  7. package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -348
  8. package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
  9. package/src/modules/doc/content/__tests__/mockSidebar.ts +0 -81
  10. package/src/modules/doc/content/content.stories.ts +0 -148
  11. package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
  12. package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
  13. package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
  14. package/src/modules/doc/contentMedia/__tests__/contentMedia.test.ts +0 -93
  15. package/src/modules/doc/contentMedia/contentMedia.stories.ts +0 -113
  16. package/src/modules/doc/header/__tests__/coveoConfig.ts +0 -6
  17. package/src/modules/doc/header/__tests__/header.test.ts +0 -437
  18. package/src/modules/doc/header/__tests__/mockNavDevelopers.ts +0 -427
  19. package/src/modules/doc/header/__tests__/mockNavs.ts +0 -115
  20. package/src/modules/doc/header/__tests__/mockProps.ts +0 -152
  21. package/src/modules/doc/header/header.stories.ts +0 -190
  22. package/src/modules/doc/headingAnchor/__tests__/headingAnchor.test.ts +0 -110
  23. package/src/modules/doc/headingAnchor/headingAnchor.stories.ts +0 -33
  24. package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
  25. package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
  26. package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
  27. package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
  28. package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
  29. package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
  30. package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
  31. package/src/modules/doc/nav/__tests__/nav.test.ts +0 -58
  32. package/src/modules/doc/phase/__tests__/mockProps.ts +0 -13
  33. package/src/modules/doc/phase/__tests__/phase.test.ts +0 -60
  34. package/src/modules/doc/phase/phase.stories.ts +0 -12
  35. package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
  36. package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
  37. package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
  38. package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
  39. package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
  40. package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
  41. package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
  42. package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
  43. package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
@@ -1,14 +0,0 @@
1
- export default {
2
- body: `<ul class="ul bulletList">
3
- <li class="li">Apex SOAP web services allow an external application to invoke Apex methods
4
- through SOAP Web services. <a class="xref" href="docs/atlas.en-us.226.0.apexcode.meta/apexcode/apex_callouts.htm" data-id="docs/atlas.en-us.226.0.apexcode.meta/apexcode/apex_callouts.htm">Apex callouts</a> enable Apex to invoke external web or HTTP
5
- services.</li>
6
-
7
- <li class="li">Apex REST API exposes your Apex classes and methods as REST web services. See
8
- <a class="xref" href="docs/atlas.en-us.226.0.apexcode.meta/apexcode/apex_rest.htm" title="You can expose your Apex classes and methods so that external applications can access your code and your application through the REST architecture." data-id="docs/atlas.en-us.226.0.apexcode.meta/apexcode/apex_rest.htm">Exposing Apex Classes as REST Web
9
- Services</a>.</li>
10
-
11
- </ul>`,
12
- title: "Caution",
13
- variant: "Caution"
14
- };
@@ -1,29 +0,0 @@
1
- import mockProps from "./__tests__/mockProps";
2
-
3
- export default {
4
- title: "docs/doc-content-callout",
5
- component: "doc-content-callout"
6
- };
7
-
8
- export const Base = (args: any) => `
9
- <style>
10
- doc-content-callout {
11
- display:block;
12
- margin-bottom:12px;
13
- }
14
- </style>
15
- <doc-content-callout title='Note'variant="note">
16
- ${args.body}
17
- </doc-content-callout>
18
- <doc-content-callout title='Tip'variant="tip">
19
- ${args.body}
20
- </doc-content-callout>
21
- <doc-content-callout title='Warning' variant="warning">
22
- ${args.body}
23
- </doc-content-callout>
24
- <doc-content-callout title='Caution' variant="caution">
25
- ${args.body}
26
- </doc-content-callout>
27
- `;
28
-
29
- Base.args = mockProps;
@@ -1,93 +0,0 @@
1
- import ContentMedia from "doc/contentMedia";
2
- import { createRenderComponent } from "utils/tests";
3
-
4
- const TAG = "doc-content-media";
5
- const render = createRenderComponent(TAG, ContentMedia);
6
-
7
- describe(TAG, () => {
8
- const originalConsole = global.console;
9
-
10
- beforeAll(() => {
11
- global.console = { ...global.console, error: jest.fn() };
12
- });
13
-
14
- afterAll(() => {
15
- global.console = originalConsole;
16
- });
17
-
18
- it("renders image with passed in props", () => {
19
- const element = render({
20
- mediaTitle: "test title",
21
- contentType: "image",
22
- contentSrc: "https://placekitten.com/400/300",
23
- caption: "test caption"
24
- });
25
-
26
- const title = element.shadowRoot.querySelector(".content-media-title");
27
- expect(title).not.toBeNull();
28
- expect(title.textContent).toBe("test title");
29
-
30
- const caption = element.shadowRoot.querySelector(
31
- ".content-media-caption"
32
- );
33
- expect(caption).not.toBeNull();
34
- expect(caption.textContent).toBe("test caption");
35
-
36
- const image = element.shadowRoot.querySelector(
37
- ".content-media-image img"
38
- );
39
- expect(image).not.toBeNull();
40
- expect(image.src).toBe("https://placekitten.com/400/300");
41
-
42
- return expect(element).toBeAccessible();
43
- });
44
-
45
- it("renders iframe with passed in props", () => {
46
- const element = render({
47
- mediaTitle: "test title",
48
- contentType: "iframe",
49
- contentSrc: "https://www.youtube.com/embed/DfV7WnyEPTE",
50
- caption: "test caption"
51
- });
52
-
53
- const title = element.shadowRoot.querySelector(".content-media-title");
54
- expect(title).not.toBeNull();
55
- expect(title.textContent).toBe("test title");
56
-
57
- const caption = element.shadowRoot.querySelector(
58
- ".content-media-caption"
59
- );
60
- expect(caption).not.toBeNull();
61
- expect(caption.textContent).toBe("test caption");
62
-
63
- const iframe = element.shadowRoot.querySelector(
64
- ".content-media-iframe iframe"
65
- );
66
- expect(iframe).not.toBeNull();
67
- expect(iframe.src).toBe("https://www.youtube.com/embed/DfV7WnyEPTE");
68
-
69
- return expect(element).toBeAccessible();
70
- });
71
-
72
- it("doesn't render title or caption when not provided", () => {
73
- const element = render({
74
- contentType: "iframe",
75
- contentSrc: "https://www.youtube.com/embed/DfV7WnyEPTE"
76
- });
77
-
78
- const title = element.shadowRoot.querySelector(".content-media-title");
79
- expect(title).toBeNull();
80
-
81
- const caption = element.shadowRoot.querySelector(
82
- ".content-media-caption"
83
- );
84
- expect(caption).toBeNull();
85
-
86
- expect(global.console.error).toBeCalledTimes(1);
87
- expect(global.console.error).toBeCalledWith(
88
- "media-title must be specified when using iframe-src attribute."
89
- );
90
-
91
- return expect(element).toBeAccessible();
92
- });
93
- });
@@ -1,113 +0,0 @@
1
- import { html } from "lit-html";
2
-
3
- export default {
4
- title: "docs/doc-content-media",
5
- component: "doc-content-media"
6
- };
7
-
8
- // prettier-ignore
9
- const styles = () => html `
10
- <style>
11
- .container-sm {
12
- max-width: 540px;
13
- margin: 0 auto;
14
- }
15
-
16
- .container-fw {
17
- width: 100%;
18
- }
19
-
20
- h1 {
21
- font-size: 36px;
22
- }
23
-
24
- h2 {
25
- font-size: 24px;
26
- }
27
-
28
- h1, h2 {
29
- font-weight: bold;
30
- }
31
- </style>
32
- `;
33
-
34
- // prettier-ignore
35
- export const Base = () => html`${styles()}
36
- <div class="container-sm">
37
- <h1>Small Container</h1>
38
- <h2>Images</h2>
39
- <doc-content-media
40
- content-type="image"
41
- content-src="https://placekitten.com/400/300"
42
- media-title="A cute kitten"
43
- caption="An incredibly cute kitten"
44
- ></doc-content-media>
45
- <doc-content-media
46
- content-type="image"
47
- content-src="https://placekitten.com/400/300"
48
- media-title="A cute kitten"
49
- ></doc-content-media>
50
- <doc-content-media
51
- content-type="image"
52
- content-src="https://placekitten.com/400/300"
53
- caption="An incredibly cute kitten"
54
- ></doc-content-media>
55
- <doc-content-media
56
- content-type="image"
57
- content-src="https://placekitten.com/400/300"
58
- ></doc-content-media>
59
-
60
- <h2>IFrames</h2>
61
- <doc-content-media
62
- content-type="iframe"
63
- content-src="https://www.youtube.com/embed/DfV7WnyEPTE"
64
- media-title="Master Lightning Web Components in 8 Easy Steps (1)"
65
- caption="Lightning Web Components are a new development platform for Salesforce."
66
- ></doc-content-media>
67
- <doc-content-media
68
- content-type="iframe"
69
- content-src="https://play.vidyard.com/yThw736PBYf18ts1f8SKXa?disable_popouts=1&v=4.2.30&type=inline"
70
- media-title="Non-YouTube Video"
71
- caption="doc-content-media supports iframes from any origin."
72
- ></doc-content-media>
73
- </div>
74
-
75
- <div class="container-fw">
76
- <h1>Full-width Container</h1>
77
- <h2>Images</h2>
78
- <doc-content-media
79
- content-type="image"
80
- content-src="https://placekitten.com/400/300"
81
- media-title="A cute kitten"
82
- caption="An incredibly cute kitten"
83
- ></doc-content-media>
84
- <doc-content-media
85
- content-type="image"
86
- content-src="https://placekitten.com/400/300"
87
- media-title="A cute kitten"
88
- ></doc-content-media>
89
- <doc-content-media
90
- content-type="image"
91
- content-src="https://placekitten.com/400/300"
92
- caption="An incredibly cute kitten"
93
- ></doc-content-media>
94
- <doc-content-media
95
- content-type="image"
96
- content-src="https://placekitten.com/400/300"
97
- ></doc-content-media>
98
-
99
- <h2>IFrames</h2>
100
- <doc-content-media
101
- content-type="iframe"
102
- content-src="https://www.youtube.com/embed/DfV7WnyEPTE"
103
- media-title="Master Lightning Web Components in 8 Easy Steps (1)"
104
- caption="Lightning Web Components are a new development platform for Salesforce."
105
- ></doc-content-media>
106
- <doc-content-media
107
- content-type="iframe"
108
- content-src="https://play.vidyard.com/yThw736PBYf18ts1f8SKXa?disable_popouts=1&v=4.2.30&type=inline"
109
- media-title="Non-YouTube Video"
110
- caption="doc-content-media supports iframes from any origin."
111
- ></doc-content-media>
112
- </div>
113
- `;
@@ -1,6 +0,0 @@
1
- import { coveoHeaderConfig } from "../../../../../../dx-components/src/modules/utils/coveo/coveo";
2
-
3
- export default {
4
- mobile: false,
5
- ...coveoHeaderConfig
6
- };
@@ -1,437 +0,0 @@
1
- import Button from "dx/button";
2
- import Header from "doc/header";
3
- import HeaderNav from "dx/headerNav";
4
- import Icon from "dx/icon";
5
- import { createRenderComponent } from "utils/tests";
6
- import { createMediaMock } from "utils/jest";
7
- import {
8
- mockPropsDevelopers,
9
- mockPropsEmployees,
10
- mockPropsNoNavigation
11
- } from "./mockProps";
12
- import Dropdown from "dx/dropdown";
13
- import { Option } from "typings/custom";
14
- import { track } from "dx/instrumentation";
15
- import { ANALYTICS_INFO } from "utils/headerBase";
16
-
17
- const EXPECTED_QUERY_TABLET = "(max-width: 980px)";
18
- const EXPECTED_QUERY_MOBILE = "(max-width: 880px)";
19
- const SMALL_MOBILE_MATCH = "(max-width: 740px)";
20
-
21
- jest.mock("dx/instrumentation");
22
-
23
- const TAG = "doc-header";
24
- const render = createRenderComponent(TAG, Header);
25
-
26
- const assertMediaMatchCalls = () => {
27
- expect(window.matchMedia).toBeCalledTimes(3);
28
- expect(window.matchMedia).toHaveBeenNthCalledWith(1, EXPECTED_QUERY_MOBILE);
29
- expect(window.matchMedia).toHaveBeenNthCalledWith(2, EXPECTED_QUERY_TABLET);
30
-
31
- expect(window.matchMedia).toHaveBeenLastCalledWith(SMALL_MOBILE_MATCH);
32
- };
33
-
34
- const assertDropdownRender = (
35
- element: Header,
36
- dropdown: Dropdown,
37
- languages: Array<Option>
38
- ) => {
39
- expect(dropdown).not.toBeNull();
40
- expect(dropdown.classList).toHaveLength(1);
41
- expect(dropdown.classList).toContain("header_lang-dropdown");
42
- expect(dropdown.options).toHaveLength(languages.length);
43
- dropdown.options.forEach((option, index) => {
44
- const mockLang = languages[index];
45
- expect(option).toHaveProperty("id", mockLang.id);
46
- expect(option).toHaveProperty("label", mockLang.label);
47
- });
48
-
49
- expect(dropdown.valuePath).toBe(element.langValuePath);
50
- expect(dropdown.value).toBe(element.language);
51
-
52
- expect(dropdown.querySelector("dx-button")).not.toBeNull();
53
- };
54
-
55
- const testLangEvent = () => {
56
- const { languages } = mockPropsDevelopers;
57
- const [firstLang, secondLang] = languages;
58
-
59
- const element = render({
60
- ...mockPropsDevelopers,
61
- language: firstLang.id
62
- });
63
-
64
- expect(element.language).toBe(firstLang.id);
65
-
66
- const dropdown: HTMLElement = element.shadowRoot.querySelector(
67
- ".header_lang-dropdown"
68
- );
69
- const mockLangChange = jest.fn();
70
- element.addEventListener("langchange", mockLangChange);
71
-
72
- dropdown.dispatchEvent(
73
- new CustomEvent("change", { detail: secondLang.id })
74
- );
75
-
76
- expect(element.language).toBe(secondLang.id);
77
- expect(mockLangChange).toBeCalledTimes(1);
78
- expect(mockLangChange.mock.calls[0][0]).toHaveProperty(
79
- "detail",
80
- secondLang.id
81
- );
82
- return expect(element).toBeAccessible();
83
- };
84
-
85
- describe(TAG, () => {
86
- describe("desktop", () => {
87
- it("renders", () => {
88
- const element = render();
89
- expect(element.headerHref).toBe("/");
90
-
91
- const headerEl: HTMLElement =
92
- element.shadowRoot.querySelector("header");
93
- expect(headerEl).not.toBeNull();
94
- expect(headerEl.classList).toHaveLength(0);
95
-
96
- expect(headerEl.querySelector("dx-banner")).not.toBeNull();
97
-
98
- const logo = element.shadowRoot.querySelector("dx-logo");
99
- expect(logo).not.toBeNull();
100
- expect(logo.label).toBe("Salesforce");
101
-
102
- expect(
103
- element.shadowRoot.querySelector("dx-header-nav")
104
- ).toBeNull();
105
-
106
- expect(
107
- element.shadowRoot.querySelector("dx-header-search")
108
- ).toBeNull();
109
-
110
- expect(
111
- element.shadowRoot.querySelector("dx-header-mobile-nav-menu")
112
- ).toBeNull();
113
-
114
- const homeLink: HTMLAnchorElement =
115
- element.shadowRoot.querySelector(".home-link");
116
- expect(homeLink).not.toBeNull();
117
- expect(homeLink.href).toMatch(/\/$/);
118
- expect(homeLink.querySelector("dx-icon")).toBeNull();
119
-
120
- expect(element.shadowRoot.querySelector("dx-dropdown")).toBeNull();
121
-
122
- expect(
123
- element.shadowRoot.querySelector(
124
- ".header_l2_group.header_l2_group-nav"
125
- )
126
- ).toBeNull();
127
- });
128
-
129
- it("renders with some properties", () => {
130
- const subtitle = "testsubtitle";
131
- const element = render({ ...mockPropsDevelopers, subtitle });
132
-
133
- const subtitleEl = element.shadowRoot.querySelector(".subtitle");
134
- expect(subtitleEl.textContent).toEqual(subtitle);
135
-
136
- const signUp: HTMLElement = element.shadowRoot.querySelector(
137
- ".header-login-signup dx-button"
138
- );
139
- expect(signUp).not.toBeNull();
140
-
141
- const headerNavs: Array<HeaderNav> =
142
- element.shadowRoot.querySelectorAll("dx-header-nav");
143
- expect(headerNavs).toHaveLength(1);
144
- const [globalNav] = headerNavs;
145
- expect(globalNav.ariaLabel).toBe("Global Navigation Bar");
146
-
147
- const dropdown: Dropdown = element.shadowRoot.querySelector(
148
- ".header_l2_group.header_l2_group-right-ctas dx-dropdown"
149
- );
150
-
151
- assertDropdownRender(
152
- element,
153
- dropdown,
154
- mockPropsDevelopers.languages
155
- );
156
-
157
- expect(
158
- element.shadowRoot.querySelector(
159
- ".header_l2_group.header_l2_group-title dx-dropdown"
160
- )
161
- ).toBeNull();
162
-
163
- const brandIcon = element.shadowRoot.querySelector(".brand-icon");
164
- expect(brandIcon).toBeNull();
165
- return expect(element).toBeAccessible();
166
- });
167
-
168
- it("renders with scoped nav items", () => {
169
- const element = render(mockPropsEmployees);
170
-
171
- const headerNavs: Array<HeaderNav> =
172
- element.shadowRoot.querySelectorAll("dx-header-nav");
173
- expect(headerNavs).toHaveLength(2);
174
- const [globalNav, scopedNav] = headerNavs;
175
- expect(globalNav.ariaLabel).toBe("Global Navigation Bar");
176
- expect(scopedNav.ariaLabel).toBe("Scoped Navigation Bar");
177
-
178
- const brandIcon = element.shadowRoot.querySelector(".brand-icon");
179
- expect(brandIcon).not.toBeNull();
180
- return expect(element).toBeAccessible();
181
- });
182
-
183
- it("doesn't render subnav when navitems is empty", () => {
184
- const element = render(mockPropsNoNavigation);
185
-
186
- const els = element.querySelectorAll(
187
- "dx-header-mobile-nav-menu, .header_l2_group-nav"
188
- );
189
-
190
- expect(els).toHaveLength(0);
191
- });
192
-
193
- it("renders the brand icon when a brand has an icon associated", () => {
194
- const element = render(mockPropsEmployees);
195
-
196
- const brandIcon: Icon =
197
- element.shadowRoot.querySelector(".brand-icon");
198
- expect(brandIcon).not.toBeNull();
199
- expect(brandIcon.symbol).toBe(mockPropsEmployees.brand);
200
- });
201
-
202
- it("doesn't render brand icon when no brand is provided", () => {
203
- const element = render({
204
- ...mockPropsDevelopers,
205
- brand: undefined
206
- });
207
-
208
- const brandIcon: Icon =
209
- element.shadowRoot.querySelector(".brand-icon");
210
- expect(brandIcon).toBeNull();
211
- });
212
-
213
- // eslint-disable-next-line jest/expect-expect
214
- it("triggers event on language change", testLangEvent);
215
-
216
- it("triggers event onrequestopennav", () => {
217
- const element = render({
218
- ...mockPropsDevelopers
219
- });
220
- const headerEl = element.shadowRoot.querySelector("dx-header-nav");
221
- const headerMobile = element.shadowRoot.querySelector(
222
- "dx-header-mobile-nav-menu"
223
- );
224
-
225
- headerEl.dispatchEvent(
226
- new CustomEvent("requestopennavmenu", { detail: "123" })
227
- );
228
-
229
- return Promise.resolve().then(() => {
230
- expect(headerMobile.value).toEqual("123");
231
- expect(headerMobile.open).toEqual(true);
232
- });
233
- });
234
-
235
- it("tests mobile nav change", () => {
236
- const element = render({
237
- ...mockPropsDevelopers
238
- });
239
- const headerMobile = element.shadowRoot.querySelector(
240
- "dx-header-mobile-nav-menu"
241
- );
242
-
243
- headerMobile.dispatchEvent(
244
- new CustomEvent("change", { detail: "test" })
245
- );
246
- return Promise.resolve().then(() => {
247
- expect(headerMobile.value).toEqual("test");
248
- });
249
- });
250
-
251
- it("renders signup button and has bailLink", () => {
252
- const element = render({
253
- ...mockPropsEmployees,
254
- bailHref: "test",
255
- bailLabel: "test",
256
- signupLink: "/"
257
- });
258
- const buttons: Array<Button> =
259
- element.shadowRoot.querySelectorAll("dx-button");
260
-
261
- expect(buttons[0].href).toEqual("/");
262
- expect(buttons[1].href).toEqual("test");
263
- return expect(element).toBeAccessible();
264
- });
265
-
266
- it("won't render search if any coveo properties are missing", () => {
267
- const element = render({
268
- subtitle: mockPropsDevelopers.subtitle,
269
- navItems: mockPropsDevelopers.navItems
270
- });
271
- const headerSearch =
272
- element.shadowRoot.querySelector("dx-header-search");
273
-
274
- expect(headerSearch).toBeNull();
275
- return expect(element).toBeAccessible();
276
- });
277
-
278
- it("signup button track is being called", () => {
279
- const element = render(mockPropsDevelopers);
280
-
281
- const button: HTMLElement =
282
- element.shadowRoot.querySelector("dx-button");
283
-
284
- button.click();
285
-
286
- expect(track).toBeCalledTimes(1);
287
- expect(track).toBeCalledWith(button, "custEv_signupStart", {
288
- ...ANALYTICS_INFO,
289
- clickUrl: "/sign-up"
290
- });
291
- });
292
-
293
- it("hides signup button when signupLink property is empty", () => {
294
- const updatedMockPropsDevelopers = {
295
- ...mockPropsDevelopers,
296
- signupLink: ""
297
- };
298
- const element = render(updatedMockPropsDevelopers);
299
- const signupButtonContainer: HTMLElement =
300
- element.shadowRoot.querySelector(".header-login-signup");
301
- expect(signupButtonContainer).toBeNull();
302
- });
303
-
304
- it("hides banner when banner markup is empty", () => {
305
- const bannerMarkup = "";
306
- const updatedMockPropsDevelopers = {
307
- ...mockPropsDevelopers,
308
- bannerMarkup
309
- };
310
- const element = render(updatedMockPropsDevelopers);
311
- const bannerElement: HTMLElement =
312
- element.shadowRoot.querySelector("dx-banner");
313
- expect(bannerElement).toBeNull();
314
- });
315
- });
316
-
317
- describe("tablet", () => {
318
- beforeEach(() => {
319
- window.matchMedia = createMediaMock(false, [false, true, false]);
320
- });
321
-
322
- it("renders tablet specific elements", () => {
323
- const element = render(mockPropsDevelopers);
324
-
325
- const button: HTMLElement = element.shadowRoot.querySelector(
326
- ".nav_menu-ctas .nav_menu-button"
327
- );
328
- expect(button).toBeNull();
329
-
330
- const headerSearch =
331
- element.shadowRoot.querySelector("dx-header-search");
332
- expect(headerSearch).not.toBeNull();
333
- expect(headerSearch.mobile).toBe(true);
334
-
335
- const signupDiv = element.shadowRoot.querySelector(
336
- ".header-login-signup"
337
- );
338
- expect(signupDiv).not.toBeNull();
339
- expect(
340
- element.shadowRoot.querySelector(
341
- ".header_l2_group.header_l2_group-right-ctas dx-dropdown"
342
- )
343
- ).not.toBeNull();
344
- expect(
345
- element.shadowRoot.querySelector(
346
- ".header_l2_group.header_l2_group-title dx-dropdown"
347
- )
348
- ).toBeNull();
349
-
350
- assertMediaMatchCalls();
351
- });
352
- });
353
-
354
- describe("mobile", () => {
355
- beforeEach(() => {
356
- window.matchMedia = createMediaMock(false, [true, true, false]);
357
- });
358
-
359
- it("renders mobile specific elements", () => {
360
- const element = render(mockPropsDevelopers);
361
-
362
- const button: HTMLElement = element.shadowRoot.querySelector(
363
- ".nav_menu-ctas .nav_menu-button"
364
- );
365
- expect(button).not.toBeNull();
366
-
367
- const headerSearch =
368
- element.shadowRoot.querySelector("dx-header-search");
369
-
370
- expect(
371
- element.shadowRoot.querySelector(
372
- ".header_l2_group.header_l2_group-right-ctas dx-dropdown"
373
- )
374
- ).not.toBeNull();
375
- expect(
376
- element.shadowRoot.querySelector(
377
- ".header_l2_group.header_l2_group-title dx-dropdown"
378
- )
379
- ).toBeNull();
380
- expect(headerSearch).not.toBeNull();
381
- expect(headerSearch.mobile).toBe(true);
382
-
383
- assertMediaMatchCalls();
384
- });
385
-
386
- it("tests toggle button", () => {
387
- const element = render(mockPropsDevelopers);
388
- const button: HTMLElement = element.shadowRoot.querySelector(
389
- ".nav_menu-ctas .nav_menu-button"
390
- );
391
- expect(button).not.toBeNull();
392
- const header = element.shadowRoot.querySelector(
393
- "dx-header-mobile-nav-menu"
394
- );
395
- expect(header).not.toBeNull();
396
-
397
- const toggleStatus = header.open;
398
-
399
- button.click();
400
-
401
- return Promise.resolve().then(() =>
402
- expect(header.open).toEqual(!toggleStatus)
403
- );
404
- });
405
- });
406
-
407
- describe("small mobile", () => {
408
- beforeEach(() => {
409
- window.matchMedia = createMediaMock(true);
410
- });
411
-
412
- it("renders small mobile specific elements", () => {
413
- const element = render(mockPropsDevelopers);
414
- const dropdown = element.shadowRoot.querySelector(
415
- ".header_l2_group.header_l2_group-title dx-dropdown"
416
- );
417
-
418
- expect(dropdown).not.toBeNull();
419
- assertDropdownRender(
420
- element,
421
- dropdown,
422
- mockPropsDevelopers.languages
423
- );
424
-
425
- expect(
426
- element.shadowRoot.querySelector(
427
- ".header_l2_group.header_l2_group-right-ctas dx-dropdown"
428
- )
429
- ).toBeNull();
430
-
431
- return expect(element).toBeAccessible();
432
- });
433
-
434
- // eslint-disable-next-line jest/expect-expect
435
- it("triggers event on language change", testLangEvent);
436
- });
437
- });