@internetarchive/collection-browser 0.4.10 → 0.4.11

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 (229) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +26 -26
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/LICENSE +661 -661
  8. package/README.md +83 -83
  9. package/dist/index.d.ts +9 -9
  10. package/dist/index.js +9 -9
  11. package/dist/src/app-root.d.ts +50 -50
  12. package/dist/src/app-root.js +278 -278
  13. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  14. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  15. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  16. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  17. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  18. package/dist/src/assets/img/icons/chevron.js +2 -2
  19. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  20. package/dist/src/assets/img/icons/empty-query.js +2 -2
  21. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
  22. package/dist/src/assets/img/icons/eye-closed.js +2 -2
  23. package/dist/src/assets/img/icons/eye.d.ts +2 -2
  24. package/dist/src/assets/img/icons/eye.js +2 -2
  25. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  26. package/dist/src/assets/img/icons/favorite-filled.js +2 -2
  27. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  28. package/dist/src/assets/img/icons/login-required.js +2 -2
  29. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  30. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  31. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  32. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  33. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  34. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  35. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  36. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  37. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  38. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  39. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  40. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  41. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  42. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  43. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  44. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  45. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  46. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  47. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  48. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  49. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  50. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  51. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  52. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  53. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  54. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  55. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  56. package/dist/src/assets/img/icons/null-result.js +2 -2
  57. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  58. package/dist/src/assets/img/icons/restricted.js +2 -2
  59. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  60. package/dist/src/assets/img/icons/reviews.js +2 -2
  61. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  62. package/dist/src/assets/img/icons/upload.js +2 -2
  63. package/dist/src/assets/img/icons/views.d.ts +1 -1
  64. package/dist/src/assets/img/icons/views.js +2 -2
  65. package/dist/src/circular-activity-indicator.d.ts +5 -5
  66. package/dist/src/circular-activity-indicator.js +17 -17
  67. package/dist/src/collection-browser.d.ts +279 -279
  68. package/dist/src/collection-browser.js +1156 -1156
  69. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  70. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  71. package/dist/src/collection-facets/facets-template.d.ts +16 -16
  72. package/dist/src/collection-facets/facets-template.js +125 -125
  73. package/dist/src/collection-facets/more-facets-content.d.ts +75 -75
  74. package/dist/src/collection-facets/more-facets-content.js +340 -340
  75. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  76. package/dist/src/collection-facets/more-facets-pagination.js +192 -192
  77. package/dist/src/collection-facets.d.ts +81 -81
  78. package/dist/src/collection-facets.js +375 -375
  79. package/dist/src/empty-placeholder.d.ts +11 -11
  80. package/dist/src/empty-placeholder.js +42 -42
  81. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  82. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  83. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  84. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  85. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  86. package/dist/src/mediatype/mediatype-config.js +85 -85
  87. package/dist/src/models.d.ts +115 -115
  88. package/dist/src/models.js +125 -125
  89. package/dist/src/restoration-state-handler.d.ts +45 -45
  90. package/dist/src/restoration-state-handler.js +230 -230
  91. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
  92. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
  93. package/dist/src/sort-filter-bar/alpha-bar.d.ts +20 -20
  94. package/dist/src/sort-filter-bar/alpha-bar.js +136 -128
  95. package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
  96. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  97. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  98. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  99. package/dist/src/sort-filter-bar/img/list.js +2 -2
  100. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  101. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  102. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  103. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  104. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +108 -108
  105. package/dist/src/sort-filter-bar/sort-filter-bar.js +438 -438
  106. package/dist/src/styles/item-image-styles.d.ts +8 -8
  107. package/dist/src/styles/item-image-styles.js +9 -9
  108. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  109. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  110. package/dist/src/tiles/grid/account-tile.d.ts +20 -20
  111. package/dist/src/tiles/grid/account-tile.js +64 -64
  112. package/dist/src/tiles/grid/collection-tile.d.ts +17 -17
  113. package/dist/src/tiles/grid/collection-tile.js +71 -71
  114. package/dist/src/tiles/grid/item-tile.d.ts +32 -32
  115. package/dist/src/tiles/grid/item-tile.js +122 -122
  116. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
  117. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +7 -7
  118. package/dist/src/tiles/grid/tile-stats.d.ts +10 -10
  119. package/dist/src/tiles/grid/tile-stats.js +40 -40
  120. package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
  121. package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
  122. package/dist/src/tiles/hover/tile-hover-pane.d.ts +15 -15
  123. package/dist/src/tiles/hover/tile-hover-pane.js +38 -38
  124. package/dist/src/tiles/image-block.d.ts +17 -17
  125. package/dist/src/tiles/image-block.js +72 -72
  126. package/dist/src/tiles/item-image.d.ts +35 -35
  127. package/dist/src/tiles/item-image.js +117 -117
  128. package/dist/src/tiles/list/account-label.d.ts +1 -1
  129. package/dist/src/tiles/list/account-label.js +6 -6
  130. package/dist/src/tiles/list/date-label.d.ts +1 -1
  131. package/dist/src/tiles/list/date-label.js +12 -12
  132. package/dist/src/tiles/list/tile-list-compact-header.d.ts +12 -12
  133. package/dist/src/tiles/list/tile-list-compact-header.js +41 -41
  134. package/dist/src/tiles/list/tile-list-compact.d.ts +21 -21
  135. package/dist/src/tiles/list/tile-list-compact.js +99 -99
  136. package/dist/src/tiles/list/tile-list.d.ts +55 -55
  137. package/dist/src/tiles/list/tile-list.js +301 -301
  138. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  139. package/dist/src/tiles/mediatype-icon.js +47 -47
  140. package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
  141. package/dist/src/tiles/overlay/icon-overlay.js +40 -40
  142. package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
  143. package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
  144. package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
  145. package/dist/src/tiles/overlay/text-overlay.js +42 -42
  146. package/dist/src/tiles/text-snippet-block.d.ts +27 -27
  147. package/dist/src/tiles/text-snippet-block.js +73 -73
  148. package/dist/src/tiles/tile-dispatcher.d.ts +58 -58
  149. package/dist/src/tiles/tile-dispatcher.js +194 -194
  150. package/dist/src/utils/analytics-events.d.ts +22 -22
  151. package/dist/src/utils/analytics-events.js +24 -24
  152. package/dist/src/utils/format-count.d.ts +7 -7
  153. package/dist/src/utils/format-count.js +76 -76
  154. package/dist/src/utils/format-date.d.ts +2 -2
  155. package/dist/src/utils/format-date.js +23 -23
  156. package/dist/src/utils/format-unit-size.d.ts +2 -2
  157. package/dist/src/utils/format-unit-size.js +33 -33
  158. package/dist/test/collection-browser.test.d.ts +1 -1
  159. package/dist/test/collection-browser.test.js +584 -584
  160. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  161. package/dist/test/collection-facets/facets-template.test.js +62 -62
  162. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  163. package/dist/test/collection-facets/more-facets-content.test.js +114 -114
  164. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  165. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  166. package/dist/test/collection-facets.test.d.ts +2 -2
  167. package/dist/test/collection-facets.test.js +460 -460
  168. package/dist/test/empty-placeholder.test.d.ts +1 -1
  169. package/dist/test/empty-placeholder.test.js +33 -33
  170. package/dist/test/icon-overlay.test.d.ts +1 -1
  171. package/dist/test/icon-overlay.test.js +24 -24
  172. package/dist/test/image-block.test.d.ts +1 -1
  173. package/dist/test/image-block.test.js +48 -48
  174. package/dist/test/item-image.test.d.ts +1 -1
  175. package/dist/test/item-image.test.js +84 -84
  176. package/dist/test/mediatype-config.test.d.ts +1 -1
  177. package/dist/test/mediatype-config.test.js +16 -16
  178. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  179. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  180. package/dist/test/mocks/mock-collection-name-cache.d.ts +7 -7
  181. package/dist/test/mocks/mock-collection-name-cache.js +13 -13
  182. package/dist/test/mocks/mock-search-responses.d.ts +12 -12
  183. package/dist/test/mocks/mock-search-responses.js +341 -341
  184. package/dist/test/mocks/mock-search-service.d.ts +13 -13
  185. package/dist/test/mocks/mock-search-service.js +40 -40
  186. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  187. package/dist/test/restoration-state-handler.test.js +125 -125
  188. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
  189. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
  190. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
  191. package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
  192. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  193. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +197 -197
  194. package/dist/test/text-overlay.test.d.ts +1 -1
  195. package/dist/test/text-overlay.test.js +48 -48
  196. package/dist/test/text-snippet-block.test.d.ts +1 -1
  197. package/dist/test/text-snippet-block.test.js +57 -57
  198. package/dist/test/tile-stats.test.d.ts +1 -1
  199. package/dist/test/tile-stats.test.js +33 -33
  200. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
  201. package/dist/test/tiles/grid/account-tile.test.js +76 -76
  202. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
  203. package/dist/test/tiles/grid/collection-tile.test.js +73 -73
  204. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  205. package/dist/test/tiles/grid/item-tile.test.js +158 -158
  206. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
  207. package/dist/test/tiles/hover/hover-pane-controller.test.js +257 -257
  208. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
  209. package/dist/test/tiles/hover/tile-hover-pane.test.js +13 -13
  210. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  211. package/dist/test/tiles/list/tile-list-compact.test.js +92 -92
  212. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  213. package/dist/test/tiles/list/tile-list.test.js +163 -163
  214. package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
  215. package/dist/test/tiles/tile-dispatcher.test.js +67 -67
  216. package/dist/test/utils/format-count.test.d.ts +1 -1
  217. package/dist/test/utils/format-count.test.js +23 -23
  218. package/dist/test/utils/format-date.test.d.ts +1 -1
  219. package/dist/test/utils/format-date.test.js +17 -17
  220. package/dist/test/utils/format-unit-size.test.d.ts +1 -1
  221. package/dist/test/utils/format-unit-size.test.js +17 -17
  222. package/local.archive.org.cert +86 -86
  223. package/local.archive.org.key +27 -27
  224. package/package.json +1 -1
  225. package/renovate.json +6 -6
  226. package/src/sort-filter-bar/alpha-bar.ts +8 -0
  227. package/tsconfig.json +21 -21
  228. package/web-dev-server.config.mjs +30 -30
  229. package/web-test-runner.config.mjs +41 -41
