@internetarchive/collection-browser 3.3.0 → 3.3.1-alpha1

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 (69) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  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/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/src/collection-browser.js +683 -683
  11. package/dist/src/collection-browser.js.map +1 -1
  12. package/dist/src/collection-facets/more-facets-content.js +118 -118
  13. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  14. package/dist/src/collection-facets.js +266 -266
  15. package/dist/src/collection-facets.js.map +1 -1
  16. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  17. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  18. package/dist/src/data-source/models.js.map +1 -1
  19. package/dist/src/tiles/base-tile-component.js.map +1 -1
  20. package/dist/src/tiles/grid/account-tile.js +36 -36
  21. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  22. package/dist/src/tiles/grid/collection-tile.js +77 -77
  23. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  24. package/dist/src/tiles/grid/item-tile.js +137 -137
  25. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  26. package/dist/src/tiles/list/tile-list-compact.js +99 -99
  27. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  28. package/dist/src/tiles/list/tile-list.js +297 -297
  29. package/dist/src/tiles/list/tile-list.js.map +1 -1
  30. package/dist/src/tiles/tile-dispatcher.js +203 -203
  31. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  32. package/dist/src/utils/format-date.js.map +1 -1
  33. package/dist/test/collection-browser.test.js +189 -189
  34. package/dist/test/collection-browser.test.js.map +1 -1
  35. package/dist/test/tiles/grid/item-tile.test.js +77 -77
  36. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  37. package/dist/test/tiles/list/tile-list-compact.test.js +70 -70
  38. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  39. package/dist/test/tiles/list/tile-list.test.js +126 -126
  40. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  41. package/dist/test/utils/format-date.test.js.map +1 -1
  42. package/eslint.config.mjs +53 -53
  43. package/index.html +24 -24
  44. package/local.archive.org.cert +86 -86
  45. package/local.archive.org.key +27 -27
  46. package/package.json +117 -117
  47. package/renovate.json +6 -6
  48. package/src/collection-browser.ts +2829 -2829
  49. package/src/collection-facets/more-facets-content.ts +639 -639
  50. package/src/collection-facets.ts +995 -995
  51. package/src/data-source/collection-browser-data-source.ts +1401 -1401
  52. package/src/data-source/collection-browser-query-state.ts +65 -65
  53. package/src/data-source/models.ts +43 -43
  54. package/src/tiles/base-tile-component.ts +65 -65
  55. package/src/tiles/grid/account-tile.ts +113 -113
  56. package/src/tiles/grid/collection-tile.ts +163 -163
  57. package/src/tiles/grid/item-tile.ts +340 -340
  58. package/src/tiles/list/tile-list-compact.ts +239 -239
  59. package/src/tiles/list/tile-list.ts +700 -700
  60. package/src/tiles/tile-dispatcher.ts +490 -490
  61. package/src/utils/format-date.ts +62 -62
  62. package/test/collection-browser.test.ts +2403 -2403
  63. package/test/tiles/grid/item-tile.test.ts +520 -520
  64. package/test/tiles/list/tile-list-compact.test.ts +282 -282
  65. package/test/tiles/list/tile-list.test.ts +552 -552
  66. package/test/utils/format-date.test.ts +89 -89
  67. package/tsconfig.json +20 -20
  68. package/web-dev-server.config.mjs +30 -30
  69. package/web-test-runner.config.mjs +41 -41
