@internetarchive/collection-browser 1.4.2-alpha.1 → 1.4.2-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/src/app-root.d.ts +1 -0
  2. package/dist/src/app-root.js +8 -7
  3. package/dist/src/app-root.js.map +1 -1
  4. package/dist/src/collection-browser.d.ts +7 -0
  5. package/dist/src/collection-browser.js +49 -28
  6. package/dist/src/collection-browser.js.map +1 -1
  7. package/dist/src/empty-placeholder.d.ts +10 -2
  8. package/dist/src/empty-placeholder.js +38 -19
  9. package/dist/src/empty-placeholder.js.map +1 -1
  10. package/dist/src/tiles/list/tile-list-compact.js +9 -6
  11. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  12. package/dist/src/tiles/list/tile-list.js +5 -5
  13. package/dist/src/tiles/list/tile-list.js.map +1 -1
  14. package/dist/src/tiles/tile-dispatcher.js +9 -6
  15. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  16. package/dist/test/empty-placeholder.test.js +34 -11
  17. package/dist/test/empty-placeholder.test.js.map +1 -1
  18. package/dist/test/tiles/grid/item-tile.test.js +16 -16
  19. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  20. package/dist/test/tiles/list/tile-list-compact.test.js +17 -17
  21. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  22. package/dist/test/tiles/list/tile-list.test.js +16 -16
  23. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  24. package/dist/test/utils/format-date.test.js +1 -1
  25. package/dist/test/utils/format-date.test.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/app-root.ts +8 -5
  28. package/src/collection-browser.ts +37 -13
  29. package/src/empty-placeholder.ts +51 -18
  30. package/src/tiles/list/tile-list-compact.ts +9 -7
  31. package/src/tiles/list/tile-list.ts +9 -5
  32. package/src/tiles/tile-dispatcher.ts +10 -8
  33. package/test/empty-placeholder.test.ts +43 -8
  34. package/test/tiles/grid/item-tile.test.ts +16 -16
  35. package/test/tiles/list/tile-list-compact.test.ts +17 -17
  36. package/test/tiles/list/tile-list.test.ts +16 -16
  37. package/test/utils/format-date.test.ts +1 -1
package/src/app-root.ts CHANGED
@@ -95,9 +95,7 @@ export class AppRoot extends LitElement {
95
95
  this.searchQuery = this.baseQueryField.value;
96
96
  this.collectionBrowser.searchType = this.searchType;
97
97
 
98
- if ((this.currentPage ?? 1) > 1) {
99
- this.collectionBrowser.goToPage(this.currentPage ?? 1);
100
- }
98
+ this.goToCurrentPage();
101
99
  }
102
100
 