@@ -1,465 +1,465 @@
1
- /* eslint-disable import/no-duplicates */
2
- import { expect, fixture } from '@open-wc/testing';
3
- import sinon from 'sinon';
4
- import { html } from 'lit';
5
- import { Aggregation } from '@internetarchive/search-service';
6
- import { ModalManager, } from '@internetarchive/modal-manager';
7
- import '@internetarchive/modal-manager';
8
- import '../src/collection-facets';
9
- import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
10
- describe('Collection Facets', () => {
11
- it('has loader', async () => {
12
- var _a, _b, _c, _d;
13
- const el = await fixture(html `<collection-facets ?facetsLoading=${true}></collection-facets>`);
14
- expect((_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#container')) === null || _b === void 0 ? void 0 : _b.classList.contains('loading')).to.be.true;
15
- el.facetsLoading = false;
16
- await el.updateComplete;
17
- expect((_d = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#container')) === null || _d === void 0 ? void 0 : _d.classList.contains('loading')).to.be.false;
18
- });
19
- it('renders a date picker loading placeholder when date picker enabled', async () => {
20
- var _a;
21
- const el = await fixture(html `<collection-facets></collection-facets>`);
22
- el.fullYearAggregationLoading = true;
23
- el.showHistogramDatePicker = true;
24
- await el.updateComplete;
25
- const histogramLoader = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.histogram-loading-indicator');
26
- expect(histogramLoader).to.exist;
27
- });
28
- it('does not render a date picker loading placeholder when date picker disabled', async () => {
29
- var _a;
30
- const el = await fixture(html `<collection-facets></collection-facets>`);
31
- el.fullYearAggregationLoading = true;
32
- el.showHistogramDatePicker = false;
33
- await el.updateComplete;
34
- const histogramLoader = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.histogram-loading-indicator');
35
- expect(histogramLoader).to.be.null;
36
- });
37
- it('renders the date picker when enabled with data present', async () => {
38
- var _a;
39
- const el = await fixture(html `<collection-facets></collection-facets>`);
40
- el.fullYearAggregationLoading = false;
41
- el.showHistogramDatePicker = true;
42
- el.fullYearsHistogramAggregation = new Aggregation({
43
- buckets: [1, 2, 3],
44
- first_bucket_key: 0,
45
- last_bucket_key: 2,
46
- });
47
- await el.updateComplete;
48
- const histogram = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('histogram-date-range');
49
- expect(histogram).to.exist;
50
- });
51
- it('does not render the date picker when disabled', async () => {
52
- var _a;
53
- const el = await fixture(html `<collection-facets></collection-facets>`);
54
- el.fullYearAggregationLoading = false;
55
- el.showHistogramDatePicker = false;
56
- el.fullYearsHistogramAggregation = new Aggregation({
57
- buckets: [1, 2, 3],
58
- first_bucket_key: 0,
59
- last_bucket_key: 2,
60
- });
61
- await el.updateComplete;
62
- const histogram = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('histogram-date-range');
63
- expect(histogram).to.be.null;
64
- });
65
- it('renders aggregations as facets', async () => {
66
- var _a, _b, _c, _d, _e;
67
- const el = await fixture(html `<collection-facets></collection-facets>`);
68
- const aggs = {
69
- subject: new Aggregation({
70
- buckets: [
71
- {
72
- key: 'foo',
73
- doc_count: 5,
74
- },
75
- ],
76
- }),
77
- };
78
- el.aggregations = aggs;
79
- await el.updateComplete;
80
- const facetGroups = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.facet-group');
81
- expect(facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups.length).to.equal(1);
82
- const titleFacetGroup = facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups[0];
83
- const facetGroupHeader = titleFacetGroup === null || titleFacetGroup === void 0 ? void 0 : titleFacetGroup.querySelector('h1');
84
- expect((_b = facetGroupHeader === null || facetGroupHeader === void 0 ? void 0 : facetGroupHeader.textContent) === null || _b === void 0 ? void 0 : _b.trim()).to.equal('Subject');
85
- const titleFacetRow = (_d = (_c = titleFacetGroup === null || titleFacetGroup === void 0 ? void 0 : titleFacetGroup.querySelector('facets-template')) === null || _c === void 0 ? void 0 : _c.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.facet-row');
86
- expect((_e = titleFacetRow === null || titleFacetRow === void 0 ? void 0 : titleFacetRow.textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.satisfy((text) => /^foo\s*5$/.test(text));
87
- });
88
- it('renders multiple aggregation types', async () => {
89
- var _a;
90
- const el = await fixture(html `<collection-facets></collection-facets>`);
91
- const aggs = {
92
- subject: new Aggregation({
93
- buckets: [
94
- {
95
- key: 'foo',
96
- doc_count: 5,
97
- },
98
- ],
99
- }),
100
- mediatype: new Aggregation({
101
- buckets: [
102
- {
103
- key: 'bar',
104
- doc_count: 10,
105
- },
106
- ],
107
- }),
108
- };
109
- el.aggregations = aggs;
110
- await el.updateComplete;
111
- const facetGroups = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.facet-group');
112
- expect(facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups.length).to.equal(2);
113
- });
114
- it('renders collection facets as links', async () => {
115
- var _a, _b, _c, _d;
116
- const el = await fixture(html `<collection-facets></collection-facets>`);
117
- const aggs = {
118
- collection: new Aggregation({
119
- buckets: [
120
- {
121
- key: 'foo',
122
- doc_count: 5,
123
- },
124
- ],
125
- }),
126
- };
127
- el.aggregations = aggs;
128
- await el.updateComplete;
129
- const collectionName = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('async-collection-name');
130
- expect(collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement).to.be.instanceOf(HTMLAnchorElement);
131
- expect((_d = collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement) === null || _d === void 0 ? void 0 : _d.getAttribute('href')).to.equal('/details/foo');
132
- });
133
- it('renders non-collection facets without links', async () => {
134
- var _a, _b, _c;
135
- const el = await fixture(html `<collection-facets></collection-facets>`);
136
- const aggs = {
137
- subject: new Aggregation({
138
- buckets: [
139
- {
140
- key: 'foo',
141
- doc_count: 5,
142
- },
143
- ],
144
- }),
145
- };
146
- el.aggregations = aggs;
147
- await el.updateComplete;
148
- const collectionName = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('async-collection-name');
149
- expect(collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement).to.not.be.instanceOf(HTMLAnchorElement);
150
- });
151
- it('does not render suppressed collection facets', async () => {
152
- var _a, _b, _c;
153
- const el = await fixture(html `<collection-facets></collection-facets>`);
154
- const aggs = {
155
- collection: new Aggregation({
156
- buckets: [
157
- {
158
- key: 'deemphasize',
159
- doc_count: 5,
160
- },
161
- {
162
- key: 'community',
163
- doc_count: 5,
164
- },
165
- {
166
- key: 'foo',
167
- doc_count: 5,
168
- },
169
- ],
170
- }),
171
- };
172
- el.aggregations = aggs;
173
- await el.updateComplete;
174
- const collectionFacets = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelectorAll('.facet-row');
175
- expect(collectionFacets === null || collectionFacets === void 0 ? void 0 : collectionFacets.length).to.equal(1);
176
- // The first (and only) collection link should be for 'foo'
177
- const collectionLink = collectionFacets === null || collectionFacets === void 0 ? void 0 : collectionFacets.item(0).querySelector(`a[href='/details/foo']`);
178
- expect(collectionLink).to.exist;
179
- });
180
- it('renders lending facets with human-readable names', async () => {
181
- var _a, _b, _c, _d, _e;
182
- const el = await fixture(html `<collection-facets></collection-facets>`);
183
- const aggs = {
184
- lending: new Aggregation({
185
- buckets: [
186
- {
187
- key: 'is_lendable',
188
- doc_count: 3,
189
- },
190
- {
191
- key: 'available_to_borrow',
192
- doc_count: 2,
193
- },
194
- {
195
- key: 'is_readable',
196
- doc_count: 1,
197
- },
198
- ],
199
- }),
200
- };
201
- el.aggregations = aggs;
202
- await el.updateComplete;
203
- const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
204
- const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
205
- expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
206
- expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
207
- expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
208
- expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
209
- });
210
- it('renders selected/negative lending facets with human-readable names', async () => {
211
- var _a, _b, _c, _d, _e;
212
- const el = await fixture(html `<collection-facets></collection-facets>`);
213
- const selectedFacets = {
214
- subject: {},
215
- lending: {
216
- is_lendable: {
217
- key: 'is_lendable',
218
- count: 5,
219
- state: 'selected',
220
- },
221
- available_to_borrow: {
222
- key: 'available_to_borrow',
223
- count: 4,
224
- state: 'selected',
225
- },
226
- is_readable: {
227
- key: 'is_readable',
228
- count: 3,
229
- state: 'hidden',
230
- },
231
- },
232
- mediatype: {},
233
- language: {},
234
- creator: {},
235
- collection: {},
236
- year: {},
237
- };
238
- el.selectedFacets = selectedFacets;
239
- await el.updateComplete;
240
- const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
241
- const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
242
- expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
243
- expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
244
- expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
245
- expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
246
- });
247
- it('only renders lending facets for is_lendable, available_to_borrow, and is_readable', async () => {
248
- var _a, _b, _c, _d, _e;
249
- const el = await fixture(html `<collection-facets></collection-facets>`);
250
- const aggs = {
251
- lending: new Aggregation({
252
- buckets: [
253
- {
254
- key: 'is_lendable',
255
- doc_count: 5,
256
- },
257
- {
258
- key: 'is_borrowable',
259
- doc_count: 4,
260
- },
261
- {
262
- key: 'available_to_borrow',
263
- doc_count: 5,
264
- },
265
- {
266
- key: 'is_browsable',
267
- doc_count: 4,
268
- },
269
- {
270
- key: 'available_to_browse',
271
- doc_count: 5,
272
- },
273
- {
274
- key: 'is_readable',
275
- doc_count: 4,
276
- },
277
- {
278
- key: 'available_to_waitlist',
279
- doc_count: 5,
280
- },
281
- ],
282
- }),
283
- };
284
- el.aggregations = aggs;
285
- await el.updateComplete;
286
- const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
287
- const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
288
- expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
289
- expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
290
- expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
291
- expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
292
- });
293
- it('does not render a More... link for lending facets', async () => {
294
- var _a;
295
- const el = await fixture(html `<collection-facets></collection-facets>`);
296
- const aggs = {
297
- lending: new Aggregation({
298
- buckets: [
299
- {
300
- key: 'is_lendable',
301
- doc_count: 5,
302
- },
303
- {
304
- key: 'is_borrowable',
305
- doc_count: 4,
306
- },
307
- {
308
- key: 'available_to_borrow',
309
- doc_count: 5,
310
- },
311
- {
312
- key: 'is_browsable',
313
- doc_count: 4,
314
- },
315
- {
316
- key: 'available_to_browse',
317
- doc_count: 5,
318
- },
319
- {
320
- key: 'is_readable',
321
- doc_count: 4,
322
- },
323
- {
324
- key: 'available_to_waitlist',
325
- doc_count: 5,
326
- },
327
- ],
328
- }),
329
- };
330
- el.aggregations = aggs;
331
- await el.updateComplete;
332
- const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
333
- expect(moreLink).not.to.exist;
334
- });
335
- describe('More Facets', () => {
336
- it('Does not render < allowedFacetCount', async () => {
337
- var _a;
338
- const el = await fixture(html `<collection-facets></collection-facets>`);
339
- const aggs = {
340
- subject: new Aggregation({
341
- buckets: [
342
- {
343
- key: 'foo',
344
- doc_count: 5,
345
- },
346
- ],
347
- }),
348
- };
349
- el.aggregations = aggs;
350
- await el.updateComplete;
351
- const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
352
- expect(moreLink).to.be.null;
353
- });
354
- it('Render More Facets', async () => {
355
- var _a, _b;
1
+ /* eslint-disable import/no-duplicates */
2
+ import { expect, fixture } from '@open-wc/testing';
3
+ import sinon from 'sinon';
4
+ import { html } from 'lit';
5
+ import { Aggregation } from '@internetarchive/search-service';
6
+ import { ModalManager, } from '@internetarchive/modal-manager';
7
+ import '@internetarchive/modal-manager';
8
+ import '../src/collection-facets';
9
+ import { MockAnalyticsHandler } from './mocks/mock-analytics-handler';
10
+ describe('Collection Facets', () => {
11
+ it('has loader', async () => {
12
+ var _a, _b, _c, _d;
13
+ const el = await fixture(html `<collection-facets ?facetsLoading=${true}></collection-facets>`);
14
+ expect((_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#container')) === null || _b === void 0 ? void 0 : _b.classList.contains('loading')).to.be.true;
15
+ el.facetsLoading = false;
16
+ await el.updateComplete;
17
+ expect((_d = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#container')) === null || _d === void 0 ? void 0 : _d.classList.contains('loading')).to.be.false;
18
+ });
19
+ it('renders a date picker loading placeholder when date picker enabled', async () => {
20
+ var _a;
21
+ const el = await fixture(html `<collection-facets></collection-facets>`);
22
+ el.fullYearAggregationLoading = true;
23
+ el.showHistogramDatePicker = true;
24
+ await el.updateComplete;
25
+ const histogramLoader = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.histogram-loading-indicator');
26
+ expect(histogramLoader).to.exist;
27
+ });
28
+ it('does not render a date picker loading placeholder when date picker disabled', async () => {
29
+ var _a;
30
+ const el = await fixture(html `<collection-facets></collection-facets>`);
31
+ el.fullYearAggregationLoading = true;
32
+ el.showHistogramDatePicker = false;
33
+ await el.updateComplete;
34
+ const histogramLoader = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.histogram-loading-indicator');
35
+ expect(histogramLoader).to.be.null;
36
+ });
37
+ it('renders the date picker when enabled with data present', async () => {
38
+ var _a;
39
+ const el = await fixture(html `<collection-facets></collection-facets>`);
40
+ el.fullYearAggregationLoading = false;
41
+ el.showHistogramDatePicker = true;
42
+ el.fullYearsHistogramAggregation = new Aggregation({
43
+ buckets: [1, 2, 3],
44
+ first_bucket_key: 0,
45
+ last_bucket_key: 2,
46
+ });
47
+ await el.updateComplete;
48
+ const histogram = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('histogram-date-range');
49
+ expect(histogram).to.exist;
50
+ });
51
+ it('does not render the date picker when disabled', async () => {
52
+ var _a;
53
+ const el = await fixture(html `<collection-facets></collection-facets>`);
54
+ el.fullYearAggregationLoading = false;
55
+ el.showHistogramDatePicker = false;
56
+ el.fullYearsHistogramAggregation = new Aggregation({
57
+ buckets: [1, 2, 3],
58
+ first_bucket_key: 0,
59
+ last_bucket_key: 2,
60
+ });
61
+ await el.updateComplete;
62
+ const histogram = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('histogram-date-range');
63
+ expect(histogram).to.be.null;
64
+ });
65
+ it('renders aggregations as facets', async () => {
66
+ var _a, _b, _c, _d, _e;
67
+ const el = await fixture(html `<collection-facets></collection-facets>`);
68
+ const aggs = {
69
+ subject: new Aggregation({
70
+ buckets: [
71
+ {
72
+ key: 'foo',
73
+ doc_count: 5,
74
+ },
75
+ ],
76
+ }),
77
+ };
78
+ el.aggregations = aggs;
79
+ await el.updateComplete;
80
+ const facetGroups = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.facet-group');
81
+ expect(facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups.length).to.equal(1);
82
+ const titleFacetGroup = facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups[0];
83
+ const facetGroupHeader = titleFacetGroup === null || titleFacetGroup === void 0 ? void 0 : titleFacetGroup.querySelector('h1');
84
+ expect((_b = facetGroupHeader === null || facetGroupHeader === void 0 ? void 0 : facetGroupHeader.textContent) === null || _b === void 0 ? void 0 : _b.trim()).to.equal('Subject');
85
+ const titleFacetRow = (_d = (_c = titleFacetGroup === null || titleFacetGroup === void 0 ? void 0 : titleFacetGroup.querySelector('facets-template')) === null || _c === void 0 ? void 0 : _c.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.facet-row');
86
+ expect((_e = titleFacetRow === null || titleFacetRow === void 0 ? void 0 : titleFacetRow.textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.satisfy((text) => /^foo\s*5$/.test(text));
87
+ });
88
+ it('renders multiple aggregation types', async () => {
89
+ var _a;
90
+ const el = await fixture(html `<collection-facets></collection-facets>`);
91
+ const aggs = {
92
+ subject: new Aggregation({
93
+ buckets: [
94
+ {
95
+ key: 'foo',
96
+ doc_count: 5,
97
+ },
98
+ ],
99
+ }),
100
+ mediatype: new Aggregation({
101
+ buckets: [
102
+ {
103
+ key: 'bar',
104
+ doc_count: 10,
105
+ },
106
+ ],
107
+ }),
108
+ };
109
+ el.aggregations = aggs;
110
+ await el.updateComplete;
111
+ const facetGroups = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.facet-group');
112
+ expect(facetGroups === null || facetGroups === void 0 ? void 0 : facetGroups.length).to.equal(2);
113
+ });
114
+ it('renders collection facets as links', async () => {
115
+ var _a, _b, _c, _d;
116
+ const el = await fixture(html `<collection-facets></collection-facets>`);
117
+ const aggs = {
118
+ collection: new Aggregation({
119
+ buckets: [
120
+ {
121
+ key: 'foo',
122
+ doc_count: 5,
123
+ },
124
+ ],
125
+ }),
126
+ };
127
+ el.aggregations = aggs;
128
+ await el.updateComplete;
129
+ const collectionName = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('async-collection-name');
130
+ expect(collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement).to.be.instanceOf(HTMLAnchorElement);
131
+ expect((_d = collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement) === null || _d === void 0 ? void 0 : _d.getAttribute('href')).to.equal('/details/foo');
132
+ });
133
+ it('renders non-collection facets without links', async () => {
134
+ var _a, _b, _c;
135
+ const el = await fixture(html `<collection-facets></collection-facets>`);
136
+ const aggs = {
137
+ subject: new Aggregation({
138
+ buckets: [
139
+ {
140
+ key: 'foo',
141
+ doc_count: 5,
142
+ },
143
+ ],
144
+ }),
145
+ };
146
+ el.aggregations = aggs;
147
+ await el.updateComplete;
148
+ const collectionName = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('async-collection-name');
149
+ expect(collectionName === null || collectionName === void 0 ? void 0 : collectionName.parentElement).to.not.be.instanceOf(HTMLAnchorElement);
150
+ });
151
+ it('does not render suppressed collection facets', async () => {
152
+ var _a, _b, _c;
153
+ const el = await fixture(html `<collection-facets></collection-facets>`);
154
+ const aggs = {
155
+ collection: new Aggregation({
156
+ buckets: [
157
+ {
158
+ key: 'deemphasize',
159
+ doc_count: 5,
160
+ },
161
+ {
162
+ key: 'community',
163
+ doc_count: 5,
164
+ },
165
+ {
166
+ key: 'foo',
167
+ doc_count: 5,
168
+ },
169
+ ],
170
+ }),
171
+ };
172
+ el.aggregations = aggs;
173
+ await el.updateComplete;
174
+ const collectionFacets = (_c = (_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelectorAll('.facet-row');
175
+ expect(collectionFacets === null || collectionFacets === void 0 ? void 0 : collectionFacets.length).to.equal(1);
176
+ // The first (and only) collection link should be for 'foo'
177
+ const collectionLink = collectionFacets === null || collectionFacets === void 0 ? void 0 : collectionFacets.item(0).querySelector(`a[href='/details/foo']`);
178
+ expect(collectionLink).to.exist;
179
+ });
180
+ it('renders lending facets with human-readable names', async () => {
181
+ var _a, _b, _c, _d, _e;
182
+ const el = await fixture(html `<collection-facets></collection-facets>`);
183
+ const aggs = {
184
+ lending: new Aggregation({
185
+ buckets: [
186
+ {
187
+ key: 'is_lendable',
188
+ doc_count: 3,
189
+ },
190
+ {
191
+ key: 'available_to_borrow',
192
+ doc_count: 2,
193
+ },
194
+ {
195
+ key: 'is_readable',
196
+ doc_count: 1,
197
+ },
198
+ ],
199
+ }),
200
+ };
201
+ el.aggregations = aggs;
202
+ await el.updateComplete;
203
+ const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
204
+ const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
205
+ expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
206
+ expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
207
+ expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
208
+ expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
209
+ });
210
+ it('renders selected/negative lending facets with human-readable names', async () => {
211
+ var _a, _b, _c, _d, _e;
212
+ const el = await fixture(html `<collection-facets></collection-facets>`);
213
+ const selectedFacets = {
214
+ subject: {},
215
+ lending: {
216
+ is_lendable: {
217
+ key: 'is_lendable',
218
+ count: 5,
219
+ state: 'selected',
220
+ },
221
+ available_to_borrow: {
222
+ key: 'available_to_borrow',
223
+ count: 4,
224
+ state: 'selected',
225
+ },
226
+ is_readable: {
227
+ key: 'is_readable',
228
+ count: 3,
229
+ state: 'hidden',
230
+ },
231
+ },
232
+ mediatype: {},
233
+ language: {},
234
+ creator: {},
235
+ collection: {},
236
+ year: {},
237
+ };
238
+ el.selectedFacets = selectedFacets;
239
+ await el.updateComplete;
240
+ const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
241
+ const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
242
+ expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
243
+ expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
244
+ expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
245
+ expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
246
+ });
247
+ it('only renders lending facets for is_lendable, available_to_borrow, and is_readable', async () => {
248
+ var _a, _b, _c, _d, _e;
249
+ const el = await fixture(html `<collection-facets></collection-facets>`);
250
+ const aggs = {
251
+ lending: new Aggregation({
252
+ buckets: [
253
+ {
254
+ key: 'is_lendable',
255
+ doc_count: 5,
256
+ },
257
+ {
258
+ key: 'is_borrowable',
259
+ doc_count: 4,
260
+ },
261
+ {
262
+ key: 'available_to_borrow',
263
+ doc_count: 5,
264
+ },
265
+ {
266
+ key: 'is_browsable',
267
+ doc_count: 4,
268
+ },
269
+ {
270
+ key: 'available_to_browse',
271
+ doc_count: 5,
272
+ },
273
+ {
274
+ key: 'is_readable',
275
+ doc_count: 4,
276
+ },
277
+ {
278
+ key: 'available_to_waitlist',
279
+ doc_count: 5,
280
+ },
281
+ ],
282
+ }),
283
+ };
284
+ el.aggregations = aggs;
285
+ await el.updateComplete;
286
+ const facetsTemplate = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('facets-template');
287
+ const lendingTitles = (_b = facetsTemplate === null || facetsTemplate === void 0 ? void 0 : facetsTemplate.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.facet-title');
288
+ expect(lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.length).to.equal(3);
289
+ expect((_c = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(0).textContent) === null || _c === void 0 ? void 0 : _c.trim()).to.equal('Lending Library');
290
+ expect((_d = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(1).textContent) === null || _d === void 0 ? void 0 : _d.trim()).to.equal('Borrow 14 Days');
291
+ expect((_e = lendingTitles === null || lendingTitles === void 0 ? void 0 : lendingTitles.item(2).textContent) === null || _e === void 0 ? void 0 : _e.trim()).to.equal('Always Available');
292
+ });
293
+ it('does not render a More... link for lending facets', async () => {
294
+ var _a;
295
+ const el = await fixture(html `<collection-facets></collection-facets>`);
296
+ const aggs = {
297
+ lending: new Aggregation({
298
+ buckets: [
299
+ {
300
+ key: 'is_lendable',
301
+ doc_count: 5,
302
+ },
303
+ {
304
+ key: 'is_borrowable',
305
+ doc_count: 4,
306
+ },
307
+ {
308
+ key: 'available_to_borrow',
309
+ doc_count: 5,
310
+ },
311
+ {
312
+ key: 'is_browsable',
313
+ doc_count: 4,
314
+ },
315
+ {
316
+ key: 'available_to_browse',
317
+ doc_count: 5,
318
+ },
319
+ {
320
+ key: 'is_readable',
321
+ doc_count: 4,
322
+ },
323
+ {
324
+ key: 'available_to_waitlist',
325
+ doc_count: 5,
326
+ },
327
+ ],
328
+ }),
329
+ };
330
+ el.aggregations = aggs;
331
+ await el.updateComplete;
332
+ const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
333
+ expect(moreLink).not.to.exist;
334
+ });
335
+ describe('More Facets', () => {
336
+ it('Does not render < allowedFacetCount', async () => {
337
+ var _a;
338
+ const el = await fixture(html `<collection-facets></collection-facets>`);
339
+ const aggs = {
340
+ subject: new Aggregation({
341
+ buckets: [
342
+ {
343
+ key: 'foo',
344
+ doc_count: 5,
345
+ },
346
+ ],
347
+ }),
348
+ };
349
+ el.aggregations = aggs;
350
+ await el.updateComplete;
351
+ const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
352
+ expect(moreLink).to.be.null;
353
+ });
354
+ it('Render More Facets', async () => {
355
+ var _a, _b;
356
356
  const el = await fixture(html `<collection-facets
357
357
  .modalManager=${new ModalManager()}
358
- ></collection-facets>`);
359
- const aggs = {
360
- subject: new Aggregation({
361
- buckets: [
362
- {
363
- key: 'foo',
364
- doc_count: 5,
365
- },
366
- {
367
- key: 'fi',
368
- doc_count: 5,
369
- },
370
- {
371
- key: 'fum',
372
- doc_count: 5,
373
- },
374
- {
375
- key: 'flee',
376
- doc_count: 5,
377
- },
378
- {
379
- key: 'wheee',
380
- doc_count: 5,
381
- },
382
- {
383
- key: 'whooo',
384
- doc_count: 5,
385
- },
386
- {
387
- key: 'boop',
388
- doc_count: 5,
389
- },
390
- ],
391
- }),
392
- };
393
- el.aggregations = aggs;
394
- await el.updateComplete;
395
- let eventCaught = false;
396
- let eventFacet = '';
397
- el.addEventListener('showMoreFacets', e => {
398
- eventFacet = e.detail;
399
- eventCaught = true;
400
- });
401
- const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
402
- expect(moreLink).to.exist; // has link
403
- const showModalSpy = sinon.spy(el.modalManager, 'showModal');
404
- // let's pop up modal
405
- moreLink === null || moreLink === void 0 ? void 0 : moreLink.click();
406
- await el.updateComplete;
407
- expect(showModalSpy.callCount).to.equal(1);
408
- expect((_b = el.modalManager) === null || _b === void 0 ? void 0 : _b.classList.contains('more-search-facets')).to.be
409
- .true;
410
- expect(eventCaught).to.be.true;
411
- expect(eventFacet).to.equal('subject');
412
- });
413
- });
414
- it('fire analytics on more link', async () => {
415
- var _a;
416
- const mockAnalyticsHandler = new MockAnalyticsHandler();
358
+ ></collection-facets>`);
359
+ const aggs = {
360
+ subject: new Aggregation({
361
+ buckets: [
362
+ {
363
+ key: 'foo',
364
+ doc_count: 5,
365
+ },
366
+ {
367
+ key: 'fi',
368
+ doc_count: 5,
369
+ },
370
+ {
371
+ key: 'fum',
372
+ doc_count: 5,
373
+ },
374
+ {
375
+ key: 'flee',
376
+ doc_count: 5,
377
+ },
378
+ {
379
+ key: 'wheee',
380
+ doc_count: 5,
381
+ },
382
+ {
383
+ key: 'whooo',
384
+ doc_count: 5,
385
+ },
386
+ {
387
+ key: 'boop',
388
+ doc_count: 5,
389
+ },
390
+ ],
391
+ }),
392
+ };
393
+ el.aggregations = aggs;
394
+ await el.updateComplete;
395
+ let eventCaught = false;
396
+ let eventFacet = '';
397
+ el.addEventListener('showMoreFacets', e => {
398
+ eventFacet = e.detail;
399
+ eventCaught = true;
400
+ });
401
+ const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
402
+ expect(moreLink).to.exist; // has link
403
+ const showModalSpy = sinon.spy(el.modalManager, 'showModal');
404
+ // let's pop up modal
405
+ moreLink === null || moreLink === void 0 ? void 0 : moreLink.click();
406
+ await el.updateComplete;
407
+ expect(showModalSpy.callCount).to.equal(1);
408
+ expect((_b = el.modalManager) === null || _b === void 0 ? void 0 : _b.classList.contains('more-search-facets')).to.be
409
+ .true;
410
+ expect(eventCaught).to.be.true;
411
+ expect(eventFacet).to.equal('subject');
412
+ });
413
+ });
414
+ it('fire analytics on more link', async () => {
415
+ var _a;
416
+ const mockAnalyticsHandler = new MockAnalyticsHandler();
417
417
  const el = await fixture(html `<collection-facets
418
418
  .analyticsHandler=${mockAnalyticsHandler}
419
- ></collection-facets>`);
420
- const aggs = {
421
- subject: new Aggregation({
422
- buckets: [
423
- {
424
- key: 'foo',
425
- doc_count: 5,
426
- },
427
- {
428
- key: 'fi',
429
- doc_count: 5,
430
- },
431
- {
432
- key: 'fum',
433
- doc_count: 5,
434
- },
435
- {
436
- key: 'flee',
437
- doc_count: 5,
438
- },
439
- {
440
- key: 'wheee',
441
- doc_count: 5,
442
- },
443
- {
444
- key: 'whooo',
445
- doc_count: 5,
446
- },
447
- {
448
- key: 'boop',
449
- doc_count: 5,
450
- },
451
- ],
452
- }),
453
- };
454
- el.aggregations = aggs;
455
- await el.updateComplete;
456
- const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
457
- expect(moreLink).to.exist; // has link
458
- moreLink === null || moreLink === void 0 ? void 0 : moreLink.click();
459
- await el.updateComplete;
460
- expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
461
- expect(mockAnalyticsHandler.callAction).to.equal('showMoreFacetsModal');
462
- expect(mockAnalyticsHandler.callLabel).to.equal('subject');
463
- });
464
- });
419
+ ></collection-facets>`);
420
+ const aggs = {
421
+ subject: new Aggregation({
422
+ buckets: [
423
+ {
424
+ key: 'foo',
425
+ doc_count: 5,
426
+ },
427
+ {
428
+ key: 'fi',
429
+ doc_count: 5,
430
+ },
431
+ {
432
+ key: 'fum',
433
+ doc_count: 5,
434
+ },
435
+ {
436
+ key: 'flee',
437
+ doc_count: 5,
438
+ },
439
+ {
440
+ key: 'wheee',
441
+ doc_count: 5,
442
+ },
443
+ {
444
+ key: 'whooo',
445
+ doc_count: 5,
446
+ },
447
+ {
448
+ key: 'boop',
449
+ doc_count: 5,
450
+ },
451
+ ],
452
+ }),
453
+ };
454
+ el.aggregations = aggs;
455
+ await el.updateComplete;
456
+ const moreLink = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.more-link');
457
+ expect(moreLink).to.exist; // has link
458
+ moreLink === null || moreLink === void 0 ? void 0 : moreLink.click();
459
+ await el.updateComplete;
460
+ expect(mockAnalyticsHandler.callCategory).to.equal('collection-browser');
461
+ expect(mockAnalyticsHandler.callAction).to.equal('showMoreFacetsModal');
462
+ expect(mockAnalyticsHandler.callLabel).to.equal('subject');
463
+ });
464
+ });
465
465
  //# sourceMappingURL=collection-facets.test.js.map