@coveo/quantic 3.16.0 → 3.16.1-pre.1a6fc4649f

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 (116) hide show
  1. package/docs/out/quantic-docs.json +2 -2
  2. package/force-app/main/default/lwc/quanticNumberButton/quanticNumberButton.html +1 -1
  3. package/force-app/main/default/lwc/quanticResultsPerPage/quanticResultsPerPage.js +27 -17
  4. package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +6 -6
  5. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
  6. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.d.ts +0 -1
  7. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
  8. package/force-app/main/default/staticresources/coveoheadless/definitions/features/parameter-manager/parameter-manager-selectors.d.ts +5 -0
  9. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-parameters/search-parameter-actions-loader.d.ts +36 -0
  10. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-parameters/search-parameter-actions.d.ts +6 -0
  11. package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
  12. package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -9
  13. package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +5 -5
  14. package/package.json +6 -4
  15. package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +0 -604
  16. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +0 -76
  17. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +0 -282
  18. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +0 -167
  19. package/force-app/main/default/lwc/quanticCarousel/__tests__/quanticCarousel.test.js +0 -262
  20. package/force-app/main/default/lwc/quanticCaseClassification/__tests__/quanticCaseClassification.test.js +0 -819
  21. package/force-app/main/default/lwc/quanticCaseClassification/e2e/data.ts +0 -23
  22. package/force-app/main/default/lwc/quanticCaseClassification/e2e/fixture.ts +0 -51
  23. package/force-app/main/default/lwc/quanticCaseClassification/e2e/pageObject.ts +0 -152
  24. package/force-app/main/default/lwc/quanticCaseClassification/e2e/quanticCaseClassification.e2e.ts +0 -269
  25. package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +0 -327
  26. package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +0 -269
  27. package/force-app/main/default/lwc/quanticColoredResultBadge/__tests__/quanticColoredResultBadge.test.js +0 -212
  28. package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +0 -321
  29. package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +0 -199
  30. package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +0 -341
  31. package/force-app/main/default/lwc/quanticFacetCaption/__tests__/quanticFacetCaption.test.js +0 -28
  32. package/force-app/main/default/lwc/quanticFacetManager/__tests__/quanticFacetManager.test.js +0 -178
  33. package/force-app/main/default/lwc/quanticFacetManager/e2e/fixture.ts +0 -63
  34. package/force-app/main/default/lwc/quanticFacetManager/e2e/pageObject.ts +0 -23
  35. package/force-app/main/default/lwc/quanticFacetManager/e2e/quanticFacetManager.e2e.ts +0 -82
  36. package/force-app/main/default/lwc/quanticFeedback/__tests__/quanticFeedback.test.js +0 -392
  37. package/force-app/main/default/lwc/quanticFeedbackModal/__tests__/quanticFeedbackModal.test.js +0 -448
  38. package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +0 -298
  39. package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +0 -814
  40. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +0 -56
  41. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +0 -87
  42. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +0 -283
  43. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +0 -199
  44. package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +0 -151
  45. package/force-app/main/default/lwc/quanticHeading/__tests__/quanticHeading.test.js +0 -71
  46. package/force-app/main/default/lwc/quanticHeadlessLoader/__tests__/quanticHeadlessLoader.test.js +0 -651
  47. package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +0 -335
  48. package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +0 -343
  49. package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +0 -63
  50. package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +0 -69
  51. package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +0 -101
  52. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/defaultTestCase.json +0 -13
  53. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/youtubeTestCase.json +0 -14
  54. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/quanticQuickviewContent.test.js +0 -82
  55. package/force-app/main/default/lwc/quanticRadioButtonsGroup/__tests__/quanticRadioButtonsGroup.test.js +0 -273
  56. package/force-app/main/default/lwc/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +0 -501
  57. package/force-app/main/default/lwc/quanticResultAction/__tests__/quanticResultAction.test.js +0 -262
  58. package/force-app/main/default/lwc/quanticResultActionBar/__tests__/quanticResultActionBar.test.js +0 -141
  59. package/force-app/main/default/lwc/quanticResultChildren/__tests__/quanticResultChildren.test.js +0 -340
  60. package/force-app/main/default/lwc/quanticResultDate/__tests__/quanticResultDate.test.js +0 -144
  61. package/force-app/main/default/lwc/quanticResultField/__tests__/quanticResultField.test.js +0 -120
  62. package/force-app/main/default/lwc/quanticResultHighlightedTextField/__tests__/quanticResultHighlightedTextField.test.js +0 -209
  63. package/force-app/main/default/lwc/quanticResultLink/__tests__/quanticResultLink.test.js +0 -261
  64. package/force-app/main/default/lwc/quanticResultMultiValueText/__tests__/quanticResultMultiValueText.test.js +0 -235
  65. package/force-app/main/default/lwc/quanticResultNumber/__tests__/quanticResultNumber.test.js +0 -144
  66. package/force-app/main/default/lwc/quanticResultPrintableUri/__tests__/quanticResultPrintableUri.test.js +0 -324
  67. package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +0 -171
  68. package/force-app/main/default/lwc/quanticResultText/__tests__/quanticResultText.test.js +0 -155
  69. package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +0 -404
  70. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +0 -74
  71. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +0 -85
  72. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +0 -97
  73. package/force-app/main/default/lwc/quanticSearchBox/__tests__/quanticSearchBox.test.js +0 -168
  74. package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +0 -823
  75. package/force-app/main/default/lwc/quanticSmartSnippet/__tests__/quanticSmartSnippet.test.js +0 -341
  76. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +0 -21
  77. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +0 -91
  78. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +0 -196
  79. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +0 -168
  80. package/force-app/main/default/lwc/quanticSmartSnippetAnswer/__tests__/quanticSmartSnippetAnswer.test.js +0 -126
  81. package/force-app/main/default/lwc/quanticSmartSnippetSource/__tests__/quanticSmartSnippetSource.test.js +0 -290
  82. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +0 -329
  83. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +0 -31
  84. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +0 -93
  85. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +0 -160
  86. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +0 -127
  87. package/force-app/main/default/lwc/quanticSort/__tests__/quanticSort.test.js +0 -416
  88. package/force-app/main/default/lwc/quanticSort/e2e/fixture.ts +0 -61
  89. package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +0 -89
  90. package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +0 -91
  91. package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +0 -123
  92. package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +0 -186
  93. package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +0 -222
  94. package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +0 -287
  95. package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +0 -62
  96. package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +0 -67
  97. package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +0 -77
  98. package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +0 -331
  99. package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +0 -61
  100. package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +0 -80
  101. package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +0 -173
  102. package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +0 -339
  103. package/force-app/main/default/lwc/quanticTooltip/__tests__/quanticTooltip.test.js +0 -107
  104. package/force-app/main/default/lwc/quanticUserAction/__tests__/quanticUserAction.test.js +0 -427
  105. package/force-app/main/default/lwc/quanticUserActionsSession/__tests__/quanticUserActionsSession.test.js +0 -269
  106. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/data/userActionsState.json +0 -89
  107. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/quanticUserActionsTimeline.test.js +0 -511
  108. package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +0 -229
  109. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +0 -32
  110. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +0 -32
  111. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +0 -71
  112. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +0 -39
  113. package/force-app/main/default/lwc/quanticUtils/__tests__/facetDependenciesUtils.test.js +0 -92
  114. package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +0 -71
  115. package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +0 -223
  116. package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +0 -131
