@internetarchive/bookreader 5.0.0-43 → 5.0.0-44-a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. package/BookReader/BookReader.css +1 -2
  2. package/BookReader/BookReader.js +1 -1
  3. package/BookReader/BookReader.js.map +1 -1
  4. package/BookReader/ia-bookreader-bundle.js +35 -35
  5. package/BookReader/ia-bookreader-bundle.js.map +1 -1
  6. package/BookReader/plugins/plugin.tts.js +1 -1
  7. package/BookReader/plugins/plugin.tts.js.map +1 -1
  8. package/BookReaderDemo/IADemoBr.js +30 -0
  9. package/BookReaderDemo/demo-internetarchive.html +3 -0
  10. package/babel.config.js +1 -1
  11. package/package.json +10 -16
  12. package/renovate.json +7 -4
  13. package/src/BookNavigator/book-navigator.js +4 -0
  14. package/src/BookNavigator/downloads/downloads-provider.js +14 -5
  15. package/src/BookNavigator/downloads/downloads.js +23 -1
  16. package/src/css/_controls.scss +1 -2
  17. package/src/plugins/tts/plugin.tts.js +15 -3
  18. package/tests/{karma → jest}/BookNavigator/book-navigator.test.js +119 -104
  19. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-button.test.js +13 -14
  20. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
  21. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
  22. package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
  23. package/tests/{karma → jest}/BookNavigator/downloads/downloads-provider.test.js +18 -18
  24. package/tests/{karma → jest}/BookNavigator/downloads/downloads.test.js +7 -8
  25. package/tests/{karma → jest}/BookNavigator/sharing/sharing-provider.test.js +8 -8
  26. package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
  27. package/tests/{karma → jest}/BookNavigator/volumes/volumes-provider.test.js +38 -38
  28. package/tests/{karma → jest}/BookNavigator/volumes/volumes.test.js +15 -16
  29. package/tests/jest/plugins/tts/AbstractTTSEngine.test.js +3 -3
  30. package/karma.conf.js +0 -23
  31. package/tests/karma/BookNavigator/bookmarks/ia-bookmarks.test.js +0 -57
  32. package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
@@ -3,17 +3,16 @@ import {
3
3
  elementUpdated,
4
4
  fixtureCleanup,
5
5
  fixtureSync,
6
- expect,
7
- } from '@open-wc/testing';
6
+ } from '@open-wc/testing-helpers';
8
7
  import sinon from 'sinon';
9
- import DownloadsProvider from '../../../src/BookNavigator/downloads/downloads-provider.js';
10
- import SearchProvider from '../../../src/BookNavigator/search/search-provider.js';
11
- import SharingProvider from '../../../src/BookNavigator/sharing.js';
12
- import VisualAdjustmentsProvider from '../../../src/BookNavigator/visual-adjustments/visual-adjustments-provider.js';
13
- import VolumesProvider from '../../../src/BookNavigator/volumes/volumes-provider.js';
8
+ import DownloadsProvider from '@/src/BookNavigator/downloads/downloads-provider.js';
9
+ import SearchProvider from '@/src/BookNavigator/search/search-provider.js';
10
+ import SharingProvider from '@/src/BookNavigator/sharing.js';
11
+ import VisualAdjustmentsProvider from '@/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js';
12
+ import VolumesProvider from '@/src/BookNavigator/volumes/volumes-provider.js';
14
13
  import { ModalManager } from '@internetarchive/modal-manager';
15
14
  import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
16
- import '../../../src/BookNavigator/book-navigator.js';
15
+ import '@/src/BookNavigator/book-navigator.js';
17
16
 
18
17
  const promise0 = () => new Promise(res => setTimeout(res, 0));
19
18
 