103
101
  private collectionChanged(e: Event) {
@@ -105,8 +103,13 @@ export class AppRoot extends LitElement {
105
103
  this.withinCollection = this.baseCollectionField.value;
106
104
  this.collectionBrowser.withinCollection = this.withinCollection;
107
105
 
108
- if ((this.currentPage ?? 1) > 1) {
109
- this.collectionBrowser.goToPage(this.currentPage ?? 1);
106
+ this.goToCurrentPage();
107
+ }
108
+
109
+ private goToCurrentPage() {
110
+ const page = this.currentPage ?? 1;
111
+ if (page > 1) {
112
+ this.collectionBrowser.goToPage(page);
110
113
  }
111
114
  }
112
115
 
@@ -385,14 +385,20 @@ export class CollectionBrowser
385
385
  }
386
386
 
387
387
  private setPlaceholderType() {
388
+ const hasQuery = !!this.baseQuery?.trim();
389
+ const isCollection = !!this.withinCollection;
390
+ const noResults =
391
+ !this.searchResultsLoading &&
392
+ (this.totalResults === 0 || !this.searchService);
393
+
388
394
  this.placeholderType = null;
389
- if (!this.baseQuery?.trim() && !this.withinCollection) {
395
+ if (!hasQuery && !isCollection) {
390
396
  this.placeholderType = 'empty-query';
391
- } else if (
392
- !this.searchResultsLoading &&
393
- (this.totalResults === 0 || !this.searchService)
394
- ) {
395
- this.placeholderType = 'null-result';
397
+ } else if (noResults) {
398
+ // Within a collection, no query + no results means the collection simply has no viewable items.
399
+ // Otherwise, we must have a user query that produced 0 results.
400
+ this.placeholderType =
401
+ !hasQuery && isCollection ? 'empty-collection' : 'no-results';
396
402
  }
397
403
 
398
404
  if (this.queryErrorMessage) {
@@ -405,6 +411,7 @@ export class CollectionBrowser
405
411
  <empty-placeholder
406
412
  .placeholderType=${this.placeholderType}
407
413
  ?isMobileView=${this.mobileView}
414
+ ?isCollection=${!!this.withinCollection}
408
415
  .detailMessage=${this.queryErrorMessage ?? ''}
409
416
  .baseNavigationUrl=${this.baseNavigationUrl}
410
417
  ></empty-placeholder>
@@ -1486,8 +1493,7 @@ export class CollectionBrowser
1486
1493
 
1487
1494
  private async fetchFacets() {
1488
1495
  const trimmedQuery = this.baseQuery?.trim();
1489
- if (!trimmedQuery && !this.withinCollection) return;
1490
- if (!this.searchService) return;
1496
+ if (!this.canPerformSearch) return;
1491
1497
 
1492
1498
  const { facetFetchQueryKey } = this;
1493
1499
 
@@ -1508,7 +1514,7 @@ export class CollectionBrowser
1508
1514
  );
1509
1515
 
1510
1516
  this.facetsLoading = true;
1511
- const searchResponse = await this.searchService.search(
1517
+ const searchResponse = await this.searchService?.search(
1512
1518
  params,
1513
1519
  this.searchType
1514
1520
  );
@@ -1576,6 +1582,25 @@ export class CollectionBrowser
1576
1582
  });
1577
1583
  }
1578
1584
 
1585
+ /**
1586
+ * Whether a search may be performed in the current state of the component.
1587
+ * This is only true if the search service is defined, and either
1588
+ * (a) a non-empty query is set, or
1589
+ * (b) we are on a collection page in metadata search mode.
1590
+ */
1591
+ private get canPerformSearch(): boolean {
1592
+ if (!this.searchService) return false;
1593
+
1594
+ const trimmedQuery = this.baseQuery?.trim();
1595
+ const hasNonEmptyQuery = !!trimmedQuery;
1596
+ const isCollectionSearch = !!this.withinCollection;
1597
+ const isMetadataSearch = this.searchType === SearchType.METADATA;
1598
+
1599
+ // Metadata searches within a collection are allowed to have no query.
1600
+ // Otherwise, a non-empty query must be set.
1601
+ return hasNonEmptyQuery || (isCollectionSearch && isMetadataSearch);
1602
+ }
1603
+
1579
1604
  /**
1580
1605
  * Additional params to pass to the search service if targeting a collection page,
1581
1606
  * or null otherwise.
@@ -1630,8 +1655,7 @@ export class CollectionBrowser
1630
1655
  */
1631
1656
  async fetchPage(pageNumber: number, numInitialPages = 1) {
1632
1657
  const trimmedQuery = this.baseQuery?.trim();
1633
- if (!trimmedQuery && !this.withinCollection) return;
1634
- if (!this.searchService) return;
1658
+ if (!this.canPerformSearch) return;
1635
1659
 
1636
1660
  // if we already have data, don't fetch again
1637
1661
  if (this.dataSource[pageNumber]) return;
@@ -1665,7 +1689,7 @@ export class CollectionBrowser
1665
1689
  };
1666
1690
  params.uid = await this.requestUID(params, 'hits');
1667
1691
 
1668
- const searchResponse = await this.searchService.search(
1692
+ const searchResponse = await this.searchService?.search(
1669
1693
  params,
1670
1694
  this.searchType
1671
1695
  );
@@ -1854,7 +1878,7 @@ export class CollectionBrowser
1854
1878
  filterType: PrefixFilterType
1855
1879
  ): Promise<Bucket[]> {
1856
1880
  const trimmedQuery = this.baseQuery?.trim();
1857
- if (!trimmedQuery && !this.withinCollection) return [];
1881
+ if (!this.canPerformSearch) return [];
1858
1882
 
1859
1883
  const filterAggregationKey = prefixFilterAggregationKeys[filterType];
1860
1884
  const sortParams = this.sortParam ? [this.sortParam] : [];
@@ -8,21 +8,53 @@ import {
8
8
  } from 'lit';
9
9
  import { customElement, property } from 'lit/decorators.js';
10
10
  import { choose } from 'lit/directives/choose.js';
11
+ import { msg } from '@lit/localize';
11
12
 
12
13
  import emptyQueryIcon from './assets/img/icons/empty-query';
13
14
  import nullResultIcon from './assets/img/icons/null-result';
14
15
 
15
16
  export type PlaceholderType =
16
17
  | 'empty-query'
17
- | 'null-result'
18
+ | 'empty-collection'
19
+ | 'no-results'
18
20
  | 'query-error'
19
21
  | null;
20
22
  @customElement('empty-placeholder')
21
23
  export class EmptyPlaceholder extends LitElement {
24
+ private static readonly MESSAGE_EMPTY_QUERY = msg(
25
+ 'To begin searching, enter a search term in the box above and hit "Go".'
26
+ );
27
+
28
+ private static readonly MESSAGE_NO_SEARCH_RESULTS = msg(
29
+ 'Your search did not match any items in the Archive. ' +
30
+ 'Try different keywords or a more general search.'
31
+ );
32
+
33
+ private static readonly MESSAGE_NO_COLLECTION_RESULTS = msg(
34
+ 'Your search did not match any items in this collection. ' +
35
+ 'Try different keywords or a more general search.'
36
+ );
37
+
38
+ private static readonly MESSAGE_NO_VIEWABLE_MEMBERS = msg(
39
+ 'This collection contains no viewable items.'
40
+ );
41
+
42
+ private static readonly MESSAGE_QUERY_ERROR = msg(html`The search engine
43
+ encountered an error, which might be related to your search query.
44
+ <a
45
+ href="https://help.archive.org/help/search-building-powerful-complex-queries/"
46
+ >
47
+ Tips for constructing search queries.
48
+ </a> `);
49
+
50
+ private static readonly QUERY_ERROR_DETAILS_MESSAGE = msg('Error details:');
51
+
22
52
  @property({ type: String }) placeholderType: PlaceholderType = null;
23
53
 
24
54
  @property({ type: Boolean }) isMobileView?: false;
25
55
 
56
+ @property({ type: Boolean }) isCollection?: false;
57
+
26
58
  @property({ type: String }) detailMessage?: string = '';
27
59
 
28
60
  render() {
@@ -38,7 +70,8 @@ export class EmptyPlaceholder extends LitElement {
38
70
  >
39
71
  ${choose(this.placeholderType, [
40
72
  ['empty-query', () => this.emptyQueryTemplate],
41
- ['null-result', () => this.nullResultTemplate],
73
+ ['empty-collection', () => this.emptyCollectionTemplate],
74
+ ['no-results', () => this.noResultsTemplate],
42
75
  ['query-error', () => this.queryErrorTemplate],
43
76
  ])}
44
77
  </div>
@@ -47,18 +80,24 @@ export class EmptyPlaceholder extends LitElement {
47
80
 
48
81
  private get emptyQueryTemplate(): TemplateResult {
49
82
  return html`
50
- <h2 class="title">
51
- To begin searching, enter a search term in the box above and hit "Go".
52
- </h2>
83
+ <h2 class="title">${EmptyPlaceholder.MESSAGE_EMPTY_QUERY}</h2>
53
84
  <div>${emptyQueryIcon}</div>
54
85
  `;
55
86
  }
56
87
 
57
- private get nullResultTemplate(): TemplateResult {
88
+ private get emptyCollectionTemplate(): TemplateResult {
89
+ return html`
90
+ <h2 class="title">${EmptyPlaceholder.MESSAGE_NO_VIEWABLE_MEMBERS}</h2>
91
+ <div>${nullResultIcon}</div>
92
+ `;
93
+ }
94
+
95
+ private get noResultsTemplate(): TemplateResult {
58
96
  return html`
59
97
  <h2 class="title">
60
- Your search did not match any items in the Archive. Try different
61
- keywords or a more general search.
98
+ ${this.isCollection
99
+ ? EmptyPlaceholder.MESSAGE_NO_COLLECTION_RESULTS
100
+ : EmptyPlaceholder.MESSAGE_NO_SEARCH_RESULTS}
62
101
  </h2>
63
102
  <div>${nullResultIcon}</div>
64
103
  `;
@@ -66,17 +105,11 @@ export class EmptyPlaceholder extends LitElement {
66
105
 
67
106
  private get queryErrorTemplate(): TemplateResult {
68
107
  return html`
69
- <h2 class="title">
70
- The search engine encountered an error, which might be related to your
71
- search query.
72
- <a
73
- href="https://help.archive.org/help/search-building-powerful-complex-queries/"
74
- >
75
- Tips for constructing search queries.
76
- </a>
77
- </h2>
108
+ <h2 class="title">${EmptyPlaceholder.MESSAGE_QUERY_ERROR}</h2>
78
109
  <div>${nullResultIcon}</div>
79
- <p class="error-details">Error details: ${this.detailMessage}</p>
110
+ <p class="error-details">
111
+ ${EmptyPlaceholder.QUERY_ERROR_DETAILS_MESSAGE} ${this.detailMessage}
112
+ </p>
80
113
  `;
81
114
  }
82
115
 
@@ -1,4 +1,4 @@
1
- import { css, html, LitElement } from 'lit';
1
+ import { css, html, LitElement, nothing } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
3
  import DOMPurify from 'dompurify';
4
4
  import type { SortParam } from '@internetarchive/search-service';
@@ -65,17 +65,19 @@ export class TileListCompact extends LitElement {
65
65
  `;
66
66
  }
67
67
 
68
- private get href(): string {
68
+ private get href(): string | typeof nothing {
69
+ if (!this.model?.identifier || this.baseNavigationUrl == null)
70
+ return nothing;
71
+
69
72
  // Use the server-specified href if available.
70
73
  // Otherwise, construct a details page URL from the item identifier.
71
- if (this.model?.href) {
72
- return `${this.baseNavigationUrl}${this.model?.href}`;
74
+ if (this.model.href) {
75
+ return `${this.baseNavigationUrl}${this.model.href}`;
73
76
  }
74
77
 
75
78
  const isCollection = this.model?.mediatype === 'collection';
76
- return `${this.baseNavigationUrl}${
77
- isCollection ? this.collectionPagePath : '/details/'
78
- }${this.model?.identifier}`;
79
+ const basePath = isCollection ? this.collectionPagePath : '/details/';
80
+ return `${this.baseNavigationUrl}${basePath}${this.model.identifier}`;
79
81
  }
80
82
 
81
83
  /*
@@ -96,11 +96,15 @@ export class TileList extends LitElement {
96
96
  if (!this.model) return nothing;
97
97
 
98
98
  const isCollection = this.model.mediatype === 'collection';
99
- return html`<a
100
- href="${this.baseNavigationUrl}${isCollection
101
- ? this.collectionPagePath
102
- : '/details/'}${encodeURI(this.model.identifier)}"
103
- >
99
+ const hrefBasePath = isCollection ? this.collectionPagePath : '/details/';
100
+ const href =
101
+ this.model.identifier && this.baseNavigationUrl != null
102
+ ? `${this.baseNavigationUrl}${hrefBasePath}${encodeURI(
103
+ this.model.identifier
104
+ )}`
105
+ : nothing;
106
+
107
+ return html`<a href=${href}>
104
108
  <image-block
105
109
  .model=${this.model}
106
110
  .baseImageUrl=${this.baseImageUrl}
@@ -124,7 +124,7 @@ export class TileDispatcher
124
124
  private get linkTileTemplate() {
125
125
  return html`
126
126
  <a
127
- href="${this.linkTileHref}"
127
+ href=${this.linkTileHref}
128
128
  aria-label=${this.model?.title ?? 'Untitled item'}
129
129
  title=${this.shouldPrepareHoverPane
130
130
  ? nothing // Don't show title tooltips when we have the tile info popups
@@ -139,17 +139,19 @@ export class TileDispatcher
139
139
  `;
140
140
  }
141
141
 
142
- private get linkTileHref() {
142
+ private get linkTileHref(): string | typeof nothing {
143
+ if (!this.model?.identifier || this.baseNavigationUrl == null)
144
+ return nothing;
145
+
143
146
  // Use the server-specified href if available.
144
147
  // Otherwise, construct a details page URL from the item identifier.
145
- if (this.model?.href) {
146
- return `${this.baseNavigationUrl}${this.model?.href}`;
148
+ if (this.model.href) {
149
+ return `${this.baseNavigationUrl}${this.model.href}`;
147
150
  }
148
151
 
149
- const isCollection = this.model?.mediatype === 'collection';
150
- return `${this.baseNavigationUrl}${
151
- isCollection ? this.collectionPagePath : '/details/'
152
- }${this.model?.identifier}`;
152
+ const isCollection = this.model.mediatype === 'collection';
153
+ const basePath = isCollection ? this.collectionPagePath : '/details/';
154
+ return `${this.baseNavigationUrl}${basePath}${this.model.identifier}`;
153
155
  }
154
156
 
155
157
  /**
@@ -15,21 +15,55 @@ describe('Empty Placeholder', () => {
15
15
  await el.updateComplete;
16
16
 
17
17
  expect(el.shadowRoot?.querySelector('.empty-query')).to.exist;
18
- expect(el.shadowRoot?.querySelector('.null-result')).to.not.exist;
19
- expect(el.shadowRoot?.querySelector('infinite-scroller')).to.not.exist;
18
+
19
+ expect(el.shadowRoot?.querySelector('.empty-collection')).to.not.exist;
20
+ expect(el.shadowRoot?.querySelector('.no-results')).to.not.exist;
21
+ expect(el.shadowRoot?.querySelector('.query-error')).to.not.exist;
22
+ });
23
+
24
+ it('should render with empty-collection placeholder', async () => {
25
+ const el = await fixture<EmptyPlaceholder>(
26
+ html`<empty-placeholder></empty-placeholder>`
27
+ );
28
+
29
+ el.placeholderType = 'empty-collection';
30
+ await el.updateComplete;
31
+
32
+ expect(el.shadowRoot?.querySelector('.empty-collection')).to.exist;
33
+
34
+ expect(el.shadowRoot?.querySelector('.no-results')).to.not.exist;
35
+ expect(el.shadowRoot?.querySelector('.empty-query')).to.not.exist;
36
+ expect(el.shadowRoot?.querySelector('.query-error')).to.not.exist;
20
37
  });
21
38
 
22
- it('should render with null-result placeholder', async () => {
39
+ it('should render with no-results placeholder', async () => {
23
40
  const el = await fixture<EmptyPlaceholder>(
24
41
  html`<empty-placeholder></empty-placeholder>`
25
42
  );
26
43
 
27
- el.placeholderType = 'null-result';
44
+ el.placeholderType = 'no-results';
28
45
  await el.updateComplete;
29
46
 
30
- expect(el.shadowRoot?.querySelector('.null-result')).to.exist;
47
+ expect(el.shadowRoot?.querySelector('.no-results')).to.exist;
48
+
49
+ expect(el.shadowRoot?.querySelector('.empty-query')).to.not.exist;
50
+ expect(el.shadowRoot?.querySelector('.empty-collection')).to.not.exist;
51
+ expect(el.shadowRoot?.querySelector('.query-error')).to.not.exist;
52
+ });
53
+
54
+ it('should render with query-error placeholder', async () => {
55
+ const el = await fixture<EmptyPlaceholder>(
56
+ html`<empty-placeholder></empty-placeholder>`
57
+ );
58
+
59
+ el.placeholderType = 'query-error';
60
+ await el.updateComplete;
61
+
62
+ expect(el.shadowRoot?.querySelector('.query-error')).to.exist;
63
+
31
64
  expect(el.shadowRoot?.querySelector('.empty-query')).to.not.exist;
32
- expect(el.shadowRoot?.querySelector('collection-facets')).to.not.exist;
65
+ expect(el.shadowRoot?.querySelector('.empty-collection')).to.not.exist;
66
+ expect(el.shadowRoot?.querySelector('.no-results')).to.not.exist;
33
67
  });
34
68
 
35
69
  it('should not render any empty placeholder', async () => {
@@ -41,7 +75,8 @@ describe('Empty Placeholder', () => {
41
75
  await el.updateComplete;
42
76
 
43
77
  expect(el.shadowRoot?.querySelector('.empty-query')).to.not.exist;
44
- expect(el.shadowRoot?.querySelector('.null-result')).to.not.exist;
45
- expect(el.shadowRoot?.querySelector('collection-facets')).to.not.exist;
78
+ expect(el.shadowRoot?.querySelector('.empty-collection')).to.not.exist;
79
+ expect(el.shadowRoot?.querySelector('.no-results')).to.not.exist;
80
+ expect(el.shadowRoot?.querySelector('.query-error')).to.not.exist;
46
81
  });
47
82
  });
@@ -158,10 +158,10 @@ describe('Item Tile', () => {
158
158
 
159
159
  it('should render published date when sorting by it', async () => {
160
160
  const model: Partial<TileModel> = {
161
- dateAdded: new Date('2010-01-02'),
162
- dateArchived: new Date('2011-01-02'),
163
- datePublished: new Date('2012-01-02'),
164
- dateReviewed: new Date('2013-01-02'),
161
+ dateAdded: new Date(2010, 0, 2),
162
+ dateArchived: new Date(2011, 0, 2),
163
+ datePublished: new Date(2012, 0, 2),
164
+ dateReviewed: new Date(2013, 0, 2),
165
165
  };
166
166
 
167
167
  const el = await fixture<ItemTile>(html`
@@ -181,10 +181,10 @@ describe('Item Tile', () => {
181
181
 
182
182
  it('should render added date when sorting by it', async () => {
183
183
  const model: Partial<TileModel> = {
184
- dateAdded: new Date('2010-01-02'),
185
- dateArchived: new Date('2011-01-02'),
186
- datePublished: new Date('2012-01-02'),
187
- dateReviewed: new Date('2013-01-02'),
184
+ dateAdded: new Date(2010, 0, 2),
185
+ dateArchived: new Date(2011, 0, 2),
186
+ datePublished: new Date(2012, 0, 2),
187
+ dateReviewed: new Date(2013, 0, 2),
188
188
  };
189
189
 
190
190
  const el = await fixture<ItemTile>(html`
@@ -202,10 +202,10 @@ describe('Item Tile', () => {
202
202
 
203
203
  it('should render archived date when sorting by it', async () => {
204
204
  const model: Partial<TileModel> = {
205
- dateAdded: new Date('2010-01-02'),
206
- dateArchived: new Date('2011-01-02'),
207
- datePublished: new Date('2012-01-02'),
208
- dateReviewed: new Date('2013-01-02'),
205
+ dateAdded: new Date(2010, 0, 2),
206
+ dateArchived: new Date(2011, 0, 2),
207
+ datePublished: new Date(2012, 0, 2),
208
+ dateReviewed: new Date(2013, 0, 2),
209
209
  };
210
210
 
211
211
  const el = await fixture<ItemTile>(html`
@@ -225,10 +225,10 @@ describe('Item Tile', () => {
225
225
 
226
226
  it('should render reviewed date when sorting by it', async () => {
227
227
  const model: Partial<TileModel> = {
228
- dateAdded: new Date('2010-01-02'),
229
- dateArchived: new Date('2011-01-02'),
230
- datePublished: new Date('2012-01-02'),
231
- dateReviewed: new Date('2013-01-02'),
228
+ dateAdded: new Date(2010, 0, 2),
229
+ dateArchived: new Date(2011, 0, 2),
230
+ datePublished: new Date(2012, 0, 2),
231
+ dateReviewed: new Date(2013, 0, 2),
232
232
  };
233
233
 
234
234
  const el = await fixture<ItemTile>(html`
@@ -41,7 +41,7 @@ describe('List Tile Compact', () => {
41
41
  const el = await fixture<TileListCompact>(html`
42
42
  <tile-list-compact
43
43
  .baseNavigationUrl=${''}
44
- .model=${{ title: 'foo', href: '/foo/bar' }}
44
+ .model=${{ identifier: 'id', title: 'foo', href: '/foo/bar' }}
45
45
  ></tile-list-compact>
46
46
  `);
47
47
 
@@ -78,10 +78,10 @@ describe('List Tile Compact', () => {
78
78
 
79
79
  it('should render published date when sorting by it', async () => {
80
80
  const model: Partial<TileModel> = {
81
- dateAdded: new Date('2010-01-02'),
82
- dateArchived: new Date('2011-01-02'),
83
- datePublished: new Date('2012-01-02'),
84
- dateReviewed: new Date('2013-01-02'),
81
+ dateAdded: new Date(2010, 0, 2),
82
+ dateArchived: new Date(2011, 0, 2),
83
+ datePublished: new Date(2012, 0, 2),
84
+ dateReviewed: new Date(2013, 0, 2),
85
85
  };
86
86
 
87
87
  const el = await fixture<TileListCompact>(html`
@@ -99,10 +99,10 @@ describe('List Tile Compact', () => {
99
99
 
100
100
  it('should render added date when sorting by it', async () => {
101
101
  const model: Partial<TileModel> = {
102
- dateAdded: new Date('2010-01-02'),
103
- dateArchived: new Date('2011-01-02'),
104
- datePublished: new Date('2012-01-02'),
105
- dateReviewed: new Date('2013-01-02'),
102
+ dateAdded: new Date(2010, 0, 2),
103
+ dateArchived: new Date(2011, 0, 2),
104
+ datePublished: new Date(2012, 0, 2),
105
+ dateReviewed: new Date(2013, 0, 2),
106
106
  };
107
107
 
108
108
  const el = await fixture<TileListCompact>(html`
@@ -120,10 +120,10 @@ describe('List Tile Compact', () => {
120
120
 
121
121
  it('should render archived date when sorting by it', async () => {
122
122
  const model: Partial<TileModel> = {
123
- dateAdded: new Date('2010-01-02'),
124
- dateArchived: new Date('2011-01-02'),
125
- datePublished: new Date('2012-01-02'),
126
- dateReviewed: new Date('2013-01-02'),
123
+ dateAdded: new Date(2010, 0, 2),
124
+ dateArchived: new Date(2011, 0, 2),
125
+ datePublished: new Date(2012, 0, 2),
126
+ dateReviewed: new Date(2013, 0, 2),
127
127
  };
128
128
 
129
129
  const el = await fixture<TileListCompact>(html`
@@ -141,10 +141,10 @@ describe('List Tile Compact', () => {
141
141
 
142
142
  it('should render reviewed date when sorting by it', async () => {
143
143
  const model: Partial<TileModel> = {
144
- dateAdded: new Date('2010-01-02'),
145
- dateArchived: new Date('2011-01-02'),
146
- datePublished: new Date('2012-01-02'),
147
- dateReviewed: new Date('2013-01-02'),
144
+ dateAdded: new Date(2010, 0, 2),
145
+ dateArchived: new Date(2011, 0, 2),
146
+ datePublished: new Date(2012, 0, 2),
147
+ dateReviewed: new Date(2013, 0, 2),
148
148
  };
149
149
 
150
150
  const el = await fixture<TileListCompact>(html`
@@ -138,10 +138,10 @@ describe('List Tile', () => {
138
138
 
139
139
  it('should render published date when sorting by it', async () => {
140
140
  const model: Partial<TileModel> = {
141
- dateAdded: new Date('2010-01-02'),
142
- dateArchived: new Date('2011-01-02'),
143
- datePublished: new Date('2012-01-02'),
144
- dateReviewed: new Date('2013-01-02'),
141
+ dateAdded: new Date(2010, 0, 2),
142
+ dateArchived: new Date(2011, 0, 2),
143
+ datePublished: new Date(2012, 0, 2),
144
+ dateReviewed: new Date(2013, 0, 2),
145
145
  };
146
146
 
147
147
  const el = await fixture<TileList>(html`
@@ -159,10 +159,10 @@ describe('List Tile', () => {
159
159
 
160
160
  it('should render added date when sorting by it', async () => {
161
161
  const model: Partial<TileModel> = {
162
- dateAdded: new Date('2010-01-02'),
163
- dateArchived: new Date('2011-01-02'),
164
- datePublished: new Date('2012-01-02'),
165
- dateReviewed: new Date('2013-01-02'),
162
+ dateAdded: new Date(2010, 0, 2),
163
+ dateArchived: new Date(2011, 0, 2),
164
+ datePublished: new Date(2012, 0, 2),
165
+ dateReviewed: new Date(2013, 0, 2),
166
166
  };
167
167
 
168
168
  const el = await fixture<TileList>(html`
@@ -180,10 +180,10 @@ describe('List Tile', () => {
180
180
 
181
181
  it('should render archived date when sorting by it', async () => {
182
182
  const model: Partial<TileModel> = {
183
- dateAdded: new Date('2010-01-02'),
184
- dateArchived: new Date('2011-01-02'),
185
- datePublished: new Date('2012-01-02'),
186
- dateReviewed: new Date('2013-01-02'),
183
+ dateAdded: new Date(2010, 0, 2),
184
+ dateArchived: new Date(2011, 0, 2),
185
+ datePublished: new Date(2012, 0, 2),
186
+ dateReviewed: new Date(2013, 0, 2),
187
187
  };
188
188
 
189
189
  const el = await fixture<TileList>(html`
@@ -201,10 +201,10 @@ describe('List Tile', () => {
201
201
 
202
202
  it('should render reviewed date when sorting by it', async () => {
203
203
  const model: Partial<TileModel> = {
204
- dateAdded: new Date('2010-01-02'),
205
- dateArchived: new Date('2011-01-02'),
206
- datePublished: new Date('2012-01-02'),
207
- dateReviewed: new Date('2013-01-02'),
204
+ dateAdded: new Date(2010, 0, 2),
205
+ dateArchived: new Date(2011, 0, 2),
206
+ datePublished: new Date(2012, 0, 2),
207
+ dateReviewed: new Date(2013, 0, 2),
208
208
  };
209
209
 
210
210
  const el = await fixture<TileList>(html`
@@ -1,7 +1,7 @@
1
1
  import { expect } from '@open-wc/testing';
2
2
  import { formatDate } from '../../src/utils/format-date';
3
3
 
4
- const testDate = new Date(Date.UTC(2020, 11, 9));
4
+ const testDate = new Date(2020, 11, 9);
5
5
 
6
6
  describe('formatDate', () => {
7
7
  it('returns blank when undefined date', () => {