@internetarchive/bookreader 5.0.0-58 → 5.0.0-59

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 (50) hide show
  1. package/BookReader/BookReader.css +110 -39
  2. package/BookReader/BookReader.js +1 -1
  3. package/BookReader/BookReader.js.LICENSE.txt +0 -20
  4. package/BookReader/BookReader.js.map +1 -1
  5. package/BookReader/ia-bookreader-bundle.js +1 -1
  6. package/BookReader/ia-bookreader-bundle.js.map +1 -1
  7. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  8. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  9. package/BookReader/plugins/plugin.autoplay.js +1 -1
  10. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  11. package/BookReader/plugins/plugin.resume.js +1 -1
  12. package/BookReader/plugins/plugin.resume.js.map +1 -1
  13. package/BookReader/plugins/plugin.tts.js +1 -1
  14. package/BookReader/plugins/plugin.tts.js.map +1 -1
  15. package/BookReader/plugins/plugin.url.js +1 -1
  16. package/BookReader/plugins/plugin.url.js.map +1 -1
  17. package/BookReaderDemo/BookReaderJSAutoplay.js +4 -1
  18. package/BookReaderDemo/BookReaderJSSimple.js +1 -0
  19. package/BookReaderDemo/IADemoBr.js +1 -2
  20. package/CHANGELOG.md +4 -0
  21. package/package.json +1 -1
  22. package/src/BookReader/BookModel.js +59 -1
  23. package/src/BookReader/Mode1UpLit.js +13 -70
  24. package/src/BookReader/Mode2Up.js +72 -1332
  25. package/src/BookReader/Mode2UpLit.js +774 -0
  26. package/src/BookReader/ModeCoordinateSpace.js +29 -0
  27. package/src/BookReader/ModeSmoothZoom.js +32 -0
  28. package/src/BookReader/options.js +8 -2
  29. package/src/BookReader/utils.js +16 -0
  30. package/src/BookReader.js +24 -217
  31. package/src/css/_BRBookmarks.scss +1 -1
  32. package/src/css/_BRmain.scss +14 -0
  33. package/src/css/_BRpages.scss +113 -41
  34. package/src/plugins/plugin.autoplay.js +1 -6
  35. package/src/plugins/tts/WebTTSEngine.js +2 -2
  36. package/src/plugins/tts/plugin.tts.js +3 -17
  37. package/src/plugins/tts/utils.js +0 -16
  38. package/tests/e2e/helpers/base.js +20 -20
  39. package/tests/e2e/helpers/rightToLeft.js +4 -10
  40. package/tests/e2e/viewmode.test.js +10 -8
  41. package/tests/jest/BookReader/BookModel.test.js +25 -0
  42. package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +28 -11
  43. package/tests/jest/BookReader/Mode1UpLit.test.js +0 -19
  44. package/tests/jest/BookReader/Mode2Up.test.js +55 -225
  45. package/tests/jest/BookReader/Mode2UpLit.test.js +190 -0
  46. package/tests/jest/BookReader/ModeCoordinateSpace.test.js +16 -0
  47. package/tests/jest/BookReader/ModeSmoothZoom.test.js +26 -0
  48. package/tests/jest/BookReader/Navbar/Navbar.test.js +3 -3
  49. package/tests/jest/BookReader/utils.test.js +32 -1
  50. package/tests/jest/plugins/tts/utils.test.js +0 -34
@@ -10,7 +10,7 @@
10
10
  }
11
11
  }
12
12
 