@@ -41,6 +40,12 @@ const container = (sharedObserver = null) => {
41
40
  `;
42
41
  };
43
42
 
43
+ window.ResizeObserver = class ResizeObserver {
44
+ observe = sinon.fake()
45
+ unobserve = sinon.fake()
46
+ disconnect = sinon.fake()
47
+ };
48
+
44
49
  afterEach(() => {
45
50
  window.br = null;
46
51
  fixtureCleanup();
@@ -53,19 +58,20 @@ afterEach(() => {
53
58
  describe('<book-navigator>', () => {
54
59
  describe("How it loads", () => {
55
60
  describe('Attaches BookReader listeners before `br.init` is called', () => {
56
- it('binds global event listeners', async () => {
61
+ test('binds global event listeners', async () => {
57
62
  const el = fixtureSync(container());
58
63
  const spy = sinon.spy(el, 'bindEventListeners');
59
64
  await elementUpdated(el);
60
- expect(spy.callCount).to.equal(1);
65
+ expect(spy.callCount).toEqual(1);
61
66
  });
62
- it('Listens for Global Event @BookReader:PostInit', async () => {
67
+ test('Listens for Global Event @BookReader:PostInit', async () => {
63
68
  const brStub = {
64
69
  resize: sinon.fake(),
65
70
  currentIndex: sinon.fake(),
66
71
  jumpToIndex: sinon.fake(),
67
72
  options: { enableMultipleBooks: false }, // for multipleBooks
68
- el: '#BookReader'
73
+ el: '#BookReader',
74
+ refs: {}
69
75
  };
70
76
 
71
77
  const sharedObserver = new SharedResizeObserver();
@@ -77,25 +83,25 @@ describe('<book-navigator>', () => {
77
83
  el.handleResize = sinon.fake();
78
84
  await elementUpdated(el);
79
85
 
80
- expect(brStub.resize.callCount).to.equal(0);
86
+ expect(brStub.resize.callCount).toEqual(0);
81
87
 
82
88
  window.dispatchEvent(new CustomEvent('BookReader:PostInit', {
83
89
  detail: { props: brStub }
84
90
  }));
85
91
  await elementUpdated(el);
86
92
 
87
- expect(el.emitLoadingStatusUpdate.callCount).to.equal(1);
88
- expect(el.bookreader).to.equal(brStub); // sets bookreader
89
- expect(el.bookReaderLoaded).to.be.true; // notes bookreader is loaded
90
- expect(el.bookReaderCannotLoad).to.be.false;
91
- expect(sharedObserver.addObserver.callCount).to.equal(1);
93
+ expect(el.emitLoadingStatusUpdate.callCount).toEqual(1);
94
+ expect(el.bookreader).toEqual(brStub); // sets bookreader
95
+ expect(el.bookReaderLoaded).toBeTruthy(); // notes bookreader is loaded
96
+ expect(el.bookReaderCannotLoad).toBeFalsy();
97
+ expect(sharedObserver.addObserver.callCount).toEqual(1);
92
98
 
93
99
  await promise0();
94
100
 
95
- expect(brStub.resize.callCount > 0).to.be.true;
101
+ expect(brStub.resize.callCount > 0).toBeTruthy();
96
102
  });
97
103
  });
98
- it('Emits a BrBookNav:PostInit event at completion', async () => {
104
+ test('Emits a BrBookNav:PostInit event at completion', async () => {
99
105
  let initEventFired = false;
100
106
  window.addEventListener('BrBookNav:PostInit', (e) => {
101
107
  initEventFired = true;
@@ -105,22 +111,22 @@ describe('<book-navigator>', () => {
105
111
 
106
112
  await elementUpdated(el);
107
113
 
108
- expect(initEventFired).to.be.true;
109
- expect(spy.callCount).to.equal(1);
114
+ expect(initEventFired).toBeTruthy();
115
+ expect(spy.callCount).toEqual(1);
110
116
  });
111
117
 
112
- it('creates an item image from metadata', async () => {
118
+ test('creates an item image from metadata', async () => {
113
119
  const el = fixtureSync(container());
114
120
  const itemImage = fixtureSync(el.itemImage);
115
- expect(itemImage).to.be.instanceOf(HTMLImageElement);
116
- expect(itemImage.getAttribute('class')).to.equal('cover-img');
117
- expect(itemImage.getAttribute('src')).to.equal('https://https://foo.archive.org/services/img/foo');
121
+ expect(itemImage).toBeInstanceOf(HTMLImageElement);
122
+ expect(itemImage.getAttribute('class')).toEqual('cover-img');
123
+ expect(itemImage.getAttribute('src')).toEqual('https://https://foo.archive.org/services/img/foo');
118
124
  });
119
125
  });
120
126
  describe('Menu/Layer Provider', () => {
121
127
  describe('Connecting with a provider:', () => {
122
128
  // loads Providers with base shared resources
123
- it('We load 3 Sub Menus by default', async() => {
129
+ test('We load 3 Sub Menus by default', async() => {
124
130
  const el = fixtureSync(container());
125
131
  const $brContainer = document.createElement('div');
126
132
  const brStub = {
@@ -138,17 +144,17 @@ describe('<book-navigator>', () => {
138
144
  el.initializeBookSubmenus();
139
145
  await el.elementUpdated;
140
146
  const defaultMenus = Object.keys(el.menuProviders);
141
- expect(defaultMenus).to.contain('downloads');
142
- expect(el.menuProviders.downloads).to.be.instanceOf(DownloadsProvider);
147
+ expect(defaultMenus).toContain('downloads');
148
+ expect(el.menuProviders.downloads).toBeInstanceOf(DownloadsProvider);
143
149
 
144
- expect(defaultMenus).to.contain('share');
145
- expect(el.menuProviders.share).to.be.instanceOf(SharingProvider);
150
+ expect(defaultMenus).toContain('share');
151
+ expect(el.menuProviders.share).toBeInstanceOf(SharingProvider);
146
152
 
147
- expect(defaultMenus).to.contain('visualAdjustments');
148
- expect(el.menuProviders.visualAdjustments).to.be.instanceOf(VisualAdjustmentsProvider);
153
+ expect(defaultMenus).toContain('visualAdjustments');
154
+ expect(el.menuProviders.visualAdjustments).toBeInstanceOf(VisualAdjustmentsProvider);
149
155
  });
150
- describe('Loading Sub Menus By Plugin Flags', async() => {
151
- it('Search: uses `enableSearch` flag', async() => {
156
+ describe('Loading Sub Menus By Plugin Flags', () => {
157
+ test('Search: uses `enableSearch` flag', async() => {
152
158
  const el = fixtureSync(container());
153
159
  const $brContainer = document.createElement('div');
154
160
  const brStub = {
@@ -166,13 +172,13 @@ describe('<book-navigator>', () => {
166
172
  el.initializeBookSubmenus();
167
173
  await el.elementUpdated;
168
174
 
169
- expect(el.menuProviders.search).to.exist;
170
- expect(el.menuProviders.search).to.be.instanceOf(SearchProvider);
175
+ expect(el.menuProviders.search).toBeDefined();
176
+ expect(el.menuProviders.search).toBeInstanceOf(SearchProvider);
171
177
 
172
178
  // also adds a menu shortcut
173
- expect(el.menuShortcuts.find(m => m.id === 'search')).to.exist;
179
+ expect(el.menuShortcuts.find(m => m.id === 'search')).toBeDefined();
174
180
  });
175
- it('Volumes/Multiple Books: uses `enableMultipleBooks` flag', async() => {
181
+ test('Volumes/Multiple Books: uses `enableMultipleBooks` flag', async() => {
176
182
  const el = fixtureSync(container());
177
183
  const $brContainer = document.createElement('div');
178
184
  const brStub = {
@@ -197,49 +203,50 @@ describe('<book-navigator>', () => {
197
203
  el.initializeBookSubmenus();
198
204
  await el.elementUpdated;
199
205
 
200
- expect(el.menuProviders.volumes).to.exist;
201
- expect(el.menuProviders.volumes).to.be.instanceOf(VolumesProvider);
206
+ expect(el.menuProviders.volumes).toBeDefined();
207
+ expect(el.menuProviders.volumes).toBeInstanceOf(VolumesProvider);
202
208
 
203
209
  // also adds a menu shortcut
204
- expect(el.menuShortcuts.find(m => m.id === 'volumes')).to.be.exist;
210
+ expect(el.menuShortcuts.find(m => m.id === 'volumes')).toBeDefined();
205
211
  });
206
212
  });
207
- it('keeps track of base shared resources for providers in: `baseProviderConfig`', () => {
213
+ test('keeps track of base shared resources for providers in: `baseProviderConfig`', () => {
208
214
  const el = fixtureSync(container());
209
215
  const baseConfigKeys = Object.keys(el.baseProviderConfig);
210
- expect(baseConfigKeys).to.contain('baseHost');
211
- expect(baseConfigKeys).to.contain('modal');
212
- expect(baseConfigKeys).to.contain('sharedObserver');
213
- expect(baseConfigKeys).to.contain('bookreader');
214
- expect(baseConfigKeys).to.contain('item');
215
- expect(baseConfigKeys).to.contain('signedIn');
216
- expect(baseConfigKeys).to.contain('isAdmin');
217
- expect(baseConfigKeys).to.contain('onProviderChange');
216
+ expect(baseConfigKeys).toContain('baseHost');
217
+ expect(baseConfigKeys).toContain('modal');
218
+ expect(baseConfigKeys).toContain('sharedObserver');
219
+ expect(baseConfigKeys).toContain('bookreader');
220
+ expect(baseConfigKeys).toContain('item');
221
+ expect(baseConfigKeys).toContain('signedIn');
222
+ expect(baseConfigKeys).toContain('isAdmin');
223
+ expect(baseConfigKeys).toContain('onProviderChange');
218
224
  });
219
225
  });
220
226
 
221
227
  describe('Controlling Menu Side Panel & Shortcuts', () => {
222
228
  describe('Side Menu Panels', () => {
223
- it('`isWideEnoughToOpenMenu` checks if menu should be open', async () => {
229
+ test('`isWideEnoughToOpenMenu` checks if menu should be open', async () => {
224
230
  const el = fixtureSync(container());
225
231
  el.brWidth = 300;
226
232
  await el.elementUpdated;
227
233
 
228
- expect(el.isWideEnoughToOpenMenu).to.equal(false);
234
+ expect(el.isWideEnoughToOpenMenu).toEqual(false);
229
235
 
230
236
  el.brWidth = 641;
231
237
  await el.elementUpdated;
232
238
 
233
- expect(el.isWideEnoughToOpenMenu).to.equal(true);
239
+ expect(el.isWideEnoughToOpenMenu).toEqual(true);
234
240
  });
235
241
  describe('Control which side menu to toggle open by using: `this.updateSideMenu`', () => {
236
- it('Emits `@updateSideMenu` to signal which menu gets the update', async () => {
242
+ test('Emits `@updateSideMenu` to signal which menu gets the update', async () => {
237
243
  const el = fixtureSync(container());
238
244
  const brStub = {
239
245
  resize: sinon.fake(),
240
246
  currentIndex: sinon.fake(),
241
247
  jumpToIndex: sinon.fake(),
242
- options: { enableMultipleBooks: true }
248
+ options: { enableMultipleBooks: true },
249
+ refs: {},
243
250
  };
244
251
  el.bookreader = brStub;
245
252
  await elementUpdated(el);
@@ -252,17 +259,18 @@ describe('<book-navigator>', () => {
252
259
  });
253
260
 
254
261
  el.updateSideMenu('foo', 'open');
255
- expect(initEventFired).to.equal(true);
256
- expect(eventDetails.menuId).to.equal('foo');
257
- expect(eventDetails.action).to.equal('open');
262
+ expect(initEventFired).toEqual(true);
263
+ expect(eventDetails.menuId).toEqual('foo');
264
+ expect(eventDetails.action).toEqual('open');
258
265
  });
259
- it('Will Not Emit `@updateSideMenu` if menu ID is missing', async() => {
266
+ test('Will Not Emit `@updateSideMenu` if menu ID is missing', async() => {
260
267
  const el = fixtureSync(container());
261
268
  const brStub = {
262
269
  resize: sinon.fake(),
263
270
  currentIndex: sinon.fake(),
264
271
  jumpToIndex: sinon.fake(),
265
- options: { enableMultipleBooks: true }
272
+ options: { enableMultipleBooks: true },
273
+ refs: {},
266
274
  };
267
275
  el.bookreader = brStub;
268
276
  await elementUpdated(el);
@@ -273,30 +281,31 @@ describe('<book-navigator>', () => {
273
281
  });
274
282
 
275
283
  el.updateSideMenu('', 'open');
276
- expect(initEventFired).to.equal(false);
284
+ expect(initEventFired).toEqual(false);
277
285
  });
278
286
  });
279
287
  });
280
288
 
281
289
  describe('Shortcuts', () => {
282
- it('has specific order of menu shortcuts to show', () => {
290
+ test('has specific order of menu shortcuts to show', () => {
283
291
  const el = fixtureSync(container());
284
- expect(el.shortcutOrder[0]).to.equal('fullscreen');
285
- expect(el.shortcutOrder[1]).to.equal('volumes');
286
- expect(el.shortcutOrder[2]).to.equal('search');
287
- expect(el.shortcutOrder[3]).to.equal('bookmarks');
292
+ expect(el.shortcutOrder[0]).toEqual('fullscreen');
293
+ expect(el.shortcutOrder[1]).toEqual('volumes');
294
+ expect(el.shortcutOrder[2]).toEqual('search');
295
+ expect(el.shortcutOrder[3]).toEqual('bookmarks');
288
296
  });
289
297
  });
290
298
 
291
299
  describe('Behaviors for specific menus', () => {
292
300
  describe('Search menu - ref: plugin.search.js', () => {
293
- it('Event: listens for `BookReader:ToggleSearchMenu to open search side panel', async () => {
301
+ test('Event: listens for `BookReader:ToggleSearchMenu to open search side panel', async () => {
294
302
  const el = fixtureSync(container());
295
303
  const brStub = {
296
304
  resize: sinon.fake(),
297
305
  currentIndex: sinon.fake(),
298
306
  jumpToIndex: sinon.fake(),
299
- options: { enableMultipleBooks: true }
307
+ options: { enableMultipleBooks: true },
308
+ refs: {},
300
309
  };
301
310
  el.bookreader = brStub;
302
311
  await elementUpdated(el);
@@ -310,8 +319,8 @@ describe('<book-navigator>', () => {
310
319
  window.dispatchEvent(toggleSearchMenuEvent);
311
320
 
312
321
  await elementUpdated(el);
313
- expect(sidePanelConfig.menuId).to.equal('search');
314
- expect(sidePanelConfig.action).to.equal('toggle');
322
+ expect(sidePanelConfig.menuId).toEqual('search');
323
+ expect(sidePanelConfig.action).toEqual('toggle');
315
324
  });
316
325
  });
317
326
  });