@@ -1,223 +0,0 @@
1
- import {
2
- I18nUtils,
3
- buildTemplateTextFromResult,
4
- copyToClipboard,
5
- TimeSpan,
6
- } from 'c/quanticUtils';
7
-
8
- describe('c/quanticUtils', () => {
9
- describe('I18nUtils', () => {
10
- it('getTextWithDecorator should return text wrapped in given tags', () => {
11
- const text = 'sample text';
12
- const startTag = '<test-start-tag>';
13
- const endTag = '<test-end-tag>';
14
- expect(I18nUtils.getTextWithDecorator(text, startTag, endTag)).toBe(
15
- `${startTag}${text}${endTag}`
16
- );
17
- });
18
-
19
- it('getTextBold should return text wrapped in bold tags', () => {
20
- const text = 'sample text';
21
- expect(I18nUtils.getTextBold(text)).toBe(`<b>${text}</b>`);
22
- });
23
-
24
- describe('getLabelNameWithCount', () => {
25
- const testLabelName = 'thisLabelName';
26
- const testLabelNamePlural = `${testLabelName}_plural`;
27
- const testLabelNameZero = `${testLabelName}_zero`;
28
-
29
- it('should return plural variant if count not equal to 1', () => {
30
- expect(I18nUtils.getLabelNameWithCount(testLabelName, 99)).toBe(
31
- testLabelNamePlural
32
- );
33
- });
34
-
35
- it('should return plural variant if count is fraction of 1', () => {
36
- expect(I18nUtils.getLabelNameWithCount(testLabelName, 0.5)).toBe(
37
- testLabelNamePlural
38
- );
39
- });
40
-
41
- it('should return zero variant if count is 0', () => {
42
- expect(I18nUtils.getLabelNameWithCount(testLabelName, 0)).toBe(
43
- testLabelNameZero
44
- );
45
- });
46
-
47
- it('should return singular variant if count is equal to 1', () => {
48
- expect(I18nUtils.getLabelNameWithCount(testLabelName, 1)).toBe(
49
- testLabelName
50
- );
51
- });
52
-
53
- it('should return singular variant if count is equal to -1', () => {
54
- expect(I18nUtils.getLabelNameWithCount(testLabelName, -1)).toBe(
55
- testLabelName
56
- );
57
- });
58
-
59
- describe('given other locale', () => {
60
- jest.resetModules();
61
- jest.mock('@salesforce/i18n/locale', () => ({
62
- default: 'de-DE',
63
- }));
64
- const withOtherLocale = require('c/quanticUtils');
65
-
66
- it('should return label name without failing', () => {
67
- expect(() =>
68
- withOtherLocale.I18nUtils.getLabelNameWithCount(testLabelName, 2)
69
- ).not.toThrow();
70
- });
71
- });
72
- });
73
-
74
- describe('format', () => {
75
- it('should throw an error if the given string is not a string', () => {
76
- let caughtError;
77
- try {
78
- I18nUtils.format(undefined);
79
- } catch (error) {
80
- caughtError = error;
81
- }
82
- expect(caughtError).toBeDefined();
83
- });
84
-
85
- it('should return the given string if no formatting arguments are given', () => {
86
- const testString = 'this is a test string';
87
- expect(I18nUtils.format(testString)).toBe(testString);
88
- });
89
-
90
- it('should return the given string with formatting arguments inserted in order', () => {
91
- const testString = 'this is a {{0}} string, {{1}}.';
92
- const test = 'test';
93
- const buddy = 'buddy';
94
- expect(I18nUtils.format(testString, test, buddy)).toBe(
95
- 'this is a test string, buddy.'
96
- );
97
- });
98
- });
99
-
100
- describe('escapeHTML', () => {
101
- it('should escape html tags', () => {
102
- let htmlWithTags = '<div>test string</div>';
103
-
104
- expect(I18nUtils.escapeHTML(htmlWithTags)).toBe(
105
- '&lt;div&gt;test string&lt;/div&gt;'
106
- );
107
- });
108
-
109
- it('should escape html anchor tags', () => {
110
- let htmlWithTags = '<a src="http://www.sketchysite.com"></a>';
111
-
112
- expect(I18nUtils.escapeHTML(htmlWithTags)).toBe(
113
- '&lt;a src="http://www.sketchysite.com"&gt;&lt;/a&gt;'
114
- );
115
- });
116
- });
117
- });
118
-
119
- describe('copy to clipboard', () => {
120
- const mockExecCommand = jest.fn(() => {});
121
- const mockWriteText = jest.fn(() => new Promise(() => {}));
122
-
123
- beforeAll(() => {
124
- Object.defineProperty(document, 'execCommand', {
125
- value: mockExecCommand,
126
- writable: true,
127
- });
128
- });
129
-
130
- afterEach(() => {
131
- jest.clearAllMocks();
132
- });
133
-
134
- describe('when the Clipboard API is available', () => {
135
- it('should correctly perform the copy to clipboard operation using the writeText method', () => {
136
- const exampleText = 'example text';
137
-
138
- Object.defineProperty(navigator, 'clipboard', {
139
- value: {
140
- ...navigator.clipboard,
141
- writeText: mockWriteText,
142
- },
143
- writable: true,
144
- });
145
-
146
- copyToClipboard(exampleText);
147
- expect(mockWriteText).toHaveBeenCalledTimes(1);
148
- expect(mockWriteText.mock.calls[0][0]).toBe(exampleText);
149
- expect(mockExecCommand).toHaveBeenCalledTimes(0);
150
- });
151
- });
152
-
153
- describe('when the Clipboard API is not available', () => {
154
- it('should correctly perform the copy to clipboard operation using the DOM method', () => {
155
- const exampleText = 'example text';
156
-
157
- Object.defineProperty(navigator, 'clipboard', {
158
- value: undefined,
159
- writable: true,
160
- });
161
-
162
- copyToClipboard(exampleText);
163
- expect(mockWriteText).toHaveBeenCalledTimes(0);
164
- expect(mockExecCommand).toHaveBeenCalledTimes(1);
165
- });
166
- });
167
- });
168
-
169
- describe('buildTemplateTextFromResult', () => {
170
- const testTemplate =
171
- '<a href="${clickUri}">${title}</a><br/><br/><quote>${excerpt}</quote>';
172
- const testResult = {
173
- clickUri: 'https://www.example.com',
174
- title: 'Example Title',
175
- excerpt: 'This is an example excerpt.',
176
- };
177
-
178
- it('should return a string with the result values inserted into the template', () => {
179
- // @ts-ignore
180
- expect(buildTemplateTextFromResult(testTemplate, testResult)).toBe(
181
- `<a href="${testResult.clickUri}">${testResult.title}</a><br/><br/><quote>${testResult.excerpt}</quote>`
182
- );
183
- });
184
-
185
- it('should return an empty string if the template is undefined or falsy', () => {
186
- // @ts-ignore
187
- expect(buildTemplateTextFromResult(undefined, testResult)).toBe('');
188
- });
189
-
190
- it('should not return the template field name as placeholder if the result does not contain the field', () => {
191
- const resultWithoutExcerpt = {
192
- clickUri: 'https://www.example.com',
193
- title: 'Example Title',
194
- };
195
-
196
- // @ts-ignore
197
- expect(
198
- buildTemplateTextFromResult(testTemplate, resultWithoutExcerpt)
199
- ).toBe(
200
- `<a href="${testResult.clickUri}">${testResult.title}</a><br/><br/><quote></quote>`
201
- );
202
- });
203
- });
204
-
205
- describe('TimeSpan', () => {
206
- describe('getYoutubeFormatTimestamp', () => {
207
- it('should return the correct YouTube timestamp format for timestamps of less than a minute', () => {
208
- const timeSpan = new TimeSpan(45000); // 45 seconds
209
- expect(timeSpan.getYoutubeFormatTimestamp()).toBe('0:45');
210
- });
211
-
212
- it('should return the correct YouTube timestamp format for timestamps of more than an hour', () => {
213
- const timeSpan = new TimeSpan(3661000); // 1 hour, 1 minute, and 1 second
214
- expect(timeSpan.getYoutubeFormatTimestamp()).toBe('1:01:01');
215
- });
216
-
217
- it('should return the correct YouTube timestamp format for timestamps of less than an hour', () => {
218
- const timeSpan = new TimeSpan(300000); // 5 minutes
219
- expect(timeSpan.getYoutubeFormatTimestamp()).toBe('05:00');
220
- });
221
- });
222
- });
223
- });
@@ -1,131 +0,0 @@
1
- // @ts-ignore
2
- import {createElement} from 'lwc';
3
- import QuanticViewedByCustomerBadge from '../quanticViewedByCustomerBadge';
4
-
5
- const viewedByCustomerLabel = 'Viewed by customer';
6
- const viewedByCustomerIconName = 'utility:profile_alt';
7
- const errorMessage =
8
- 'The c-quantic-viewed-by-customer-badge requires the result attribute to be set.';
9
-
10
- jest.mock(
11
- '@salesforce/label/c.quantic_ViewedByCustomer',
12
- () => ({default: viewedByCustomerLabel}),
13
- {
14
- virtual: true,
15
- }
16
- );
17
-
18
- const selectors = {
19
- errorComponent: 'c-quantic-component-error',
20
- label: '.viewed-by-customer__label',
21
- icon: 'lightning-icon',
22
- };
23
-
24
- function createTestComponent(options) {
25
- const element = createElement('c-quantic-viewed-by-customer-badge', {
26
- is: QuanticViewedByCustomerBadge,
27
- });
28
-
29
- for (const [key, value] of Object.entries(options)) {
30
- element[key] = value;
31
- }
32
-
33
- document.body.appendChild(element);
34
- return element;
35
- }
36
-
37
- // Helper function to wait until the microtask queue is empty.
38
- function flushPromises() {
39
- return new Promise((resolve) => setTimeout(resolve, 0));
40
- }
41
-
42
- describe('c-quantic-viewed-by-customer-badge', () => {
43
- function cleanup() {
44
- // The jsdom instance is shared across test cases in a single file so reset the DOM
45
- while (document.body.firstChild) {
46
- document.body.removeChild(document.body.firstChild);
47
- }
48
- jest.clearAllMocks();
49
- }
50
-
51
- afterEach(() => {
52
- cleanup();
53
- });
54
-
55
- describe('when no result is given', () => {
56
- let consoleError;
57
-
58
- beforeAll(() => {
59
- consoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
60
- });
61
-
62
- afterAll(() => {
63
- consoleError.mockReset();
64
- });
65
-
66
- it('should show the component error and log an error message', async () => {
67
- const element = createTestComponent({});
68
- await flushPromises();
69
-
70
- const errorComponent = element.shadowRoot.querySelector(
71
- selectors.errorComponent
72
- );
73
-
74
- expect(errorComponent).not.toBeNull();
75
- expect(consoleError).toHaveBeenCalledWith(errorMessage);
76
- });
77
- });
78
-
79
- describe('when isUserActionView has the value true in the result', () => {
80
- it('should render the viewed by customer badge', async () => {
81
- const element = createTestComponent({result: {isUserActionView: true}});
82
- await flushPromises();
83
-
84
- const errorComponent = element.shadowRoot.querySelector(
85
- selectors.errorComponent
86
- );
87
- const label = element.shadowRoot.querySelector(selectors.label);
88
- const icon = element.shadowRoot.querySelector(selectors.icon);
89
-
90
- expect(errorComponent).toBeNull();
91
- expect(label).not.toBeNull();
92
- expect(label.textContent).toBe(viewedByCustomerLabel);
93
- expect(icon).not.toBeNull();
94
- expect(icon.iconName).toBe(viewedByCustomerIconName);
95
- });
96
- });
97
-
98
- describe('when isUserActionView has the value false in the result', () => {
99
- it('should not render the viewed by customer badge', async () => {
100
- const element = createTestComponent({result: {isUserActionView: false}});
101
- await flushPromises();
102
-
103
- const errorComponent = element.shadowRoot.querySelector(
104
- selectors.errorComponent
105
- );
106
- const label = element.shadowRoot.querySelector(selectors.label);
107
- const icon = element.shadowRoot.querySelector(selectors.icon);
108
-
109
- expect(errorComponent).toBeNull();
110
- expect(label).toBeNull();
111
- expect(icon).toBeNull();
112
- });
113
- });
114
-
115
- describe('when isUserActionView is undefined in the result', () => {
116
- it('should not render the viewed by customer badge', async () => {
117
- const element = createTestComponent({result: {}});
118
- await flushPromises();
119
-
120
- const errorComponent = element.shadowRoot.querySelector(
121
- selectors.errorComponent
122
- );
123
- const label = element.shadowRoot.querySelector(selectors.label);
124
- const icon = element.shadowRoot.querySelector(selectors.icon);
125
-
126
- expect(errorComponent).toBeNull();
127
- expect(label).toBeNull();
128
- expect(icon).toBeNull();
129
- });
130
- });
131
- });