@internetarchive/ia-item-navigator 0.0.0-a14 → 0.0.0-a16

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,18 +4,18 @@ import Sinon from 'sinon';
4
4
 
5
5
  import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
6
6
  import { ModalManager } from '@internetarchive/modal-manager';
7
- import { BookNavigator } from '../src/interfaces/nav-controller-interface';
7
+ import { CustomTheaterInterface } from '../src/interfaces/custom-theater-interface';
8
8
  import { ItemNavigator, ItemType } from '../src/item-navigator';
9
9
  import '../src/item-navigator';
10
10
 
11
11
  import '../test/book-nav-stub';
12
12
  import { ItemStub, menuProvider, shortcut } from '../test/ia-stub';
13
13
  import {
14
- IntManageFullscreenEvent,
15
- IntManageSideMenuEvent,
16
- IntSetMenuContentsEvent,
17
- IntSetMenuShortcutsEvent,
18
- IntSetOpenMenuEvent,
14
+ ManageFullscreenEvent,
15
+ ToggleSideMenuOpenEvent,
16
+ SetSideMenuContentsEvent,
17
+ SetSideMenuShortcutsEvent,
18
+ ToggleSidePanelOpenEvent,
19
19
  } from '../src/interfaces/event-interfaces';
20
20
 
21
21
  afterEach(() => {
@@ -48,7 +48,7 @@ describe('ItemNavigator', () => {
48
48
 
49
49
  const bookNavigator = el.shadowRoot?.querySelector(
50
50
  'book-navigator'
51
- ) as BookNavigator;
51
+ ) as CustomTheaterInterface;
52
52
  await bookNavigator.updateComplete;
53
53
 
54
54
  console.log('132234234324324324');
@@ -57,7 +57,6 @@ describe('ItemNavigator', () => {
57
57
  expect(bookNavigator).to.exist;
58
58
  expect(bookNavigator?.modal).to.exist;
59
59
  expect(bookNavigator?.baseHost).to.exist;
60
- expect(bookNavigator?.book).to.exist;
61
60
  expect(bookNavigator?.signedIn).to.be.null;
62
61
  expect(bookNavigator?.sharedObserver).to.exist;
63
62
  expect(bookNavigator?.sideMenuOpen).to.exist;
@@ -131,7 +130,6 @@ describe('ItemNavigator', () => {
131
130
  it('freshly registers handler', async () => {
132
131
  const sharedObserver = new SharedResizeObserver();
133
132
  const addObserverSpy = Sinon.spy(sharedObserver, 'addObserver');
134
- const removeObserverSpy = Sinon.spy(sharedObserver, 'removeObserver');
135
133
 
136
134
  await fixture<ItemNavigator>(
137
135
  html`<ia-item-navigator
@@ -139,8 +137,6 @@ describe('ItemNavigator', () => {
139
137
  ></ia-item-navigator>`
140
138
  );
141
139
 
142
- // always calls to remove first, for posterity
143
- expect(removeObserverSpy.callCount).to.equal(1);
144
140
  expect(addObserverSpy.callCount).to.equal(1);
145
141
  });
146
142
  it('removes handler when component disconnects', async () => {
@@ -153,13 +149,10 @@ describe('ItemNavigator', () => {
153
149
  ></ia-item-navigator>`
154
150
  );
155
151
 
156
- // called during setup `setResizeObserver`
157
- expect(removeObserverSpy.callCount).to.equal(1);
158
-
159
152
  el.disconnectedCallback();
160
153
  await el.updateComplete;
161
154
 
162
- expect(removeObserverSpy.callCount).to.equal(2);
155
+ expect(removeObserverSpy.callCount).to.equal(1);
163
156
  });
164
157
  it('sets menu to overlay if container width is <= 600px', async () => {
165
158
  const el = await fixture<ItemNavigator>(
@@ -219,7 +212,7 @@ describe('ItemNavigator', () => {
219
212
  detail: {
220
213
  isFullScreen: true,
221
214
  },
222
- } as IntManageFullscreenEvent;
215
+ } as ManageFullscreenEvent;
223
216
  el.manageViewportFullscreen(yesFullscreenEvent);
224
217
  await el.updateComplete;
225
218
  expect(el.viewportInFullscreen).to.be.true;
@@ -228,7 +221,7 @@ describe('ItemNavigator', () => {
228
221
  detail: {
229
222
  isFullScreen: false,
230
223
  },
231
- } as IntManageFullscreenEvent;
224
+ } as ManageFullscreenEvent;
232
225
  el.manageViewportFullscreen(noFullscreenEvent);
233
226
  await el.updateComplete;
234
227
  expect(el.viewportInFullscreen).to.be.null;
@@ -280,12 +273,12 @@ describe('ItemNavigator', () => {
280
273
  expect(frame?.getAttribute('class')).to.contain('shift');
281
274
 
282
275
  expect(el.menuOpened).to.be.false;
283
- expect(el.openMenu).to.be.empty;
276
+ expect(el.openMenu).to.be.undefined;
284
277
  expect(frame?.getAttribute('class')).to.not.contain('open');
285
278
 
286
279
  const event = new CustomEvent('updateSideMenu', {
287
280
  detail,
288
- }) as IntManageSideMenuEvent;
281
+ }) as ToggleSideMenuOpenEvent;
289
282
  el.manageSideMenuEvents(event);
290
283
  await el.updateComplete;
291
284
 
@@ -386,7 +379,7 @@ describe('ItemNavigator', () => {
386
379
 
387
380
  el.setMenuShortcuts({
388
381
  detail: menuShortcuts,
389
- } as IntSetMenuShortcutsEvent);
382
+ } as SetSideMenuShortcutsEvent);
390
383
  await el.updateComplete;
391
384
 
392
385
  expect(el.menuShortcuts.length).to.equal(1);
@@ -399,7 +392,7 @@ describe('ItemNavigator', () => {
399
392
 
400
393
  el.setMenuShortcuts({
401
394
  detail: [menuProvider],
402
- } as IntSetMenuContentsEvent);
395
+ } as SetSideMenuContentsEvent);
403
396
  await el.updateComplete;
404
397
 
405
398
  expect(el.menuShortcuts.length).to.equal(1);
@@ -411,18 +404,20 @@ describe('ItemNavigator', () => {
411
404
 
412
405
  el.setOpenMenu({
413
406
  detail: { id: 'foo' },
414
- } as IntSetOpenMenuEvent);
407
+ } as ToggleSidePanelOpenEvent);
415
408
  await el.updateComplete;
416
409
 
417
410
  expect(el.openMenu).to.equal('foo');
411
+ expect(el.selectedMenuId).to.equal('foo');
418
412
 
419
413
  // toggles it off
420
414
  el.setOpenMenu({
421
415
  detail: { id: 'foo' },
422
- } as IntSetOpenMenuEvent);
416
+ } as ToggleSidePanelOpenEvent);
423
417
  await el.updateComplete;
424
418
 
425
- expect(el.openMenu).to.equal('');
419
+ expect(el.openMenu).to.be.undefined;
420
+ expect(el.selectedMenuId).to.equal('');
426
421
  });
427
422
  it('`el.closeMenu`', async () => {
428
423
  const el = await fixture<ItemNavigator>(
package/test/ia-stub.ts CHANGED
@@ -8,8 +8,8 @@ import {
8
8
  } from '@internetarchive/search-service';
9
9
  import { html } from 'lit-html';
10
10
  import {
11
- IntMenuShortcut,
12
- IntMenuProvider,
11
+ MenuShortcutInterface,
12
+ MenuProviderInterface,
13
13
  } from '../src/interfaces/menu-interfaces';
14
14
 
15
15
  export class ItemStub implements MetadataResponse {
@@ -63,7 +63,7 @@ export class ItemStub implements MetadataResponse {
63
63
  export const shortcut = {
64
64
  id: 'fullscreen',
65
65
  icon: html`<i class="fas fullscreen-test"></i>`,
66
- } as IntMenuShortcut;
66
+ } as MenuShortcutInterface;
67
67
 
68
68
  export const menuProvider = {
69
69
  ...shortcut,
@@ -76,4 +76,4 @@ export const menuProvider = {
76
76
  baseHost: 'https://archive.foo',
77
77
  subPrefix: 'bar',
78
78
  updated: () => {},
79
- } as IntMenuProvider;
79
+ } as MenuProviderInterface;