@@ -319,7 +328,7 @@ describe('<book-navigator>', () => {
319
328
  });
320
329
 
321
330
  describe('Resizing',() => {
322
- it('keeps track of `brWidth` and `brHeight`', async () => {
331
+ test('keeps track of `brWidth` and `brHeight`', async () => {
323
332
  const el = fixtureSync(container());
324
333
  const brStub = {
325
334
  resize: sinon.fake(),
@@ -330,8 +339,8 @@ describe('<book-navigator>', () => {
330
339
  };
331
340
  el.bookreader = brStub;
332
341
  await elementUpdated(el);
333
- expect(el.brWidth).to.equal(0);
334
- expect(el.brHeight).to.equal(0);
342
+ expect(el.brWidth).toEqual(0);
343
+ expect(el.brHeight).toEqual(0);
335
344
 
336
345
  const mockResizeEvent = {
337
346
  contentRect: {
@@ -345,10 +354,10 @@ describe('<book-navigator>', () => {
345
354
  await elementUpdated(el);
346
355
  await promise0();
347
356
 
348
- expect(el.brHeight).to.equal(500);
349
- expect(el.brWidth).to.equal(900);
357
+ expect(el.brHeight).toEqual(500);
358
+ expect(el.brWidth).toEqual(900);
350
359
  });
351
- it('resizes if height/width changes && is not animating', async () => {
360
+ test('resizes if height/width changes && is not animating', async () => {
352
361
  const el = fixtureSync(container());
353
362
  const brStub = {
354
363
  animating: false,
@@ -361,8 +370,8 @@ describe('<book-navigator>', () => {
361
370
 
362
371
  el.bookreader = brStub;
363
372
  await elementUpdated(el);
364
- expect(el.brWidth).to.equal(0);
365
- expect(el.brHeight).to.equal(0);
373
+ expect(el.brWidth).toEqual(0);
374
+ expect(el.brHeight).toEqual(0);
366
375
 
367
376
  const mockResizeEvent = {
368
377
  contentRect: {
@@ -376,35 +385,37 @@ describe('<book-navigator>', () => {
376
385
  await elementUpdated(el);
377
386
  await promise0();
378
387
 
379
- expect(brStub.resize.callCount).to.equal(1);
388
+ expect(brStub.resize.callCount).toEqual(1);
380
389
  });
381
- it('does not resize bookreader if animating', async () => {
390
+ test('does not resize bookreader if animating', async () => {
382
391
  const el = fixtureSync(container());
383
392
  const brStub = {
384
393
  animating: true, // <-- testing for this
385
394
  resize: sinon.fake(),
386
395
  currentIndex: sinon.fake(),
387
396
  jumpToIndex: sinon.fake(),
388
- options: { enableMultipleBooks: true }
397
+ options: { enableMultipleBooks: true },
398
+ refs: {},
389
399
  };
390
400
 
391
401
  el.bookreader = brStub;
392
402
  await elementUpdated(el);
393
403
 
394
- expect(el.bookreader.resize.callCount).to.equal(0);
395
- expect(el.bookreader.currentIndex.callCount).to.equal(0);
396
- expect(el.bookreader.jumpToIndex.callCount).to.equal(0);
404
+ expect(el.bookreader.resize.callCount).toEqual(0);
405
+ expect(el.bookreader.currentIndex.callCount).toEqual(0);
406
+ expect(el.bookreader.jumpToIndex.callCount).toEqual(0);
397
407
  });
398
408
  });
399
409
 
400
410
  describe('Fullscreen Management', () => {
401
- it('needs option: `enableFSLogoShortcut` to use FS logo', async () => {
411
+ test('needs option: `enableFSLogoShortcut` to use FS logo', async () => {
402
412
  const el = fixtureSync(container());
403
413
  const brStub = {
404
414
  isFullscreen: () => true,
405
415
  options: {
406
416
  enableFSLogoShortcut: false,
407
- }
417
+ },
418
+ refs: {},
408
419
  };
409
420
 
410
421
  el.bookreader = brStub;
@@ -413,15 +424,16 @@ describe('<book-navigator>', () => {
413
424
 
414
425
  el.manageFullScreenBehavior();
415
426
  await elementUpdated(el);
416
- expect(el.menuShortcuts.length).to.equal(0);
427
+ expect(el.menuShortcuts.length).toEqual(0);
417
428
  });
418
- it('sets fullscreen shortcut when entering Fullscreen', async () => {
429
+ test('sets fullscreen shortcut when entering Fullscreen', async () => {
419
430
  const el = fixtureSync(container());
420
431
  const brStub = {
421
432
  isFullscreen: () => true,
422
433
  options: {
423
434
  enableFSLogoShortcut: true,
424
- }
435
+ },
436
+ refs: {},
425
437
  };
426
438
 
427
439
  el.bookreader = brStub;
@@ -430,18 +442,19 @@ describe('<book-navigator>', () => {
430
442
 
431
443
  el.manageFullScreenBehavior();
432
444
  await elementUpdated(el);
433
- expect(el.menuShortcuts.length).to.equal(1);
434
- expect(el.menuShortcuts[0].id).to.equal('fullscreen');
435
- expect(el.menuShortcuts[0].icon).to.exist;
436
- expect(el.emitMenuShortcutsUpdated.callCount).to.equal(1);
445
+ expect(el.menuShortcuts.length).toEqual(1);
446
+ expect(el.menuShortcuts[0].id).toEqual('fullscreen');
447
+ expect(el.menuShortcuts[0].icon).toBeDefined();
448
+ expect(el.emitMenuShortcutsUpdated.callCount).toEqual(1);
437
449
  });
438
- it('clicking Fullscreen shortcut closes fullscreen', async () => {
450
+ test('clicking Fullscreen shortcut closes fullscreen', async () => {
439
451
  const el = fixtureSync(container());
440
452
  const brStub = {
441
453
  isFullscreen: () => true,
442
454
  options: {
443
455
  enableFSLogoShortcut: true,
444
- }
456
+ },
457
+ refs: {},
445
458
  };
446
459
 
447
460
  el.bookreader = brStub;
@@ -455,15 +468,16 @@ describe('<book-navigator>', () => {
455
468
  fixtureSync(el.menuShortcuts[0].icon).click();
456
469
  await elementUpdated(el);
457
470
 
458
- expect(el.closeFullscreen.callCount).to.equal(1);
471
+ expect(el.closeFullscreen.callCount).toEqual(1);
459
472
  });
460
- it('removes Fullscreen shortcut when leaving fullscreen', async() => {
473
+ test('removes Fullscreen shortcut when leaving fullscreen', async() => {
461
474
  const el = fixtureSync(container());
462
475
  const brStub = {
463
476
  isFullscreen: () => false,
464
477
  options: {
465
478
  enableFSLogoShortcut: true,
466
- }
479
+ },
480
+ refs: {},
467
481
  };
468
482
 
469
483
  el.bookreader = brStub;
@@ -472,10 +486,10 @@ describe('<book-navigator>', () => {
472
486
 
473
487
  el.manageFullScreenBehavior();
474
488
  await elementUpdated(el);
475
- expect(el.menuShortcuts.length).to.equal(0);
476
- expect(el.emitMenuShortcutsUpdated.callCount).to.equal(1);
489
+ expect(el.menuShortcuts.length).toEqual(0);
490
+ expect(el.emitMenuShortcutsUpdated.callCount).toEqual(1);
477
491
  });
478
- it('Event: Listens for `BookReader:FullscreenToggled', async() => {
492
+ test('Event: Listens for `BookReader:FullscreenToggled', async() => {
479
493
  const el = fixtureSync(container());
480
494
  const brStub = {
481
495
  isFullscreen: () => true,
@@ -484,7 +498,8 @@ describe('<book-navigator>', () => {
484
498
  jumpToIndex: sinon.fake(),
485
499
  options: {
486
500
  enableFSLogoShortcut: true,
487
- }
501
+ },
502
+ refs: {},
488
503
  };
489
504
  el.bookreader = brStub;
490
505
  el.manageFullScreenBehavior = sinon.fake();
@@ -495,7 +510,7 @@ describe('<book-navigator>', () => {
495
510
  }));
496
511
  await elementUpdated(el);
497
512
 
498
- expect(el.manageFullScreenBehavior.callCount).to.equal(1);
513
+ expect(el.manageFullScreenBehavior.callCount).toEqual(1);
499
514
  });
500
515
  });
501
516
  });
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  html,
3
3
  fixtureSync,
4
- expect,
5
4
  fixtureCleanup,
6
- } from '@open-wc/testing';
7
- import '../../../../src/BookNavigator/bookmarks/bookmark-button.js';
5
+ } from '@open-wc/testing-helpers';
6
+ import '@/src/BookNavigator/bookmarks/bookmark-button.js';
8
7
  import sinon from 'sinon';
9
8
 
10
9
  afterEach(() => {
@@ -13,13 +12,13 @@ afterEach(() => {
13
12
  });
14
13
 
15
14
  describe('<bookmark-button>', () => {
16
- it('sets default properties', async () => {
15
+ test('sets default properties', async () => {
17
16
  const el = fixtureSync(html`<bookmark-button></bookmark-button>`);
18
17
 
19
- expect(el.side).to.be.undefined;
20
- expect(el.state).to.equal('hollow');
18
+ expect(el.side).toBeUndefined();
19
+ expect(el.state).toEqual('hollow');
21
20
  });
22
- it('Event: fires `@bookmarkButtonClicked on click', async () => {
21
+ test('Event: fires `@bookmarkButtonClicked on click', async () => {
23
22
  const el = fixtureSync(html`<bookmark-button></bookmark-button>`);
24
23
  let buttonClicked = false;
25
24
  el.addEventListener('bookmarkButtonClicked', () => { buttonClicked = true; });
@@ -27,18 +26,18 @@ describe('<bookmark-button>', () => {
27
26
  el.handleClick(eventStub);
28
27
  await el.updateComplete;
29
28
 
30
- expect(buttonClicked).to.be.true;
31
- expect(eventStub.preventDefault.callCount).to.equal(1);
29
+ expect(buttonClicked).toBeTruthy();
30
+ expect(eventStub.preventDefault.callCount).toEqual(1);
32
31
  });
33
- it('Title: Toggles title between `Add/Remove bookmark`', async () => {
32
+ test('Title: Toggles title between `Add/Remove bookmark`', async () => {
34
33
  const el = fixtureSync(html`<bookmark-button></bookmark-button>`);
35
- expect(el.title).to.equal('Add bookmark');
36
- expect(el.state).to.equal('hollow');
34
+ expect(el.title).toEqual('Add bookmark');
35
+ expect(el.state).toEqual('hollow');
37
36
 
38
37
  el.state = 'filled';
39
38
  await el.updateComplete;
40
39
 
41
- expect(el.title).to.equal('Remove bookmark');
42
- expect(el.state).to.not.equal('hollow');
40
+ expect(el.title).toEqual('Remove bookmark');
41
+ expect(el.state).not.toEqual('hollow');
43
42
  });
44
43
  });