13
- .BRmodeThumb .BRpagecontainer, .BRmode2Up .BRpagecontainer {
13
+ .BRmodeThumb .BRpagecontainer, .BRmode2up .BRpagecontainer {
14
14
  cursor: pointer;
15
15
  }
16
16
  .BRpagecontainer.BRemptypage {
@@ -83,57 +83,129 @@ svg.BRPageLayer {
83
83
  display: none;
84
84
  }
85
85
 
86
- .BRbookcover {
87
- position: absolute;
88
- background-image: none;
89
- box-shadow: 1px 0 10px #111;
86
+ .br-mode-2up__root {
87
+ display: block;
88
+ overflow: auto;
89
+ width: 100%;
90
+ height: 100%;
90
91
  }
91
- .BRPreview .BRpageimage {
92
- background-color: #eee;
93
- -webkit-filter: grayscale(100%);
94
- filter: grayscale(100%);
92
+
93
+ .br-mode-2up__book {
94
+ position: relative;
95
+ transform-origin: 0 0;
96
+ width: 0px;
97
+ height: 0px;
95
98
  }
96
99
 
97
- .BRleafEdgeR {
98
- border-style: solid solid solid none;
99
- border-color: rgb(51, 51, 34);
100
- border-width: 1px 1px 1px 0px;
100
+ .BRmode2up {
101
+ // Used while loading stuff
102
+ transition: opacity 0.2s;
103
+ }
101
104
 
102
- background: transparent url(images/back_pages.png) repeat scroll 0% 0%;
103
- position: absolute;
104
- cursor: pointer;
105
+ .BRmode2up .BRpagecontainer {
106
+ backface-visibility: hidden;
107
+ &:not(.BRpage-visible) {
108
+ display: none;
109
+ }
105
110
  }
106
111
 
107
- .BRleafEdgeL {
108
- /* border-style: solid none solid solid;
109
- border-color: rgb(51, 51, 34);
110
- border-width: 1px 0px 1px 1px; */
111
- background: transparent url(images/back_pages.png) repeat scroll 0% 0%; /* XXXmang replace file */
112
+ .br-mode-2up__leafs {
112
113
  position: absolute;
113
114
  cursor: pointer;
114
- }
115
+ top: 0;
116
+ transform-style: preserve-3d;
117
+
118
+ &[side=left] {
119
+ border-radius: 4px 0 0 4px;
120
+ .br-leaf-edges__label {
121
+ padding-right: 10px;
122
+ border-radius: 4px 0 0 4px;
123
+ }
124
+ }
125
+ &[side=right] {
126
+ border-radius: 0 4px 4px 0;
127
+ .br-leaf-edges__label {
128
+ padding-left: 20px;
129
+ border-radius: 0 4px 4px 0;
130
+ }
131
+ }
132
+ &.br-mode-2up__leafs--flipping {
133
+ z-index: 200000;
134
+ transition: transform 5s;
135
+ transition-timing-function: ease-in-out;
136
+ border-radius: 0;
115
137
 
116
- .BRleafEdgeTmp {
117
- /* border-style: solid none solid solid;
118
- border-color: rgb(51, 51, 34);
119
- border-width: 1px 0px 1px 1px; */
120
- background: transparent url(images/back_pages.png) repeat scroll 0% 0%; /* XXXmang replace file */
121
- position: absolute;
138
+ // Have a copy of the background at a perpendicular angle,
139
+ // so that during the rotation, it's always visible.
140
+ &:before {
141
+ content: '';
142
+ display: block;
143
+ width: 100%;
144
+ height: 100%;
145
+ position: absolute;
146
+ transform: rotateY(-90deg);
147
+ }
148
+ }
149
+
150
+ &, &.br-mode-2up__leafs--flipping::before {
151
+ background: transparent url(images/back_pages.png) repeat scroll 0% 0%;
152
+ }
153
+
154
+ .br-leaf-edges__bar {
155
+ display: none;
156
+ pointer-events: none;
157
+ position: absolute;
158
+ top: 0;
159
+ bottom: 0;
160
+ min-width: 1px;
161
+ background-color: #9A9B9D;
162
+ opacity: 0.85;
163
+ transform: translateX(-50%);
164
+ }
165
+
166
+ .br-leaf-edges__label {
167
+ display: none;
168
+ pointer-events: none;
169
+ z-index: 1000;
170
+ position: absolute;
171
+ padding: 6px;
172
+ color: white;
173
+ background-color: #9A9B9D;
174
+ opacity: 0.85;
175
+ white-space: nowrap;
176
+ transform: translateY(-10px);
177
+ }
122
178
  }
123
179
 
124
- .BRgutter {
125
- /* border: 1px solid rgb(68, 25, 17); */
126
- position: absolute;
127
- background: transparent url(images/booksplit.png) repeat scroll 0% 0%;
180
+ .br-mode-2up--flipping-left {
181
+ .BRpage-entering[data-side=R] {
182
+ z-index: 10;
183
+ transform-origin: left;
184
+ transform: rotateY(0deg);
185
+ }
186
+
187
+ .BRpage-exiting[data-side=L] {
188
+ z-index: 10;
189
+ transform-origin: right;
190
+ }
191
+
192
+ .BRpage-exiting[data-side=R] {
193
+ z-index: 9;
194
+ }
128
195
  }
129
196
 
130
- .BRtwoPagePopUp {
131
- padding: 6px;
132
- position: absolute;
133
- font-size: $brFontSizeSmaller;
134
- color: white;
135
- background-color: #9A9B9D;
136
- opacity: 0.85;
137
- border-radius: 4px;
138
- white-space: nowrap;
197
+ .br-mode-2up--flipping-right {
198
+ .BRpage-entering[data-side=L] {
199
+ z-index: 10;
200
+ transform-origin: right;
201
+ }
202
+
203
+ .BRpage-exiting[data-side=R] {
204
+ z-index: 10;
205
+ transform-origin: left;
206
+ }
207
+
208
+ .BRpage-exiting[data-side=L] {
209
+ z-index: 9;
210
+ }
139
211
  }
@@ -80,11 +80,6 @@ BookReader.prototype.autoToggle = function(overrides) {
80
80
  this.switchMode(this.constMode2up);
81
81
  }
82
82
 
83
- // Change to autofit if book is too large
84
- if (this.reduce < this._modes.mode2Up.getAutofitReduce()) {
85
- this.zoom('auto');
86
- }
87
-
88
83
  if (null == this.autoTimer) {
89
84
  // $$$ Draw events currently cause layout problems when they occur during animation.
90
85
  // There is a specific problem when changing from 1-up immediately to autoplay in RTL so
@@ -102,7 +97,7 @@ BookReader.prototype.autoToggle = function(overrides) {
102
97
  this.autoTimer = setInterval(() => {
103
98
  if (this.animating) return;
104
99
 
105
- if (Math.max(this.twoPage.currentIndexL, this.twoPage.currentIndexR) >= this.lastDisplayableIndex()) {
100
+ if (Math.max(this.twoPage.currentIndexL, this.twoPage.currentIndexR) >= this.book.getNumLeafs() - 1) {
106
101
  this.prev({ triggerStop: false }); // $$$ really what we want?
107
102
  } else {
108
103
  this.next({ triggerStop: false });
@@ -1,7 +1,7 @@
1
1
  /* global br */
2
2
  import { isChrome, isFirefox } from '../../util/browserSniffing.js';
3
- import { promisifyEvent, isAndroid } from './utils.js';
4
- import { sleep } from '../../BookReader/utils.js';
3
+ import { isAndroid } from './utils.js';
4
+ import { promisifyEvent, sleep } from '../../BookReader/utils.js';
5
5
  import AbstractTTSEngine from './AbstractTTSEngine.js';
6
6
  /** @typedef {import("./AbstractTTSEngine.js").PageChunk} PageChunk */
7
7
  /** @typedef {import("./AbstractTTSEngine.js").AbstractTTSSound} AbstractTTSSound */
@@ -286,27 +286,13 @@ BookReader.prototype.ttsSendChunkFinishedAnalyticsEvent = function(chunk) {
286
286
  /**
287
287
  * Flip the page if the provided leaf index is not visible
288
288
  * @param {Number} leafIndex
289
- * @return {PromiseLike<void>} resolves once the flip animation has completed
290
289
  */
291
- BookReader.prototype.ttsMaybeFlipToIndex = function (leafIndex) {
292
- const in2PageMode = this.constMode2up == this.mode;
293
- let resolve = null;
294
- const promise = new Promise(res => resolve = res);
295
-
296
- if (!in2PageMode) {
290
+ BookReader.prototype.ttsMaybeFlipToIndex = async function (leafIndex) {
291
+ if (this.constMode2up != this.mode) {
297
292
  this.jumpToIndex(leafIndex);
298
- resolve();
299
293
  } else {
300
- const leafVisible = leafIndex == this.twoPage.currentIndexR || leafIndex == this.twoPage.currentIndexL;
301
- if (leafVisible) {
302
- resolve();
303
- } else {
304
- this.animationFinishedCallback = resolve;
305
- this.jumpToIndex(leafIndex);
306
- }
294
+ await this._modes.mode2Up.mode2UpLit.jumpToIndex(leafIndex);
307
295
  }
308
-
309
- return promise;
310
296
  };
311
297
 
312
298
  /**
@@ -1,21 +1,5 @@
1
1
  import langs from 'iso-language-codes/js/data.js';
2
2
 
3
- /**
4
- * Convert a EventTarget style event into a promise
5
- * @param {EventTarget} target
6
- * @param {string} eventType
7
- * @return {Promise<Event>}
8
- */
9
- export function promisifyEvent(target, eventType) {
10
- return new Promise(res => {
11
- const resolver = ev => {
12
- target.removeEventListener(eventType, resolver);
13
- res(ev);
14
- };
15
- target.addEventListener(eventType, resolver);
16
- });
17
- }
18
-
19
3
  /**
20
4
  * Use regex to approximate word count in a string
21
5
  * @param {string} text
@@ -182,10 +182,11 @@ export function runBaseTests (br) {
182
182
  await t.expect(isModeInUrl('2up')).eql(true);
183
183
  });
184
184
 
185
- test('Clicking `2 page view` brings up 2 pages at a time', async t => {
185
+ test('Clicking `2 page view` brings up cur page + caching', async t => {
186
186
  const { nav } = br;
187
187
  await t.click(nav.desktop.mode2Up);
188
- await t.expect(Selector('.BRpagecontainer').count).eql(2);
188
+ await t.expect(Selector('.BRpagecontainer.BRpage-visible').count).eql(1);
189
+ await t.expect(Selector('.BRpagecontainer').count).eql(3);
189
190
  });
190
191
 
191
192
  test('Clicking `1 page view` brings up 1 at a time', async t => {
@@ -207,41 +208,40 @@ export function runBaseTests (br) {
207
208
  });
208
209
 
209
210
  test('Clicking `zoom out` makes book smaller', async t => {
210
- const { nav, BRcontainer } = br;
211
- const book = BRcontainer.child(0);
211
+ const { nav } = br;
212
+ const page = Selector('.BRpagecontainer.BRpage-visible');
212
213
 
213
214
  await t.expect(br.BRcontainer.visible).ok();
214
- await t.expect(book.visible).ok();
215
+ await t.expect(page.visible).ok();
215
216
  await t.expect(nav.desktop.zoomOut.visible).ok();
216
217
 
217
- const initialBookHeight = await book.getBoundingClientRectProperty('height');
218
- const initialBookWidth = await book.getBoundingClientRectProperty('width');
218
+ const initialBookHeight = await page.getBoundingClientRectProperty('height');
219
+ const initialBookWidth = await page.getBoundingClientRectProperty('width');
219
220
 
220
221
  await t.click(nav.desktop.zoomOut);
221
222
 
222
- const zoomOutBookHeight = await book.getBoundingClientRectProperty('height');
223
- const zoomOutBookWidth = await book.getBoundingClientRectProperty('width');
223
+ const zoomOutBookHeight = await page.getBoundingClientRectProperty('height');
224
+ const zoomOutBookWidth = await page.getBoundingClientRectProperty('width');
224
225
 
225
- await t.expect(zoomOutBookHeight).lte(initialBookHeight);
226
- await t.expect(zoomOutBookWidth).lte(initialBookWidth);
226
+ await t.expect(zoomOutBookHeight).lt(initialBookHeight);
227
+ await t.expect(zoomOutBookWidth).lt(initialBookWidth);
227
228
  });
228
229
 
229
230
  test('Clicking `zoom in` makes book larger', async t => {
230
- const { nav, BRcontainer } = br;
231
-
232
- const book = await BRcontainer.child(0);
231
+ const { nav } = br;
232
+ const page = Selector('.BRpagecontainer.BRpage-visible');
233
233
 
234
- await t.expect(BRcontainer.visible).ok();
235
- await t.expect(book.visible).ok();
234
+ await t.expect(br.BRcontainer.visible).ok();
235
+ await t.expect(page.visible).ok();
236
236
  await t.expect(nav.desktop.zoomIn.visible).ok();
237
237
 
238
- const initialBookHeight = await book.getBoundingClientRectProperty('height');
239
- const initialBookWidth = await book.getBoundingClientRectProperty('width');
238
+ const initialBookHeight = await page.getBoundingClientRectProperty('height');
239
+ const initialBookWidth = await page.getBoundingClientRectProperty('width');
240
240
 
241
241
  await t.click(nav.desktop.zoomIn);
242
242
 
243
- const zoomInBookHeight = await book.getBoundingClientRectProperty('height');
244
- const zoomIntBookWidth = await book.getBoundingClientRectProperty('width');
243
+ const zoomInBookHeight = await page.getBoundingClientRectProperty('height');
244
+ const zoomIntBookWidth = await page.getBoundingClientRectProperty('width');
245
245
 
246
246
  await t.expect(zoomInBookHeight).gt(initialBookHeight);
247
247
  await t.expect(zoomIntBookWidth).gt(initialBookWidth);
@@ -6,15 +6,9 @@ export function runRightToLeftTests (br) {
6
6
  const { nav, BRcontainer} = br;
7
7
  await t.click(nav.desktop.mode2Up);
8
8
 
9
- //checking right leaf edge has 0 width
10
- await t.expect(BRcontainer.find('.BRleafEdgeR').getStyleProperty('width')).eql('0px');
11
-
12
- //checking empty page before the cover is more to the left than the first page
13
- const rightEmptyPage = BRcontainer.find('.BRpagecontainer.BRemptypage');
14
- const leftPage = BRcontainer.find('.BRpagecontainer.pagediv0');
15
- const leftPageLDistance = leftPage.getBoundingClientRectProperty('left');
16
- const rightPageLDistance = rightEmptyPage.getBoundingClientRectProperty('left');
17
- await t.expect(rightPageLDistance).gt(await leftPageLDistance);
9
+ //checking right leaf edge is not in tree
10
+ await t.expect(BRcontainer.find('.br-mode-2up__leafs--left').count).eql(1);
11
+ await t.expect(BRcontainer.find('.br-mode-2up__leafs--right').count).eql(0);
18
12
 
19
13
  //checks slider is in correct position
20
14
  await t.expect(nav.desktop.sliderRange.getStyleProperty('width')).eql('0px');
@@ -24,6 +18,6 @@ export function runRightToLeftTests (br) {
24
18
  const { nav } = br;
25
19
  await t.click(nav.desktop.mode2Up);
26
20
  await t.click(nav.desktop.goLeft);
27
- await t.expect(getPageUrl()).match(/page\/n2/);
21
+ await t.expect(getPageUrl()).match(/page\/n1/);
28
22
  });
29
23
  }
@@ -16,6 +16,15 @@ ocaids.forEach(ocaid => {
16
16
  await t.resizeWindow(400, 800);
17
17
  // Flip forward one
18
18
  await t.pressKey('right');
19
+ await t.pressKey('right');
20
+ await t.pressKey('right');
21
+
22
+ // 1up to 2up
23
+ await t.click(nav.desktop.viewmode);
24
+ const twoPageContainer = Selector('.BRmode2up');
25
+ await t.expect(twoPageContainer.visible).ok();
26
+ const twoPageImages = twoPageContainer.find('img.BRpageimage');
27
+ await t.expect(twoPageImages.count).gte(2);
19
28
 
20
29
  // 2up to thumb
21
30
  await t.click(nav.desktop.viewmode);
@@ -30,13 +39,6 @@ ocaids.forEach(ocaid => {
30
39
  await t.expect(onePageViewContainer.visible).ok();
31
40
  const onePageImages = onePageViewContainer.find('.BRmode1up .BRpagecontainer');
32
41
  // we usually pre-fetch the page in question & 1 before/after it
33
- await t.expect(onePageImages.count).gte(3);
34
-
35
- // 1up to 2up
36
- await t.click(nav.desktop.viewmode);
37
- const twoPageContainer = Selector('.BRtwopageview');
38
- await t.expect(twoPageContainer.visible).ok();
39
- const twoPageImages = twoPageContainer.find('img.BRpageimage');
40
- await t.expect(twoPageImages.count).gte(2);
42
+ await t.expect(onePageImages.count).gte(2);
41
43
  });
42
44
  });
@@ -311,6 +311,31 @@ describe('PageModel', () => {
311
311
  });
312
312
  });
313
313
 
314
+ describe('findLeft/findRight', () => {
315
+ const data = deepCopy(SAMPLE_DATA);
316
+
317
+ test('Calls findNext/findPrev based on progression', () => {
318
+ const bm = new BookModel({ data });
319
+ const page = bm.getPage(0);
320
+ const findNextStub = sinon.stub(page, 'findNext');
321
+ const findPrevStub = sinon.stub(page, 'findPrev');
322
+ bm.pageProgression = 'lr';
323
+ page.findLeft();
324
+ expect(findPrevStub.callCount).toBe(1);
325
+ expect(findNextStub.callCount).toBe(0);
326
+ page.findRight();
327
+ expect(findPrevStub.callCount).toBe(1);
328
+ expect(findNextStub.callCount).toBe(1);
329
+ bm.pageProgression = 'rl';
330
+ page.findLeft();
331
+ expect(findPrevStub.callCount).toBe(1);
332
+ expect(findNextStub.callCount).toBe(2);
333
+ page.findRight();
334
+ expect(findPrevStub.callCount).toBe(2);
335
+ expect(findNextStub.callCount).toBe(2);
336
+ });
337
+ });
338
+
314
339
  describe('getURISrcSet', () => {
315
340
  const data = deepCopy(SAMPLE_DATA);
316
341
  const bm = new BookModel({ data, reduceSet: NAMED_REDUCE_SETS.pow2 });
@@ -28,6 +28,7 @@ describe('BookReader.prototype.toggleFullscreen', () => {
28
28
  br.trigger = sinon.fake();
29
29
  br.switchMode = sinon.fake();
30
30
  br.updateBrClasses = sinon.fake();
31
+ br.jumpToIndex = sinon.fake();
31
32
  br.refs.$brContainer = {
32
33
  css: sinon.fake(),
33
34
  animate: (options, speed, style, callback) => callback()
@@ -70,9 +71,10 @@ describe('BookReader.prototype.enterFullscreen', () => {
70
71
  br.mode = br.constMode1up;
71
72
  br.switchMode = sinon.fake();
72
73
  br.updateBrClasses = sinon.fake();
73
- br.refs.$brContainer = {
74
+ br.refs.$br = {
74
75
  css: sinon.fake(),
75
76
  animate: sinon.fake(),
77
+ addClass: sinon.fake(),
76
78
  };
77
79
  expect(br._fullscreenCloseHandler).toBeUndefined();
78
80
 
@@ -88,9 +90,13 @@ describe('BookReader.prototype.enterFullscreen', () => {
88
90
  br.trigger = sinon.fake();
89
91
  br.resize = sinon.fake();
90
92
  br.jumpToIndex = sinon.fake();
93
+ br.refs.$br = {
94
+ addClass: sinon.fake(),
95
+ removeClass: sinon.fake(),
96
+ };
91
97
  br.refs.$brContainer = {
92
98
  css: sinon.fake(),
93
- animate: (options, speed, style, callback) => callback()
99
+ animate: (options, speed, style, callback) => callback(),
94
100
  };
95
101
 
96
102
  await br.enterFullscreen();
@@ -112,6 +118,10 @@ describe('BookReader.prototype.exitFullScreen', () => {
112
118
  br.updateBrClasses = sinon.fake();
113
119
  br.trigger = sinon.fake();
114
120
  br.resize = sinon.fake();
121
+ br.refs.$br = {
122
+ addClass: sinon.fake(),
123
+ removeClass: sinon.fake(),
124
+ };
115
125
  br.refs.$brContainer = {
116
126
  css: sinon.fake(),
117
127
  animate: (options, speed, style, callback) => callback()
@@ -137,17 +147,25 @@ describe('BookReader.prototype.trigger', () => {
137
147
  });
138
148
 
139
149
  describe('`BookReader.prototype.prev`', () => {
140
- const br = new BookReader();
141
- global.br = br;
142
- br.trigger = sinon.fake();
143
- br._modes.mode2Up.flipBackToIndex = sinon.fake();
144
- br.jumpToIndex = sinon.fake();
150
+ let br;
151
+ let flipAnimationStub;
152
+ beforeEach(() => {
153
+ br = new BookReader();
154
+ global.br = br;
155
+ br.trigger = sinon.fake();
156
+ br.jumpToIndex = sinon.fake();
157
+ flipAnimationStub = sinon.stub(br._modes.mode2Up.mode2UpLit, 'flipAnimation');
158
+ });
159
+
160
+ afterEach(() => {
161
+ sinon.restore();
162
+ });
145
163
 
146
164
  test('does not take action if user is on front page', () => {
147
165
  br.firstIndex = 0;
148
166
  br.prev();
149
167
  expect(br.trigger.callCount).toBe(0);
150
- expect(br._modes.mode2Up.flipBackToIndex.callCount).toBe(0);
168
+ expect(flipAnimationStub.callCount).toBe(0);
151
169
  expect(br.jumpToIndex.callCount).toBe(0);
152
170
  });
153
171
 
@@ -158,7 +176,7 @@ describe('`BookReader.prototype.prev`', () => {
158
176
  br.prev();
159
177
  expect(br.jumpToIndex.callCount).toBe(0); // <-- does not get called
160
178
  expect(br.trigger.callCount).toBe(1);
161
- expect(br._modes.mode2Up.flipBackToIndex.callCount).toBe(1);
179
+ expect(flipAnimationStub.callCount).toBe(1);
162
180
  });
163
181
  });
164
182
 
@@ -168,8 +186,7 @@ describe('`BookReader.prototype.prev`', () => {
168
186
  br.mode = br.constMode1up;
169
187
  br.prev();
170
188
  expect(br.jumpToIndex.callCount).toBe(1); // <-- gets called
171
- expect(br.trigger.callCount).toBe(1); // <-- gets called by `jumpToIndex` internally
172
- expect(br._modes.mode2Up.flipBackToIndex.callCount).toBe(1); // <-- gets called by `jumpToIndex` internally
189
+ expect(flipAnimationStub.callCount).toBe(0); // <-- gets called by `jumpToIndex` internally
173
190
  });
174
191
  });
175
192
  });
@@ -71,22 +71,3 @@ describe('pageTops', () => {
71
71
  ]);
72
72
  });
73
73
  });
74
-
75
- describe('worldUnitsToRenderedPixels', () => {
76
- test('0 case', () => {
77
- const mode = new Mode1UpLit(null, null);
78
- expect(mode.worldUnitsToRenderedPixels(0)).toBe(0);
79
- });
80
- test('Misc cases', () => {
81
- const mode = new Mode1UpLit(null, null);
82
- mode.screenDPI = 100;
83
- mode.realWorldReduce = 1;
84
- expect(mode.worldUnitsToRenderedPixels(1)).toBe(100);
85
- mode.screenDPI = 100;
86
- mode.realWorldReduce = 2;
87
- expect(mode.worldUnitsToRenderedPixels(1)).toBe(50);
88
- mode.screenDPI = 78;
89
- mode.realWorldReduce = 1;
90
- expect(mode.worldUnitsToRenderedPixels(1)).toBe(78);
91
- });
92
- });