@@ -1,282 +1,282 @@
1
- import { expect, fixture } from '@open-wc/testing';
2
- import { html } from 'lit';
3
- import type { TileListCompact } from '../../../src/tiles/list/tile-list-compact';
4
-
5
- import '../../../src/tiles/list/tile-list-compact';
6
- import type { TileModel } from '../../../src/models';
7
-
8
- describe('List Tile Compact', () => {
9
- it('should render initial component', async () => {
10
- const el = await fixture<TileListCompact>(
11
- html`<tile-list-compact></tile-list-compact>`,
12
- );
13
-
14
- const listContainer = el.shadowRoot?.querySelector('#list-line');
15
- const itemTitle = el.shadowRoot?.querySelector('#title');
16
- const imageBlock = el.shadowRoot?.querySelector('image-block');
17
- const itemIcon = el.shadowRoot?.querySelector('#icon');
18
- const itemViews = el.shadowRoot?.querySelector('#views');
19
-
20
- expect(listContainer).to.exist;
21
- expect(itemTitle).to.exist;
22
- expect(imageBlock).to.exist;
23
- expect(itemIcon).to.exist;
24
- expect(itemViews).to.exist;
25
- });
26
-
27
- it('should render with creator element with title', async () => {
28
- const el = await fixture<TileListCompact>(html`
29
- <tile-list-compact
30
- .model=${{ creators: ['someone'] }}
31
- ></tile-list-compact>
32
- `);
33
-
34
- const creator = el.shadowRoot?.querySelector('#creator');
35
-
36
- expect(creator).to.exist;
37
- });
38
-
39
- it('should render title link with model href if provided', async () => {
40
- const el = await fixture<TileListCompact>(html`
41
- <tile-list-compact
42
- .baseNavigationUrl=${''}
43
- .model=${{ identifier: 'id', title: 'foo', href: '/foo/bar' }}
44
- ></tile-list-compact>
45
- `);
46
-
47
- const title = el.shadowRoot?.querySelector('#title');
48
-
49
- expect(title).to.exist;
50
- expect(title?.getAttribute('href')).to.equal('/foo/bar');
51
- });
52
-
53
- it('should render weekly views when sorting by week', async () => {
54
- const el = await fixture<TileListCompact>(html`
55
- <tile-list-compact
56
- .model=${{ viewCount: 50, weeklyViewCount: 10 }}
57
- .sortParam=${{ field: 'week', direction: 'desc' }}
58
- >
59
- </tile-list-compact>
60
- `);
61
-
62
- const viewsColumn = el.shadowRoot?.getElementById('views');
63
- expect(viewsColumn).to.exist;
64
- expect(viewsColumn?.textContent?.trim()).to.equal('10');
65
- });
66
-
67
- it('should render 0 for views if missing model', async () => {
68
- const el = await fixture<TileListCompact>(html`
69
- <tile-list-compact .sortParam=${{ field: 'week', direction: 'desc' }}>
70
- </tile-list-compact>
71
- `);
72
-
73
- const viewsColumn = el.shadowRoot?.getElementById('views');
74
- expect(viewsColumn).to.exist;
75
- expect(viewsColumn?.textContent?.trim()).to.equal('0');
76
- });
77
-
78
- it('should render published date when sorting by it', async () => {
79
- const model: Partial<TileModel> = {
80
- dateAdded: new Date(2010, 0, 2),
81
- dateArchived: new Date(2011, 0, 2),
82
- datePublished: new Date(2012, 0, 2),
83
- dateReviewed: new Date(2013, 0, 2),
84
- };
85
-
86
- const el = await fixture<TileListCompact>(html`
87
- <tile-list-compact
88
- .model=${model}
89
- .sortParam=${{ field: 'date', direction: 'desc' }}
90
- >
91
- </tile-list-compact>
92
- `);
93
-
94
- const dateColumn = el.shadowRoot?.getElementById('date');
95
- expect(dateColumn).to.exist;
96
- expect(dateColumn?.textContent?.trim()).to.equal('Jan 02, 2012');
97
- });
98
-
99
- it('should render added date when sorting by it', async () => {
100
- const model: Partial<TileModel> = {
101
- dateAdded: new Date(2010, 0, 2),
102
- dateArchived: new Date(2011, 0, 2),
103
- datePublished: new Date(2012, 0, 2),
104
- dateReviewed: new Date(2013, 0, 2),
105
- };
106
-
107
- const el = await fixture<TileListCompact>(html`
108
- <tile-list-compact
109
- .model=${model}
110
- .sortParam=${{ field: 'addeddate', direction: 'desc' }}
111
- >
112
- </tile-list-compact>
113
- `);
114
-
115
- const dateColumn = el.shadowRoot?.getElementById('date');
116
- expect(dateColumn).to.exist;
117
- expect(dateColumn?.textContent?.trim()).to.equal('Jan 02, 2010');
118
- });
119
-
120
- it('should render archived date when sorting by it', async () => {
121
- const model: Partial<TileModel> = {
122
- dateAdded: new Date(2010, 0, 2),
123
- dateArchived: new Date(2011, 0, 2),
124
- datePublished: new Date(2012, 0, 2),
125
- dateReviewed: new Date(2013, 0, 2),
126
- };
127
-
128
- const el = await fixture<TileListCompact>(html`
129
- <tile-list-compact
130
- .model=${model}
131
- .sortParam=${{ field: 'publicdate', direction: 'desc' }}
132
- >
133
- </tile-list-compact>
134
- `);
135
-
136
- const dateColumn = el.shadowRoot?.getElementById('date');
137
- expect(dateColumn).to.exist;
138
- expect(dateColumn?.textContent?.trim()).to.equal('Jan 02, 2011');
139
- });
140
-
141
- it('should render reviewed date when sorting by it', async () => {
142
- const model: Partial<TileModel> = {
143
- dateAdded: new Date(2010, 0, 2),
144
- dateArchived: new Date(2011, 0, 2),
145
- datePublished: new Date(2012, 0, 2),
146
- dateReviewed: new Date(2013, 0, 2),
147
- };
148
-
149
- const el = await fixture<TileListCompact>(html`
150
- <tile-list-compact
151
- .model=${model}
152
- .sortParam=${{ field: 'reviewdate', direction: 'desc' }}
153
- >
154
- </tile-list-compact>
155
- `);
156
-
157
- const dateColumn = el.shadowRoot?.getElementById('date');
158
- expect(dateColumn).to.exist;
159
- expect(dateColumn?.textContent?.trim()).to.equal('Jan 02, 2013');
160
- });
161
-
162
- it('should only show the year for a date published of Jan 1 at midnight UTC', async () => {
163
- const model: Partial<TileModel> = {
164
- datePublished: new Date('2012-01-01T00:00:00Z'),
165
- };
166
-
167
- const el = await fixture<TileListCompact>(html`
168
- <tile-list-compact
169
- .model=${model}
170
- .sortParam=${{ field: 'date', direction: 'desc' }}
171
- >
172
- </tile-list-compact>
173
- `);
174
-
175
- const dateColumn = el.shadowRoot?.getElementById('date');
176
- expect(dateColumn).to.exist;
177
- expect(dateColumn?.textContent?.trim()).to.equal('2012');
178
- });
179
-
180
- it('should show full date added/archived/reviewed, even on Jan 1 at midnight UTC', async () => {
181
- const model: Partial<TileModel> = {
182
- dateAdded: new Date(2010, 0, 1, 0, 0, 0, 0),
183
- dateArchived: new Date(2011, 0, 1, 0, 0, 0, 0),
184
- datePublished: new Date(2012, 0, 1, 0, 0, 0, 0),
185
- dateReviewed: new Date(2013, 0, 1, 0, 0, 0, 0),
186
- };
187
-
188
- const el = await fixture<TileListCompact>(html`
189
- <tile-list-compact
190
- .model=${model}
191
- .sortParam=${{ field: 'addeddate', direction: 'desc' }}
192
- >
193
- </tile-list-compact>
194
- `);
195
-
196
- let dateColumn = el.shadowRoot?.getElementById('date');
197
- expect(dateColumn).to.exist;
198
- expect(dateColumn?.textContent?.trim()).to.equal('Jan 01, 2010');
199
-
200
- el.sortParam = { field: 'publicdate', direction: 'desc' };
201
- await el.updateComplete;
202
- dateColumn = el.shadowRoot?.getElementById('date');
203
- expect(dateColumn).to.exist;
204
- expect(dateColumn?.textContent?.trim()).to.equal('Jan 01, 2011');
205
-
206
- el.sortParam = { field: 'reviewdate', direction: 'desc' };
207
- await el.updateComplete;
208
- dateColumn = el.shadowRoot?.getElementById('date');
209
- expect(dateColumn).to.exist;
210
- expect(dateColumn?.textContent?.trim()).to.equal('Jan 01, 2013');
211
- });
212
-
213
- it('should display dates in UTC time zone by default', async () => {
214
- const model: Partial<TileModel> = {
215
- datePublished: new Date('2012-02-15T00:00:00Z'),
216
- };
217
-
218
- const el = await fixture<TileListCompact>(html`
219
- <tile-list-compact
220
- .model=${model}
221
- .sortParam=${{ field: 'date', direction: 'desc' }}
222
- >
223
- </tile-list-compact>
224
- `);
225
-
226
- const dateColumn = el.shadowRoot?.getElementById('date');
227
- expect(dateColumn).to.exist;
228
- expect(dateColumn?.textContent?.trim()).to.equal('Feb 15, 2012');
229
- });
230
-
231
- it('should display dates in local time when useLocalTime option is true', async () => {
232
- // Expected behavior depends on the time zone offset where the testing occurs
233
- const offset = new Date().getTimezoneOffset();
234
- let datePublished, expected;
235
- if (offset > 0) {
236
- // Positive local time zone offsets have earlier local dates than UTC
237
- datePublished = new Date('2012-02-15T00:00:00Z');
238
- expected = 'Feb 14, 2012';
239
- } else if (offset < 0) {
240
- // Negative local time zone offsets have later local dates than UTC
241
- datePublished = new Date('2012-02-15T23:59:59Z');
242
- expected = 'Feb 16, 2012';
243
- } else {
244
- // Local time may just be UTC itself
245
- datePublished = new Date('2012-02-15T00:00:00Z');
246
- expected = 'Feb 15, 2012';
247
- }
248
-
249
- const model: Partial<TileModel> = {
250
- datePublished,
251
- };
252
-
253
- const el = await fixture<TileListCompact>(html`
254
- <tile-list-compact
255
- useLocalTime
256
- .model=${model}
257
- .sortParam=${{ field: 'date', direction: 'desc' }}
258
- >
259
- </tile-list-compact>
260
- `);
261
-
262
- const dateColumn = el.shadowRoot?.getElementById('date');
263
- expect(dateColumn).to.exist;
264
- expect(dateColumn?.textContent?.trim()).to.equal(expected);
265
- });
266
-
267
- it('should show the first creator matching the letter filter, if defined', async () => {
268
- const model: Partial<TileModel> = {
269
- creator: 'foo',
270
- creators: ['foo', 'bar', 'baz'],
271
- };
272
-
273
- const el = await fixture<TileListCompact>(html`
274
- <tile-list-compact .model=${model} .creatorFilter=${'B'}>
275
- </tile-list-compact>
276
- `);
277
-
278
- const creator = el.shadowRoot?.getElementById('creator');
279
- expect(creator).to.exist;
280
- expect(creator?.textContent?.trim()).to.equal('bar');
281
- });
282
- });
1
+ import { expect, fixture } from '@open-wc/testing';
2
+ import { html } from 'lit';
3
+ import type { TileListCompact } from '../../../src/tiles/list/tile-list-compact';
4
+
5
+ import '../../../src/tiles/list/tile-list-compact';
6
+ import type { TileModel } from '../../../src/models';
7
+
8
+ describe('List Tile Compact', () => {
9
+ it('should render initial component', async () => {
10
+ const el = await fixture<TileListCompact>(
11
+ html`<tile-list-compact></tile-list-compact>`,
12
+ );
13
+
14
+ const listContainer = el.shadowRoot?.querySelector('#list-line');
15
+ const itemTitle = el.shadowRoot?.querySelector('#title');
16
+ const imageBlock = el.shadowRoot?.querySelector('image-block');
17
+ const itemIcon = el.shadowRoot?.querySelector('#icon');
18
+ const itemViews = el.shadowRoot?.querySelector('#views');
19
+
20
+ expect(listContainer).to.exist;
21
+ expect(itemTitle).to.exist;
22
+ expect(imageBlock).to.exist;
23
+ expect(itemIcon).to.exist;
24
+ expect(itemViews).to.exist;
25
+ });
26
+
27
+ it('should render with creator element with title', async () => {
28
+ const el = await fixture<TileListCompact>(html`
29
+ <tile-list-compact
30
+ .model=${{ creators: ['someone'] }}
31
+ ></tile-list-compact>
32
+ `);
33
+
34
+ const creator = el.shadowRoot?.querySelector('#creator');
35
+
36
+ expect(creator).to.exist;
37
+ });
38
+
39
+ it('should render title link with model href if provided', async () => {
40
+ const el = await fixture<TileListCompact>(html`
41
+ <tile-list-compact
42
+ .baseNavigationUrl=${''}
43
+ .model=${{ identifier: 'id', title: 'foo', href: '/foo/bar' }}
44
+ ></tile-list-compact>
45
+ `);
46
+
47
+ const title = el.shadowRoot?.querySelector('#title');
48
+
49
+ expect(title).to.exist;
50
+ expect(title?.getAttribute('href')).to.equal('/foo/bar');
51
+ });
52
+
53
+ it('should render weekly views when sorting by week', async () => {
54
+ const el = await fixture<TileListCompact>(html`
55
+ <tile-list-compact
56
+ .model=${{ viewCount: 50, weeklyViewCount: 10 }}
57
+ .sortParam=${{ field: 'week', direction: 'desc' }}
58
+ >
59
+ </tile-list-compact>
60
+ `);
61
+
62
+ const viewsColumn = el.shadowRoot?.getElementById('views');
63
+ expect(viewsColumn).to.exist;
64
+ expect(viewsColumn?.textContent?.trim()).to.equal('10');
65
+ });
66
+
67
+ it('should render 0 for views if missing model', async () => {
68
+ const el = await fixture<TileListCompact>(html`
69
+ <tile-list-compact .sortParam=${{ field: 'week', direction: 'desc' }}>
70
+ </tile-list-compact>
71
+ `);
72
+
73
+ const viewsColumn = el.shadowRoot?.getElementById('views');
74
+ expect(viewsColumn).to.exist;
75
+ expect(viewsColumn?.textContent?.trim()).to.equal('0');
76
+ });
77
+
78
+ it('should render published date when sorting by it', async () => {
79
+ const model: Partial<TileModel> = {
80
+ dateAdded: new Date(2010, 0, 2),
81
+ dateArchived: new Date(2011, 0, 2),
82
+ datePublished: new Date(2012, 0, 2),
83
+ dateReviewed: new Date(2013, 0, 2),
84
+ };
85
+
86
+ const el = await fixture<TileListCompact>(html`
87
+ <tile-list-compact
88
+ .model=${model}
89
+ .sortParam=${{ field: 'date', direction: 'desc' }}
90
+ >
91
+ </tile-list-compact>
92
+ `);
93
+
94
+ const dateColumn = el.shadowRoot?.getElementById('date');
95
+ expect(dateColumn).to.exist;
96
+ expect(dateColumn?.textContent?.trim()).to.equal('Jan 02, 2012');
97
+ });
98
+
99
+ it('should render added date when sorting by it', async () => {
100
+ const model: Partial<TileModel> = {
101
+ dateAdded: new Date(2010, 0, 2),
102
+ dateArchived: new Date(2011, 0, 2),
103
+ datePublished: new Date(2012, 0, 2),
104
+ dateReviewed: new Date(2013, 0, 2),
105
+ };
106
+
107
+ const el = await fixture<TileListCompact>(html`
108
+ <tile-list-compact
109
+ .model=${model}
110
+ .sortParam=${{ field: 'addeddate', direction: 'desc' }}
111
+ >
112
+ </tile-list-compact>
113
+ `);
114
+
115
+ const dateColumn = el.shadowRoot?.getElementById('date');
116
+ expect(dateColumn).to.exist;
117
+ expect(dateColumn?.textContent?.trim()).to.equal('Jan 02, 2010');
118
+ });
119
+
120
+ it('should render archived date when sorting by it', async () => {
121
+ const model: Partial<TileModel> = {
122
+ dateAdded: new Date(2010, 0, 2),
123
+ dateArchived: new Date(2011, 0, 2),
124
+ datePublished: new Date(2012, 0, 2),
125
+ dateReviewed: new Date(2013, 0, 2),
126
+ };
127
+
128
+ const el = await fixture<TileListCompact>(html`
129
+ <tile-list-compact
130
+ .model=${model}
131
+ .sortParam=${{ field: 'publicdate', direction: 'desc' }}
132
+ >
133
+ </tile-list-compact>
134
+ `);
135
+
136
+ const dateColumn = el.shadowRoot?.getElementById('date');
137
+ expect(dateColumn).to.exist;
138
+ expect(dateColumn?.textContent?.trim()).to.equal('Jan 02, 2011');
139
+ });
140
+
141
+ it('should render reviewed date when sorting by it', async () => {
142
+ const model: Partial<TileModel> = {
143
+ dateAdded: new Date(2010, 0, 2),
144
+ dateArchived: new Date(2011, 0, 2),
145
+ datePublished: new Date(2012, 0, 2),
146
+ dateReviewed: new Date(2013, 0, 2),
147
+ };
148
+
149
+ const el = await fixture<TileListCompact>(html`
150
+ <tile-list-compact
151
+ .model=${model}
152
+ .sortParam=${{ field: 'reviewdate', direction: 'desc' }}
153
+ >
154
+ </tile-list-compact>
155
+ `);
156
+
157
+ const dateColumn = el.shadowRoot?.getElementById('date');
158
+ expect(dateColumn).to.exist;
159
+ expect(dateColumn?.textContent?.trim()).to.equal('Jan 02, 2013');
160
+ });
161
+
162
+ it('should only show the year for a date published of Jan 1 at midnight UTC', async () => {
163
+ const model: Partial<TileModel> = {
164
+ datePublished: new Date('2012-01-01T00:00:00Z'),
165
+ };
166
+
167
+ const el = await fixture<TileListCompact>(html`
168
+ <tile-list-compact
169
+ .model=${model}
170
+ .sortParam=${{ field: 'date', direction: 'desc' }}
171
+ >
172
+ </tile-list-compact>
173
+ `);
174
+
175
+ const dateColumn = el.shadowRoot?.getElementById('date');
176
+ expect(dateColumn).to.exist;
177
+ expect(dateColumn?.textContent?.trim()).to.equal('2012');
178
+ });
179
+
180
+ it('should show full date added/archived/reviewed, even on Jan 1 at midnight UTC', async () => {
181
+ const model: Partial<TileModel> = {
182
+ dateAdded: new Date(2010, 0, 1, 0, 0, 0, 0),
183
+ dateArchived: new Date(2011, 0, 1, 0, 0, 0, 0),
184
+ datePublished: new Date(2012, 0, 1, 0, 0, 0, 0),
185
+ dateReviewed: new Date(2013, 0, 1, 0, 0, 0, 0),
186
+ };
187
+
188
+ const el = await fixture<TileListCompact>(html`
189
+ <tile-list-compact
190
+ .model=${model}
191
+ .sortParam=${{ field: 'addeddate', direction: 'desc' }}
192
+ >
193
+ </tile-list-compact>
194
+ `);
195
+
196
+ let dateColumn = el.shadowRoot?.getElementById('date');
197
+ expect(dateColumn).to.exist;
198
+ expect(dateColumn?.textContent?.trim()).to.equal('Jan 01, 2010');
199
+
200
+ el.sortParam = { field: 'publicdate', direction: 'desc' };
201
+ await el.updateComplete;
202
+ dateColumn = el.shadowRoot?.getElementById('date');
203
+ expect(dateColumn).to.exist;
204
+ expect(dateColumn?.textContent?.trim()).to.equal('Jan 01, 2011');
205
+
206
+ el.sortParam = { field: 'reviewdate', direction: 'desc' };
207
+ await el.updateComplete;
208
+ dateColumn = el.shadowRoot?.getElementById('date');
209
+ expect(dateColumn).to.exist;
210
+ expect(dateColumn?.textContent?.trim()).to.equal('Jan 01, 2013');
211
+ });
212
+
213
+ it('should display dates in UTC time zone by default', async () => {
214
+ const model: Partial<TileModel> = {
215
+ datePublished: new Date('2012-02-15T00:00:00Z'),
216
+ };
217
+
218
+ const el = await fixture<TileListCompact>(html`
219
+ <tile-list-compact
220
+ .model=${model}
221
+ .sortParam=${{ field: 'date', direction: 'desc' }}
222
+ >
223
+ </tile-list-compact>
224
+ `);
225
+
226
+ const dateColumn = el.shadowRoot?.getElementById('date');
227
+ expect(dateColumn).to.exist;
228
+ expect(dateColumn?.textContent?.trim()).to.equal('Feb 15, 2012');
229
+ });
230
+
231
+ it('should display dates in local time when useLocalTime option is true', async () => {
232
+ // Expected behavior depends on the time zone offset where the testing occurs
233
+ const offset = new Date().getTimezoneOffset();
234
+ let datePublished, expected;
235
+ if (offset > 0) {
236
+ // Positive local time zone offsets have earlier local dates than UTC
237
+ datePublished = new Date('2012-02-15T00:00:00Z');
238
+ expected = 'Feb 14, 2012';
239
+ } else if (offset < 0) {
240
+ // Negative local time zone offsets have later local dates than UTC
241
+ datePublished = new Date('2012-02-15T23:59:59Z');
242
+ expected = 'Feb 16, 2012';
243
+ } else {
244
+ // Local time may just be UTC itself
245
+ datePublished = new Date('2012-02-15T00:00:00Z');
246
+ expected = 'Feb 15, 2012';
247
+ }
248
+
249
+ const model: Partial<TileModel> = {
250
+ datePublished,
251
+ };
252
+
253
+ const el = await fixture<TileListCompact>(html`
254
+ <tile-list-compact
255
+ useLocalTime
256
+ .model=${model}
257
+ .sortParam=${{ field: 'date', direction: 'desc' }}
258
+ >
259
+ </tile-list-compact>
260
+ `);
261
+
262
+ const dateColumn = el.shadowRoot?.getElementById('date');
263
+ expect(dateColumn).to.exist;
264
+ expect(dateColumn?.textContent?.trim()).to.equal(expected);
265
+ });
266
+
267
+ it('should show the first creator matching the letter filter, if defined', async () => {
268
+ const model: Partial<TileModel> = {
269
+ creator: 'foo',
270
+ creators: ['foo', 'bar', 'baz'],
271
+ };
272
+
273
+ const el = await fixture<TileListCompact>(html`
274
+ <tile-list-compact .model=${model} .creatorFilter=${'B'}>
275
+ </tile-list-compact>
276
+ `);
277
+
278
+ const creator = el.shadowRoot?.getElementById('creator');
279
+ expect(creator).to.exist;
280
+ expect(creator?.textContent?.trim()).to.equal('bar');
281
+ });
282
+ });