@internetarchive/collection-browser 3.4.1-alpha-webdev7761.2 → 3.4.1-alpha-webdev7761.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/app-root.js +19 -28
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +14 -10
- package/dist/src/collection-browser.js +870 -886
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.js +3 -4
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/models.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.js +145 -156
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-pagination.js +6 -10
- package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js +16 -21
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +7 -10
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js +3 -2
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +9 -11
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +7 -7
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js.map +1 -1
- package/dist/src/collection-facets/toggle-switch.js +4 -6
- package/dist/src/collection-facets/toggle-switch.js.map +1 -1
- package/dist/src/collection-facets.js +34 -50
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/combo-box/caret-closed.js +5 -11
- package/dist/src/combo-box/caret-closed.js.map +1 -1
- package/dist/src/combo-box/caret-open.js +5 -11
- package/dist/src/combo-box/caret-open.js.map +1 -1
- package/dist/src/combo-box/clear.d.ts +2 -0
- package/dist/src/combo-box/clear.js +11 -0
- package/dist/src/combo-box/clear.js.map +1 -0
- package/dist/src/combo-box/ia-combo-box.d.ts +40 -9
- package/dist/src/combo-box/ia-combo-box.js +363 -272
- package/dist/src/combo-box/ia-combo-box.js.map +1 -1
- package/dist/src/combo-box/models.d.ts +14 -0
- package/dist/src/combo-box/models.js +32 -1
- package/dist/src/combo-box/models.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js +35 -47
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/empty-placeholder.js +19 -18
- package/dist/src/empty-placeholder.js.map +1 -1
- package/dist/src/expanded-date-picker.js +6 -10
- package/dist/src/expanded-date-picker.js.map +1 -1
- package/dist/src/language-code-handler/language-code-handler.js +2 -2
- package/dist/src/language-code-handler/language-code-handler.js.map +1 -1
- package/dist/src/manage/manage-bar.js +86 -92
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/manage/remove-items-modal-content.js +2 -2
- package/dist/src/manage/remove-items-modal-content.js.map +1 -1
- package/dist/src/models.js +36 -40
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.js +9 -10
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/alpha-bar.js +9 -14
- package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +14 -24
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/base-tile-component.js +1 -2
- package/dist/src/tiles/base-tile-component.js.map +1 -1
- package/dist/src/tiles/grid/account-tile.js +36 -38
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +79 -82
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +154 -164
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/search-tile.js +42 -43
- package/dist/src/tiles/grid/search-tile.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +119 -119
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.js +2 -3
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.js +42 -49
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
- package/dist/src/tiles/hover/tile-hover-pane.js +113 -114
- package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
- package/dist/src/tiles/image-block.js +5 -8
- package/dist/src/tiles/image-block.js.map +1 -1
- package/dist/src/tiles/item-image.js +12 -19
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +114 -122
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +326 -347
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/overlay/icon-overlay.js +1 -2
- package/dist/src/tiles/overlay/icon-overlay.js.map +1 -1
- package/dist/src/tiles/overlay/text-overlay.js +2 -4
- package/dist/src/tiles/overlay/text-overlay.js.map +1 -1
- package/dist/src/tiles/text-snippet-block.js +2 -4
- package/dist/src/tiles/text-snippet-block.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +233 -241
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.js +5 -9
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
- package/dist/src/tiles/tile-mediatype-icon.js +12 -19
- package/dist/src/tiles/tile-mediatype-icon.js.map +1 -1
- package/dist/src/utils/collapse-repeated-quotes.js +1 -1
- package/dist/src/utils/collapse-repeated-quotes.js.map +1 -1
- package/dist/src/utils/facet-utils.js +3 -5
- package/dist/src/utils/facet-utils.js.map +1 -1
- package/dist/src/utils/format-count.js +10 -10
- package/dist/src/utils/format-count.js.map +1 -1
- package/dist/src/utils/format-date.js.map +1 -1
- package/dist/src/utils/resolve-mediatype.js +2 -3
- package/dist/src/utils/resolve-mediatype.js.map +1 -1
- package/dist/test/collection-browser.test.js +131 -185
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.js +60 -75
- package/dist/test/collection-facets/facet-row.test.js.map +1 -1
- package/dist/test/collection-facets/facets-template.test.js +17 -23
- package/dist/test/collection-facets/facets-template.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +22 -32
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +16 -22
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
- package/dist/test/collection-facets/toggle-switch.test.js +22 -19
- package/dist/test/collection-facets/toggle-switch.test.js.map +1 -1
- package/dist/test/collection-facets.test.js +80 -97
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/empty-placeholder.test.js +11 -17
- package/dist/test/empty-placeholder.test.js.map +1 -1
- package/dist/test/expanded-date-picker.test.js +8 -14
- package/dist/test/expanded-date-picker.test.js.map +1 -1
- package/dist/test/icon-overlay.test.js +7 -6
- package/dist/test/icon-overlay.test.js.map +1 -1
- package/dist/test/image-block.test.js +16 -26
- package/dist/test/image-block.test.js.map +1 -1
- package/dist/test/item-image.test.js +23 -32
- package/dist/test/item-image.test.js.map +1 -1
- package/dist/test/manage/manage-bar.test.js +21 -33
- package/dist/test/manage/manage-bar.test.js.map +1 -1
- package/dist/test/manage/remove-items-modal-content.test.js +10 -15
- package/dist/test/manage/remove-items-modal-content.test.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +2 -3
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +13 -21
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/dist/test/review-block.test.js +16 -18
- package/dist/test/review-block.test.js.map +1 -1
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +2 -3
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +1 -1
- package/dist/test/sort-filter-bar/alpha-bar.test.js +18 -24
- package/dist/test/sort-filter-bar/alpha-bar.test.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +178 -180
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/dist/test/text-overlay.test.js +16 -15
- package/dist/test/text-overlay.test.js.map +1 -1
- package/dist/test/text-snippet-block.test.js +14 -19
- package/dist/test/text-snippet-block.test.js.map +1 -1
- package/dist/test/tile-stats.test.js +73 -34
- package/dist/test/tile-stats.test.js.map +1 -1
- package/dist/test/tiles/grid/account-tile.test.js +25 -25
- package/dist/test/tiles/grid/account-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/collection-tile.test.js +13 -19
- package/dist/test/tiles/grid/collection-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +141 -168
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/search-tile.test.js +9 -13
- package/dist/test/tiles/grid/search-tile.test.js.map +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +50 -62
- package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
- package/dist/test/tiles/hover/tile-hover-pane.test.js +12 -16
- package/dist/test/tiles/hover/tile-hover-pane.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js +104 -118
- package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +202 -231
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +97 -110
- package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
- package/dist/test/tiles/tile-mediatype-icon.test.js +12 -24
- package/dist/test/tiles/tile-mediatype-icon.test.js.map +1 -1
- package/dist/test/utils/format-date.test.js.map +1 -1
- package/index.html +1 -1
- package/package.json +5 -3
- package/src/collection-browser.ts +3060 -3030
- package/src/collection-facets/models.ts +10 -10
- package/src/collection-facets/more-facets-content.ts +639 -639
- package/src/collection-facets.ts +1 -1
- package/src/combo-box/caret-closed.ts +5 -11
- package/src/combo-box/caret-open.ts +5 -11
- package/src/combo-box/clear.ts +11 -0
- package/src/combo-box/ia-combo-box.ts +1288 -1180
- package/src/combo-box/models.ts +31 -1
- package/src/manage/manage-bar.ts +247 -247
- package/src/restoration-state-handler.ts +5 -1
- package/src/tiles/base-tile-component.ts +65 -65
- package/src/tiles/grid/account-tile.ts +113 -113
- package/src/tiles/grid/collection-tile.ts +163 -163
- package/src/tiles/grid/item-tile.ts +340 -340
- package/src/tiles/grid/search-tile.ts +90 -90
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -130
- package/src/tiles/hover/hover-pane-controller.ts +613 -613
- package/src/tiles/hover/tile-hover-pane.ts +184 -184
- package/src/tiles/list/tile-list-compact.ts +239 -239
- package/src/tiles/list/tile-list.ts +700 -700
- package/src/tiles/tile-dispatcher.ts +517 -517
- package/src/utils/format-date.ts +62 -62
- package/test/collection-facets/facet-row.test.ts +375 -375
- package/test/collection-facets.test.ts +928 -928
- package/test/tiles/grid/item-tile.test.ts +520 -520
- package/test/tiles/hover/hover-pane-controller.test.ts +418 -418
- package/test/tiles/list/tile-list-compact.test.ts +282 -282
- package/test/tiles/list/tile-list.test.ts +552 -552
- package/test/tiles/tile-dispatcher.test.ts +283 -283
- package/test/utils/format-date.test.ts +89 -89
- package/tsconfig.json +8 -3
- package/vite.config.ts +29 -22
|
@@ -4,13 +4,12 @@ import { html } from 'lit';
|
|
|
4
4
|
import '../../../src/tiles/grid/item-tile';
|
|
5
5
|
describe('Item Tile', () => {
|
|
6
6
|
it('should render initial component', async () => {
|
|
7
|
-
var _a, _b, _c, _d, _e;
|
|
8
7
|
const el = await fixture(html `<item-tile></item-tile>`);
|
|
9
|
-
const container =
|
|
10
|
-
const tileDetails =
|
|
11
|
-
const itemInfo =
|
|
12
|
-
const itemTitle =
|
|
13
|
-
const imageBlock =
|
|
8
|
+
const container = el.shadowRoot?.querySelector('.container');
|
|
9
|
+
const tileDetails = el.shadowRoot?.querySelector('.tile-details');
|
|
10
|
+
const itemInfo = el.shadowRoot?.querySelector('.item-info');
|
|
11
|
+
const itemTitle = el.shadowRoot?.querySelector('#title');
|
|
12
|
+
const imageBlock = el.shadowRoot?.querySelector('image-block');
|
|
14
13
|
expect(container).to.exist;
|
|
15
14
|
expect(tileDetails).to.exist;
|
|
16
15
|
expect(itemInfo).to.exist;
|
|
@@ -18,14 +17,13 @@ describe('Item Tile', () => {
|
|
|
18
17
|
expect(itemTitle).to.exist;
|
|
19
18
|
});
|
|
20
19
|
it('should render with created-by element', async () => {
|
|
21
|
-
var _a, _b, _c, _d, _e;
|
|
22
20
|
const el = await fixture(html `<item-tile .model=${{ creator: 'someone' }}></item-tile>`);
|
|
23
|
-
const container =
|
|
24
|
-
const tileDetails =
|
|
25
|
-
const itemInfo =
|
|
26
|
-
const createdBy =
|
|
27
|
-
const truncatedCreatorText = createdBy
|
|
28
|
-
const dateSortedBy =
|
|
21
|
+
const container = el.shadowRoot?.querySelector('.container');
|
|
22
|
+
const tileDetails = el.shadowRoot?.querySelector('.tile-details');
|
|
23
|
+
const itemInfo = el.shadowRoot?.querySelector('.item-info');
|
|
24
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
25
|
+
const truncatedCreatorText = createdBy?.querySelector('.truncated');
|
|
26
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
29
27
|
expect(container).to.exist;
|
|
30
28
|
expect(tileDetails).to.exist;
|
|
31
29
|
expect(itemInfo).to.exist;
|
|
@@ -34,226 +32,212 @@ describe('Item Tile', () => {
|
|
|
34
32
|
expect(dateSortedBy).to.not.exist;
|
|
35
33
|
});
|
|
36
34
|
it('should not render with created-by but date element', async () => {
|
|
37
|
-
var _a, _b;
|
|
38
35
|
const el = await fixture(html `<item-tile .model=${{ datePublished: new Date() }}></item-tile>`);
|
|
39
36
|
el.sortParam = {
|
|
40
37
|
field: 'date',
|
|
41
38
|
direction: 'desc',
|
|
42
39
|
};
|
|
43
40
|
await el.updateComplete;
|
|
44
|
-
const createdBy =
|
|
45
|
-
const dateSortedBy =
|
|
41
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
42
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
46
43
|
expect(createdBy).to.not.exist;
|
|
47
44
|
expect(dateSortedBy).to.exist;
|
|
48
45
|
});
|
|
49
46
|
it('should not render with created-by but reviewdate element', async () => {
|
|
50
|
-
var _a, _b;
|
|
51
47
|
const el = await fixture(html `<item-tile .model=${{ dateReviewed: new Date() }}></item-tile>`);
|
|
52
48
|
el.sortParam = {
|
|
53
49
|
field: 'reviewdate',
|
|
54
50
|
direction: 'desc',
|
|
55
51
|
};
|
|
56
52
|
await el.updateComplete;
|
|
57
|
-
const createdBy =
|
|
58
|
-
const dateSortedBy =
|
|
53
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
54
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
59
55
|
expect(createdBy).to.not.exist;
|
|
60
56
|
expect(dateSortedBy).to.exist;
|
|
61
57
|
});
|
|
62
58
|
it('should not render with created-by but publicdate element', async () => {
|
|
63
|
-
var _a, _b;
|
|
64
59
|
const el = await fixture(html `<item-tile .model=${{ dateArchived: new Date() }}></item-tile>`);
|
|
65
60
|
el.sortParam = {
|
|
66
61
|
field: 'publicdate',
|
|
67
62
|
direction: 'desc',
|
|
68
63
|
};
|
|
69
64
|
await el.updateComplete;
|
|
70
|
-
const createdBy =
|
|
71
|
-
const dateSortedBy =
|
|
65
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
66
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
72
67
|
expect(createdBy).to.not.exist;
|
|
73
68
|
expect(dateSortedBy).to.exist;
|
|
74
69
|
});
|
|
75
70
|
it('should not render date-sorted-by element if date is not provided', async () => {
|
|
76
|
-
var _a, _b;
|
|
77
71
|
const el = await fixture(html `<item-tile .model=${{ dateArchived: undefined }}></item-tile>`);
|
|
78
72
|
el.sortParam = {
|
|
79
73
|
field: 'publicdate',
|
|
80
74
|
direction: 'desc',
|
|
81
75
|
};
|
|
82
76
|
await el.updateComplete;
|
|
83
|
-
const createdBy =
|
|
84
|
-
const dateSortedBy =
|
|
77
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
78
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
85
79
|
expect(createdBy).to.not.exist;
|
|
86
80
|
expect(dateSortedBy).to.not.exist;
|
|
87
81
|
});
|
|
88
82
|
it('should render without created-by when sorting by a date field', async () => {
|
|
89
|
-
var _a, _b, _c;
|
|
90
83
|
const el = await fixture(html `<item-tile .model=${{ dateAdded: new Date() }}></item-tile>`);
|
|
91
84
|
el.sortParam = {
|
|
92
85
|
field: 'addeddate',
|
|
93
86
|
direction: 'asc',
|
|
94
87
|
};
|
|
95
88
|
await el.updateComplete;
|
|
96
|
-
const itemInfo =
|
|
97
|
-
const createdBy =
|
|
98
|
-
const dateSortedBy =
|
|
89
|
+
const itemInfo = el.shadowRoot?.querySelector('.item-info');
|
|
90
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
91
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
99
92
|
expect(itemInfo).to.exist;
|
|
100
93
|
expect(createdBy).to.not.exist;
|
|
101
94
|
expect(dateSortedBy).to.exist;
|
|
102
95
|
});
|
|
103
96
|
it('should render with created-by when sort field is not a date', async () => {
|
|
104
|
-
var _a, _b, _c;
|
|
105
97
|
const el = await fixture(html `<item-tile .model=${{ creator: 'someone' }}></item-tile>`);
|
|
106
98
|
el.sortParam = {
|
|
107
99
|
field: 'week',
|
|
108
100
|
direction: 'asc',
|
|
109
101
|
};
|
|
110
102
|
await el.updateComplete;
|
|
111
|
-
const itemInfo =
|
|
112
|
-
const createdBy =
|
|
113
|
-
const dateSortedBy =
|
|
103
|
+
const itemInfo = el.shadowRoot?.querySelector('.item-info');
|
|
104
|
+
const createdBy = el.shadowRoot?.querySelector('.created-by');
|
|
105
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
114
106
|
expect(itemInfo).to.exist;
|
|
115
107
|
expect(dateSortedBy).to.not.exist; // it should not exist because this is not a date sort
|
|
116
108
|
expect(createdBy).to.exist;
|
|
117
109
|
});
|
|
118
110
|
it('should render published date when sorting by it', async () => {
|
|
119
|
-
var _a, _b;
|
|
120
111
|
const model = {
|
|
121
112
|
dateAdded: new Date(2010, 0, 2),
|
|
122
113
|
dateArchived: new Date(2011, 0, 2),
|
|
123
114
|
datePublished: new Date(2012, 0, 2),
|
|
124
115
|
dateReviewed: new Date(2013, 0, 2),
|
|
125
116
|
};
|
|
126
|
-
const el = await fixture(html `
|
|
127
|
-
<item-tile
|
|
128
|
-
.model=${model}
|
|
129
|
-
.sortParam=${{ field: 'date', direction: 'desc' }}
|
|
130
|
-
>
|
|
131
|
-
</item-tile>
|
|
117
|
+
const el = await fixture(html `
|
|
118
|
+
<item-tile
|
|
119
|
+
.model=${model}
|
|
120
|
+
.sortParam=${{ field: 'date', direction: 'desc' }}
|
|
121
|
+
>
|
|
122
|
+
</item-tile>
|
|
132
123
|
`);
|
|
133
|
-
const dateSortedBy =
|
|
124
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
134
125
|
expect(dateSortedBy).to.exist;
|
|
135
|
-
expect(
|
|
126
|
+
expect(dateSortedBy?.textContent?.trim()).to.contain('published Jan 02, 2012');
|
|
136
127
|
});
|
|
137
128
|
it('should render added date when sorting by it', async () => {
|
|
138
|
-
var _a, _b;
|
|
139
129
|
const model = {
|
|
140
130
|
dateAdded: new Date(2010, 0, 2),
|
|
141
131
|
dateArchived: new Date(2011, 0, 2),
|
|
142
132
|
datePublished: new Date(2012, 0, 2),
|
|
143
133
|
dateReviewed: new Date(2013, 0, 2),
|
|
144
134
|
};
|
|
145
|
-
const el = await fixture(html `
|
|
146
|
-
<item-tile
|
|
147
|
-
.model=${model}
|
|
148
|
-
.sortParam=${{ field: 'addeddate', direction: 'desc' }}
|
|
149
|
-
>
|
|
150
|
-
</item-tile>
|
|
135
|
+
const el = await fixture(html `
|
|
136
|
+
<item-tile
|
|
137
|
+
.model=${model}
|
|
138
|
+
.sortParam=${{ field: 'addeddate', direction: 'desc' }}
|
|
139
|
+
>
|
|
140
|
+
</item-tile>
|
|
151
141
|
`);
|
|
152
|
-
const dateSortedBy =
|
|
142
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
153
143
|
expect(dateSortedBy).to.exist;
|
|
154
|
-
expect(
|
|
144
|
+
expect(dateSortedBy?.textContent?.trim()).to.contain('added Jan 02, 2010');
|
|
155
145
|
});
|
|
156
146
|
it('should render archived date when sorting by it', async () => {
|
|
157
|
-
var _a, _b;
|
|
158
147
|
const model = {
|
|
159
148
|
dateAdded: new Date(2010, 0, 2),
|
|
160
149
|
dateArchived: new Date(2011, 0, 2),
|
|
161
150
|
datePublished: new Date(2012, 0, 2),
|
|
162
151
|
dateReviewed: new Date(2013, 0, 2),
|
|
163
152
|
};
|
|
164
|
-
const el = await fixture(html `
|
|
165
|
-
<item-tile
|
|
166
|
-
.model=${model}
|
|
167
|
-
.sortParam=${{ field: 'publicdate', direction: 'desc' }}
|
|
168
|
-
>
|
|
169
|
-
</item-tile>
|
|
153
|
+
const el = await fixture(html `
|
|
154
|
+
<item-tile
|
|
155
|
+
.model=${model}
|
|
156
|
+
.sortParam=${{ field: 'publicdate', direction: 'desc' }}
|
|
157
|
+
>
|
|
158
|
+
</item-tile>
|
|
170
159
|
`);
|
|
171
|
-
const dateSortedBy =
|
|
160
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
172
161
|
expect(dateSortedBy).to.exist;
|
|
173
|
-
expect(
|
|
162
|
+
expect(dateSortedBy?.textContent?.trim()).to.contain('archived Jan 02, 2011');
|
|
174
163
|
});
|
|
175
164
|
it('should render reviewed date when sorting by it', async () => {
|
|
176
|
-
var _a, _b;
|
|
177
165
|
const model = {
|
|
178
166
|
dateAdded: new Date(2010, 0, 2),
|
|
179
167
|
dateArchived: new Date(2011, 0, 2),
|
|
180
168
|
datePublished: new Date(2012, 0, 2),
|
|
181
169
|
dateReviewed: new Date(2013, 0, 2),
|
|
182
170
|
};
|
|
183
|
-
const el = await fixture(html `
|
|
184
|
-
<item-tile
|
|
185
|
-
.model=${model}
|
|
186
|
-
.sortParam=${{ field: 'reviewdate', direction: 'desc' }}
|
|
187
|
-
>
|
|
188
|
-
</item-tile>
|
|
171
|
+
const el = await fixture(html `
|
|
172
|
+
<item-tile
|
|
173
|
+
.model=${model}
|
|
174
|
+
.sortParam=${{ field: 'reviewdate', direction: 'desc' }}
|
|
175
|
+
>
|
|
176
|
+
</item-tile>
|
|
189
177
|
`);
|
|
190
|
-
const dateSortedBy =
|
|
178
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
191
179
|
expect(dateSortedBy).to.exist;
|
|
192
|
-
expect(
|
|
180
|
+
expect(dateSortedBy?.textContent?.trim()).to.contain('reviewed Jan 02, 2013');
|
|
193
181
|
});
|
|
194
182
|
it('should only show the year for a date published of Jan 1 at midnight UTC', async () => {
|
|
195
|
-
var _a, _b;
|
|
196
183
|
const model = {
|
|
197
184
|
datePublished: new Date('2012-01-01T00:00:00Z'),
|
|
198
185
|
};
|
|
199
|
-
const el = await fixture(html `
|
|
200
|
-
<item-tile
|
|
201
|
-
.model=${model}
|
|
202
|
-
.sortParam=${{ field: 'date', direction: 'desc' }}
|
|
203
|
-
>
|
|
204
|
-
</item-tile>
|
|
186
|
+
const el = await fixture(html `
|
|
187
|
+
<item-tile
|
|
188
|
+
.model=${model}
|
|
189
|
+
.sortParam=${{ field: 'date', direction: 'desc' }}
|
|
190
|
+
>
|
|
191
|
+
</item-tile>
|
|
205
192
|
`);
|
|
206
|
-
const dateSortedBy =
|
|
193
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
207
194
|
expect(dateSortedBy).to.exist;
|
|
208
|
-
expect(
|
|
195
|
+
expect(dateSortedBy?.textContent?.trim()).to.equal('published 2012');
|
|
209
196
|
});
|
|
210
197
|
it('should show full date added/archived/reviewed, even on Jan 1 at midnight UTC', async () => {
|
|
211
|
-
var _a, _b, _c, _d, _e, _f;
|
|
212
198
|
const model = {
|
|
213
199
|
dateAdded: new Date(2010, 0, 1, 0, 0, 0, 0),
|
|
214
200
|
dateArchived: new Date(2011, 0, 1, 0, 0, 0, 0),
|
|
215
201
|
datePublished: new Date(2012, 0, 1, 0, 0, 0, 0),
|
|
216
202
|
dateReviewed: new Date(2013, 0, 1, 0, 0, 0, 0),
|
|
217
203
|
};
|
|
218
|
-
const el = await fixture(html `
|
|
219
|
-
<item-tile
|
|
220
|
-
.model=${model}
|
|
221
|
-
.sortParam=${{ field: 'addeddate', direction: 'desc' }}
|
|
222
|
-
>
|
|
223
|
-
</item-tile>
|
|
204
|
+
const el = await fixture(html `
|
|
205
|
+
<item-tile
|
|
206
|
+
.model=${model}
|
|
207
|
+
.sortParam=${{ field: 'addeddate', direction: 'desc' }}
|
|
208
|
+
>
|
|
209
|
+
</item-tile>
|
|
224
210
|
`);
|
|
225
|
-
let dateSortedBy =
|
|
211
|
+
let dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
226
212
|
expect(dateSortedBy).to.exist;
|
|
227
|
-
expect(
|
|
213
|
+
expect(dateSortedBy?.textContent?.trim()).to.equal('added Jan 01, 2010');
|
|
228
214
|
el.sortParam = { field: 'publicdate', direction: 'desc' };
|
|
229
215
|
await el.updateComplete;
|
|
230
|
-
dateSortedBy =
|
|
216
|
+
dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
231
217
|
expect(dateSortedBy).to.exist;
|
|
232
|
-
expect(
|
|
218
|
+
expect(dateSortedBy?.textContent?.trim()).to.equal('archived Jan 01, 2011');
|
|
233
219
|
el.sortParam = { field: 'reviewdate', direction: 'desc' };
|
|
234
220
|
await el.updateComplete;
|
|
235
|
-
dateSortedBy =
|
|
221
|
+
dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
236
222
|
expect(dateSortedBy).to.exist;
|
|
237
|
-
expect(
|
|
223
|
+
expect(dateSortedBy?.textContent?.trim()).to.equal('reviewed Jan 01, 2013');
|
|
238
224
|
});
|
|
239
225
|
it('should display dates in UTC time zone by default', async () => {
|
|
240
|
-
var _a, _b;
|
|
241
226
|
const model = {
|
|
242
227
|
datePublished: new Date('2012-02-15T00:00:00Z'),
|
|
243
228
|
};
|
|
244
|
-
const el = await fixture(html `
|
|
245
|
-
<item-tile
|
|
246
|
-
.model=${model}
|
|
247
|
-
.sortParam=${{ field: 'date', direction: 'desc' }}
|
|
248
|
-
>
|
|
249
|
-
</item-tile>
|
|
229
|
+
const el = await fixture(html `
|
|
230
|
+
<item-tile
|
|
231
|
+
.model=${model}
|
|
232
|
+
.sortParam=${{ field: 'date', direction: 'desc' }}
|
|
233
|
+
>
|
|
234
|
+
</item-tile>
|
|
250
235
|
`);
|
|
251
|
-
const dateSortedBy =
|
|
236
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
252
237
|
expect(dateSortedBy).to.exist;
|
|
253
|
-
expect(
|
|
238
|
+
expect(dateSortedBy?.textContent?.trim()).to.equal('published Feb 15, 2012');
|
|
254
239
|
});
|
|
255
240
|
it('should display dates in local time when useLocalTime option is true', async () => {
|
|
256
|
-
var _a, _b;
|
|
257
241
|
// Expected behavior depends on the time zone offset where the testing occurs
|
|
258
242
|
const offset = new Date().getTimezoneOffset();
|
|
259
243
|
let datePublished, expected;
|
|
@@ -275,152 +259,141 @@ describe('Item Tile', () => {
|
|
|
275
259
|
const model = {
|
|
276
260
|
datePublished,
|
|
277
261
|
};
|
|
278
|
-
const el = await fixture(html `
|
|
279
|
-
<item-tile
|
|
280
|
-
useLocalTime
|
|
281
|
-
.model=${model}
|
|
282
|
-
.sortParam=${{ field: 'date', direction: 'desc' }}
|
|
283
|
-
>
|
|
284
|
-
</item-tile>
|
|
262
|
+
const el = await fixture(html `
|
|
263
|
+
<item-tile
|
|
264
|
+
useLocalTime
|
|
265
|
+
.model=${model}
|
|
266
|
+
.sortParam=${{ field: 'date', direction: 'desc' }}
|
|
267
|
+
>
|
|
268
|
+
</item-tile>
|
|
285
269
|
`);
|
|
286
|
-
const dateSortedBy =
|
|
270
|
+
const dateSortedBy = el.shadowRoot?.querySelector('.date-sorted-by');
|
|
287
271
|
expect(dateSortedBy).to.exist;
|
|
288
|
-
expect(
|
|
272
|
+
expect(dateSortedBy?.textContent?.trim()).to.equal(expected);
|
|
289
273
|
});
|
|
290
274
|
it('should show the first creator matching the letter filter, if defined', async () => {
|
|
291
|
-
var _a, _b;
|
|
292
275
|
const model = {
|
|
293
276
|
creator: 'foo',
|
|
294
277
|
creators: ['foo', 'bar', 'baz'],
|
|
295
278
|
};
|
|
296
|
-
const el = await fixture(html `
|
|
297
|
-
<item-tile .model=${model} .creatorFilter=${'B'}> </item-tile>
|
|
279
|
+
const el = await fixture(html `
|
|
280
|
+
<item-tile .model=${model} .creatorFilter=${'B'}> </item-tile>
|
|
298
281
|
`);
|
|
299
|
-
const creator =
|
|
282
|
+
const creator = el.shadowRoot?.querySelector('.created-by');
|
|
300
283
|
expect(creator).to.exist;
|
|
301
|
-
expect(
|
|
284
|
+
expect(creator?.textContent?.trim()).to.match(/by\s+bar/);
|
|
302
285
|
});
|
|
303
286
|
it('should render with snippet block when it has snippets', async () => {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
</item-tile>
|
|
287
|
+
const el = await fixture(html `
|
|
288
|
+
<item-tile .model=${{ snippets: ['some {{{snippet}}} text'] }}>
|
|
289
|
+
</item-tile>
|
|
308
290
|
`);
|
|
309
|
-
const snippetBlock =
|
|
291
|
+
const snippetBlock = el.shadowRoot?.querySelector('text-snippet-block');
|
|
310
292
|
expect(snippetBlock).to.exist;
|
|
311
293
|
});
|
|
312
294
|
it('should not render snippet block when no snippets are present', async () => {
|
|
313
|
-
var _a;
|
|
314
295
|
const el = await fixture(html `<item-tile></item-tile>`);
|
|
315
|
-
const snippetBlock =
|
|
296
|
+
const snippetBlock = el.shadowRoot?.querySelector('text-snippet-block');
|
|
316
297
|
expect(snippetBlock).to.not.exist;
|
|
317
298
|
});
|
|
318
299
|
it('should render info button when showInfoButton flag is set', async () => {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
<item-tile ?showInfoButton=${true}> </item-tile>
|
|
300
|
+
const el = await fixture(html `
|
|
301
|
+
<item-tile ?showInfoButton=${true}> </item-tile>
|
|
322
302
|
`);
|
|
323
|
-
const infoButton =
|
|
303
|
+
const infoButton = el.shadowRoot?.querySelector('.info-button');
|
|
324
304
|
expect(infoButton).to.exist;
|
|
325
305
|
});
|
|
326
306
|
it('should dispatch event when info button tapped', async () => {
|
|
327
|
-
var _a;
|
|
328
307
|
const infoButtonSpy = sinon.spy();
|
|
329
|
-
const el = await fixture(html `
|
|
330
|
-
<item-tile ?showInfoButton=${true} @infoButtonPressed=${infoButtonSpy}>
|
|
331
|
-
</item-tile>
|
|
308
|
+
const el = await fixture(html `
|
|
309
|
+
<item-tile ?showInfoButton=${true} @infoButtonPressed=${infoButtonSpy}>
|
|
310
|
+
</item-tile>
|
|
332
311
|
`);
|
|
333
|
-
const infoButton =
|
|
312
|
+
const infoButton = el.shadowRoot?.querySelector('.info-button');
|
|
334
313
|
infoButton.click();
|
|
335
314
|
await el.updateComplete;
|
|
336
315
|
expect(infoButtonSpy.callCount).to.equal(1);
|
|
337
316
|
});
|
|
338
317
|
it('should render with volume/issue view', async () => {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
<item-tile .model=${{ volume: '1', issue: 'Index' }}></item-tile>
|
|
318
|
+
const el = await fixture(html `
|
|
319
|
+
<item-tile .model=${{ volume: '1', issue: 'Index' }}></item-tile>
|
|
342
320
|
`);
|
|
343
|
-
const volumeIssueBlock =
|
|
321
|
+
const volumeIssueBlock = el.shadowRoot?.querySelector('.volume-issue');
|
|
344
322
|
expect(volumeIssueBlock).to.exist;
|
|
345
323
|
});
|
|
346
324
|
it('should render with volume/issue view to not render', async () => {
|
|
347
|
-
var _a;
|
|
348
325
|
const el = await fixture(html `<item-tile></item-tile>`);
|
|
349
|
-
const volumeIssueBlock =
|
|
326
|
+
const volumeIssueBlock = el.shadowRoot?.querySelector('.volume-issue');
|
|
350
327
|
expect(volumeIssueBlock).to.not.exist;
|
|
351
328
|
});
|
|
352
329
|
it('should render web capture date links if present', async () => {
|
|
353
|
-
var _a, _b, _c, _d, _e;
|
|
354
330
|
const captureDates = [
|
|
355
331
|
new Date('2010-01-02T12:34:56Z'),
|
|
356
332
|
new Date('2011-02-03T12:43:21Z'),
|
|
357
333
|
];
|
|
358
|
-
const el = await fixture(html `
|
|
359
|
-
<item-tile
|
|
334
|
+
const el = await fixture(html `
|
|
335
|
+
<item-tile
|
|
360
336
|
.model=${{
|
|
361
337
|
identifier: 'foo',
|
|
362
338
|
title: 'https://example.com/',
|
|
363
339
|
captureDates,
|
|
364
|
-
}}
|
|
365
|
-
></item-tile>
|
|
340
|
+
}}
|
|
341
|
+
></item-tile>
|
|
366
342
|
`);
|
|
367
|
-
const captureDatesUl =
|
|
343
|
+
const captureDatesUl = el.shadowRoot?.querySelector('.capture-dates');
|
|
368
344
|
expect(captureDatesUl, 'capture dates container').to.exist;
|
|
369
|
-
expect(captureDatesUl
|
|
370
|
-
const firstDateLink =
|
|
345
|
+
expect(captureDatesUl?.children.length).to.equal(2);
|
|
346
|
+
const firstDateLink = captureDatesUl?.children[0]?.querySelector('a[href]');
|
|
371
347
|
expect(firstDateLink, 'first date link').to.exist;
|
|
372
|
-
expect(firstDateLink
|
|
373
|
-
expect(
|
|
374
|
-
const secondDateLink =
|
|
348
|
+
expect(firstDateLink?.getAttribute('href')).to.equal('https://web.archive.org/web/20100102123456/https%3A%2F%2Fexample.com%2F');
|
|
349
|
+
expect(firstDateLink?.textContent?.trim()).to.equal('Jan 02, 2010');
|
|
350
|
+
const secondDateLink = captureDatesUl?.children[1]?.querySelector('a[href]');
|
|
375
351
|
expect(secondDateLink, 'second date link').to.exist;
|
|
376
|
-
expect(secondDateLink
|
|
377
|
-
expect(
|
|
352
|
+
expect(secondDateLink?.getAttribute('href')).to.equal('https://web.archive.org/web/20110203124321/https%3A%2F%2Fexample.com%2F');
|
|
353
|
+
expect(secondDateLink?.textContent?.trim()).to.equal('Feb 03, 2011');
|
|
378
354
|
});
|
|
379
355
|
it('should not render web captures if no title is present', async () => {
|
|
380
|
-
var _a;
|
|
381
356
|
const captureDates = [
|
|
382
357
|
new Date('2010-01-02T12:34:56Z'),
|
|
383
358
|
new Date('2011-02-03T12:43:21Z'),
|
|
384
359
|
];
|
|
385
|
-
const el = await fixture(html `
|
|
386
|
-
<item-tile
|
|
360
|
+
const el = await fixture(html `
|
|
361
|
+
<item-tile
|
|
387
362
|
.model=${{
|
|
388
363
|
identifier: 'foo',
|
|
389
364
|
captureDates,
|
|
390
|
-
}}
|
|
391
|
-
></item-tile>
|
|
365
|
+
}}
|
|
366
|
+
></item-tile>
|
|
392
367
|
`);
|
|
393
|
-
const captureDatesUl =
|
|
368
|
+
const captureDatesUl = el.shadowRoot?.querySelector('.capture-dates');
|
|
394
369
|
expect(captureDatesUl).not.to.exist;
|
|
395
370
|
});
|
|
396
371
|
it('should render review snippet if present', async () => {
|
|
397
|
-
var _a;
|
|
398
372
|
const review = {
|
|
399
373
|
title: 'Foo',
|
|
400
374
|
body: 'foo bar baz',
|
|
401
375
|
stars: 3,
|
|
402
376
|
};
|
|
403
|
-
const el = await fixture(html `
|
|
404
|
-
<item-tile
|
|
377
|
+
const el = await fixture(html `
|
|
378
|
+
<item-tile
|
|
405
379
|
.model=${{
|
|
406
380
|
identifier: 'foo',
|
|
407
381
|
review,
|
|
408
|
-
}}
|
|
409
|
-
></item-tile>
|
|
382
|
+
}}
|
|
383
|
+
></item-tile>
|
|
410
384
|
`);
|
|
411
|
-
const reviewBlock =
|
|
385
|
+
const reviewBlock = el.shadowRoot?.querySelector('review-block');
|
|
412
386
|
expect(reviewBlock).to.exist;
|
|
413
387
|
});
|
|
414
388
|
it('should not render review snippet block when no review is present', async () => {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
<item-tile
|
|
389
|
+
const el = await fixture(html `
|
|
390
|
+
<item-tile
|
|
418
391
|
.model=${{
|
|
419
392
|
identifier: 'foo',
|
|
420
|
-
}}
|
|
421
|
-
></item-tile>
|
|
393
|
+
}}
|
|
394
|
+
></item-tile>
|
|
422
395
|
`);
|
|
423
|
-
const reviewBlock =
|
|
396
|
+
const reviewBlock = el.shadowRoot?.querySelector('review-block');
|
|
424
397
|
expect(reviewBlock).not.to.exist;
|
|
425
398
|
});
|
|
426
399
|
});
|