@internetarchive/bookreader 5.0.0-48 → 5.0.0-49
Sign up to get free protection for your applications and to get access to all the features.
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +1 -1
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +1 -1
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/CHANGELOG.md +5 -0
- package/package.json +2 -2
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +4 -4
- package/src/BookReader/BookModel.js +0 -29
- package/src/BookReader/Mode1UpLit.js +1 -1
- package/src/BookReader/Mode2Up.js +9 -34
- package/src/BookReader/ModeThumb.js +1 -3
- package/src/BookReader/Navbar/Navbar.js +8 -5
- package/src/BookReader/Toolbar/Toolbar.js +3 -30
- package/src/BookReader.js +65 -338
- package/src/plugins/plugin.autoplay.js +4 -4
- package/src/plugins/plugin.chapters.js +2 -2
- package/src/plugins/search/plugin.search.js +6 -6
- package/src/plugins/search/view.js +2 -2
- package/src/plugins/tts/plugin.tts.js +2 -2
- package/tests/e2e/models/Navigation.js +1 -1
- package/tests/jest/BookReader/BookModel.test.js +31 -11
- package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +4 -4
- package/tests/jest/BookReader/Mode1UpLit.test.js +5 -1
- package/tests/jest/BookReader/Mode2Up.test.js +8 -8
- package/tests/jest/BookReader.test.js +0 -35
- package/tests/jest/plugins/plugin.autoplay.test.js +2 -2
- package/tests/jest/plugins/plugin.chapters.test.js +2 -3
- package/tests/e2e/ia-production/ia-prod-base.js +0 -17
@@ -81,7 +81,7 @@ BookReader.prototype.autoToggle = function(overrides) {
|
|
81
81
|
}
|
82
82
|
|
83
83
|
// Change to autofit if book is too large
|
84
|
-
if (this.reduce < this.
|
84
|
+
if (this.reduce < this._modes.mode2Up.getAutofitReduce()) {
|
85
85
|
this.zoom('auto');
|
86
86
|
}
|
87
87
|
|
@@ -94,7 +94,7 @@ BookReader.prototype.autoToggle = function(overrides) {
|
|
94
94
|
// don't flip immediately -- wait until timer fires
|
95
95
|
} else {
|
96
96
|
// flip immediately
|
97
|
-
this.
|
97
|
+
this.next({ triggerStop: false });
|
98
98
|
}
|
99
99
|
|
100
100
|
this.$('.play').hide();
|
@@ -103,9 +103,9 @@ BookReader.prototype.autoToggle = function(overrides) {
|
|
103
103
|
if (this.animating) return;
|
104
104
|
|
105
105
|
if (Math.max(this.twoPage.currentIndexL, this.twoPage.currentIndexR) >= this.lastDisplayableIndex()) {
|
106
|
-
this.
|
106
|
+
this.prev({ triggerStop: false }); // $$$ really what we want?
|
107
107
|
} else {
|
108
|
-
this.
|
108
|
+
this.next({ triggerStop: false });
|
109
109
|
}
|
110
110
|
}, this.flipDelay);
|
111
111
|
} else {
|
@@ -53,7 +53,7 @@ BookReader.prototype.init = (function(super_) {
|
|
53
53
|
*/
|
54
54
|
BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex) {
|
55
55
|
const uiStringPage = 'Page'; // i18n
|
56
|
-
const percentThrough = BookReader.util.cssPercentage(pageIndex, this.getNumLeafs() - 1);
|
56
|
+
const percentThrough = BookReader.util.cssPercentage(pageIndex, this.book.getNumLeafs() - 1);
|
57
57
|
const jumpToChapter = (event) => {
|
58
58
|
this.jumpToIndex($(event.delegateTarget).data('pageIndex'));
|
59
59
|
$('.current-chapter').removeClass('current-chapter');
|
@@ -151,7 +151,7 @@ BookReader.prototype.updateTOC = function(tocEntries) {
|
|
151
151
|
* @param {TocEntry} tocEntryObject
|
152
152
|
*/
|
153
153
|
BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
|
154
|
-
tocEntryObject.pageIndex = this.getPageIndex(tocEntryObject['pagenum']);
|
154
|
+
tocEntryObject.pageIndex = this.book.getPageIndex(tocEntryObject['pagenum']);
|
155
155
|
//creates a string with non-void tocEntryObject.label and tocEntryObject.title
|
156
156
|
const chapterStr = [tocEntryObject.label, tocEntryObject.title]
|
157
157
|
.filter(x => x)
|
@@ -297,7 +297,7 @@ export function marshallSearchResults(results, displayPageNumberFn) {
|
|
297
297
|
* @param {boolean} options.goToFirstResult
|
298
298
|
*/
|
299
299
|
BookReader.prototype.BRSearchCallback = function(results, options) {
|
300
|
-
marshallSearchResults(results, pageNum => this.getPageNum(this.leafNumToIndex(pageNum)));
|
300
|
+
marshallSearchResults(results, pageNum => this.book.getPageNum(this.book.leafNumToIndex(pageNum)));
|
301
301
|
this.searchResults = results || [];
|
302
302
|
|
303
303
|
this.updateSearchHilites();
|
@@ -357,7 +357,7 @@ BookReader.prototype.updateSearchHilites = function() {
|
|
357
357
|
// Group by pageIndex
|
358
358
|
for (const match of matches) {
|
359
359
|
for (const box of match.par[0].boxes) {
|
360
|
-
const pageIndex = this.leafNumToIndex(box.page);
|
360
|
+
const pageIndex = this.book.leafNumToIndex(box.page);
|
361
361
|
const pageBoxes = boxesByIndex[pageIndex] || (boxesByIndex[pageIndex] = []);
|
362
362
|
pageBoxes.push(box);
|
363
363
|
}
|
@@ -366,7 +366,7 @@ BookReader.prototype.updateSearchHilites = function() {
|
|
366
366
|
// update any already created pages
|
367
367
|
for (const [pageIndexString, boxes] of Object.entries(boxesByIndex)) {
|
368
368
|
const pageIndex = parseFloat(pageIndexString);
|
369
|
-
const page = this.
|
369
|
+
const page = this.book.getPage(pageIndex);
|
370
370
|
const pageContainers = this.getActivePageContainerElementsForIndex(pageIndex);
|
371
371
|
for (const container of pageContainers) {
|
372
372
|
renderBoxesInPageContainerLayer('searchHiliteLayer', boxes, page, container, boxes.map(b => `match-index-${b.matchIndex}`));
|
@@ -392,8 +392,8 @@ BookReader.prototype.removeSearchHilites = function() {
|
|
392
392
|
*/
|
393
393
|
BookReader.prototype._searchPluginGoToResult = async function (matchIndex) {
|
394
394
|
const match = this.searchResults?.matches[matchIndex];
|
395
|
-
const
|
396
|
-
const
|
395
|
+
const book = this.book;
|
396
|
+
const pageIndex = book.leafNumToIndex(match.par[0].page);
|
397
397
|
const page = book.getPage(pageIndex);
|
398
398
|
const onNearbyPage = Math.abs(this.currentIndex() - pageIndex) < 3;
|
399
399
|
let makeUnviewableAtEnd = false;
|
@@ -478,7 +478,7 @@ BookReader.prototype.searchHighlightVisible = function() {
|
|
478
478
|
|
479
479
|
results.matches.some(match => {
|
480
480
|
return match.par[0].boxes.some(box => {
|
481
|
-
const pageIndex = this.leafNumToIndex(box.page);
|
481
|
+
const pageIndex = this.book.leafNumToIndex(box.page);
|
482
482
|
if (jQuery.inArray(pageIndex, visiblePages) >= 0) {
|
483
483
|
return true;
|
484
484
|
}
|
@@ -231,10 +231,10 @@ class SearchView {
|
|
231
231
|
renderPins(matches) {
|
232
232
|
matches.forEach((match) => {
|
233
233
|
const queryString = match.text;
|
234
|
-
const pageIndex = this.br.leafNumToIndex(match.par[0].page);
|
234
|
+
const pageIndex = this.br.book.leafNumToIndex(match.par[0].page);
|
235
235
|
const uiStringSearch = "Search result"; // i18n
|
236
236
|
|
237
|
-
const percentThrough = this.br.constructor.util.cssPercentage(pageIndex, this.br.getNumLeafs() - 1);
|
237
|
+
const percentThrough = this.br.constructor.util.cssPercentage(pageIndex, this.br.book.getNumLeafs() - 1);
|
238
238
|
|
239
239
|
const escapedQueryString = escapeHTML(queryString);
|
240
240
|
const queryStringWithB = escapedQueryString.replace(this.matcher, '<b>$1</b>');
|
@@ -224,7 +224,7 @@ BookReader.prototype.ttsStart = function (startTTSEngine = true) {
|
|
224
224
|
this.$('.BRicon.read').addClass('unread active');
|
225
225
|
this.ttsSendAnalyticsEvent('Start');
|
226
226
|
if (startTTSEngine)
|
227
|
-
this.ttsEngine.start(this.currentIndex(), this.getNumLeafs());
|
227
|
+
this.ttsEngine.start(this.currentIndex(), this.book.getNumLeafs());
|
228
228
|
};
|
229
229
|
|
230
230
|
BookReader.prototype.ttsJumpForward = function () {
|
@@ -326,7 +326,7 @@ BookReader.prototype.ttsHighlightChunk = function(chunk) {
|
|
326
326
|
// update any already created pages
|
327
327
|
for (const [pageIndexString, boxes] of Object.entries(this._ttsBoxesByIndex)) {
|
328
328
|
const pageIndex = parseFloat(pageIndexString);
|
329
|
-
const page = this.
|
329
|
+
const page = this.book.getPage(pageIndex);
|
330
330
|
const pageContainers = this.getActivePageContainerElementsForIndex(pageIndex);
|
331
331
|
pageContainers.forEach(container => renderBoxesInPageContainerLayer('ttsHiliteLayer', boxes, page, container));
|
332
332
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import sinon from 'sinon';
|
2
2
|
import { deepCopy } from '../utils.js';
|
3
3
|
import { BookModel } from '@/src/BookReader/BookModel.js';
|
4
|
+
import { NAMED_REDUCE_SETS } from '@/src/BookReader/ReduceSet.js';
|
4
5
|
/** @typedef {import('@/src/BookReader/options.js').BookReaderOptions} BookReaderOptions */
|
5
6
|
|
6
7
|
afterEach(() => {
|
@@ -21,10 +22,10 @@ const SAMPLE_DATA = [
|
|
21
22
|
],
|
22
23
|
];
|
23
24
|
|
24
|
-
describe('
|
25
|
+
describe('getMedianPageSizeInches', () => {
|
25
26
|
test('handles single page data', () => {
|
26
|
-
const bm = new BookModel({ data: SAMPLE_DATA.slice(0, 1) });
|
27
|
-
expect(bm.
|
27
|
+
const bm = new BookModel({ data: SAMPLE_DATA.slice(0, 1), options: {ppi: 1} });
|
28
|
+
expect(bm.getMedianPageSizeInches()).toEqual({ width: 123, height: 123 });
|
28
29
|
});
|
29
30
|
|
30
31
|
test('handles odd pages data', () => {
|
@@ -38,8 +39,8 @@ describe('getMedianPageSize', () => {
|
|
38
39
|
Object.assign(data[0][0], sizes[0]);
|
39
40
|
Object.assign(data[1][0], sizes[1]);
|
40
41
|
Object.assign(data[1][1], sizes[2]);
|
41
|
-
const bm = new BookModel({ data });
|
42
|
-
expect(bm.
|
42
|
+
const bm = new BookModel({ data, options: {ppi: 1} });
|
43
|
+
expect(bm.getMedianPageSizeInches()).toEqual({ width: 200, height: 2200 });
|
43
44
|
});
|
44
45
|
|
45
46
|
|
@@ -55,16 +56,16 @@ describe('getMedianPageSize', () => {
|
|
55
56
|
Object.assign(data[1][0], sizes[1]);
|
56
57
|
Object.assign(data[1][1], sizes[2]);
|
57
58
|
Object.assign(data[2][0], sizes[3]);
|
58
|
-
const bm = new BookModel({ data });
|
59
|
-
expect(bm.
|
59
|
+
const bm = new BookModel({ data, options: {ppi: 1} });
|
60
|
+
expect(bm.getMedianPageSizeInches()).toEqual({ width: 300, height: 2300 });
|
60
61
|
});
|
61
62
|
|
62
63
|
test('caches result', () => {
|
63
64
|
const bm = new BookModel({ data: SAMPLE_DATA });
|
64
|
-
const firstResult = bm.
|
65
|
-
expect(bm.
|
66
|
-
expect(bm.
|
67
|
-
expect(bm.
|
65
|
+
const firstResult = bm.getMedianPageSizeInches();
|
66
|
+
expect(bm.getMedianPageSizeInches()).toBe(firstResult);
|
67
|
+
expect(bm.getMedianPageSizeInches()).toBe(firstResult);
|
68
|
+
expect(bm.getMedianPageSizeInches()).toBe(firstResult);
|
68
69
|
});
|
69
70
|
});
|
70
71
|
|
@@ -309,4 +310,23 @@ describe('PageModel', () => {
|
|
309
310
|
expect(bm.getPage(0).findPrev({ combineConsecutiveUnviewables: true })).toBeUndefined();
|
310
311
|
});
|
311
312
|
});
|
313
|
+
|
314
|
+
describe('getURISrcSet', () => {
|
315
|
+
const data = deepCopy(SAMPLE_DATA);
|
316
|
+
const bm = new BookModel({ data, reduceSet: NAMED_REDUCE_SETS.pow2 });
|
317
|
+
bm.getPageURI = (index, scale, rotate) => `correctURL.png?scale=${scale}`;
|
318
|
+
const page = bm.getPage(0);
|
319
|
+
|
320
|
+
test('with 0 elements in srcset', () => {
|
321
|
+
expect(page.getURISrcSet(1)).toBe("");
|
322
|
+
});
|
323
|
+
|
324
|
+
test('with 2 elements in srcset', () => {
|
325
|
+
expect(page.getURISrcSet(5)).toBe("correctURL.png?scale=2 2x, correctURL.png?scale=1 4x");
|
326
|
+
});
|
327
|
+
|
328
|
+
test('with the most elements in srcset', () => {
|
329
|
+
expect(page.getURISrcSet(35)).toBe("correctURL.png?scale=16 2x, correctURL.png?scale=8 4x, correctURL.png?scale=4 8x, correctURL.png?scale=2 16x, correctURL.png?scale=1 32x");
|
330
|
+
});
|
331
|
+
});
|
312
332
|
});
|
@@ -140,14 +140,14 @@ describe('`BookReader.prototype.prev`', () => {
|
|
140
140
|
const br = new BookReader();
|
141
141
|
global.br = br;
|
142
142
|
br.trigger = sinon.fake();
|
143
|
-
br.flipBackToIndex = sinon.fake();
|
143
|
+
br._modes.mode2Up.flipBackToIndex = sinon.fake();
|
144
144
|
br.jumpToIndex = sinon.fake();
|
145
145
|
|
146
146
|
test('does not take action if user is on front page', () => {
|
147
147
|
br.firstIndex = 0;
|
148
148
|
br.prev();
|
149
149
|
expect(br.trigger.callCount).toBe(0);
|
150
|
-
expect(br.flipBackToIndex.callCount).toBe(0);
|
150
|
+
expect(br._modes.mode2Up.flipBackToIndex.callCount).toBe(0);
|
151
151
|
expect(br.jumpToIndex.callCount).toBe(0);
|
152
152
|
});
|
153
153
|
|
@@ -158,7 +158,7 @@ describe('`BookReader.prototype.prev`', () => {
|
|
158
158
|
br.prev();
|
159
159
|
expect(br.jumpToIndex.callCount).toBe(0); // <-- does not get called
|
160
160
|
expect(br.trigger.callCount).toBe(1);
|
161
|
-
expect(br.flipBackToIndex.callCount).toBe(1);
|
161
|
+
expect(br._modes.mode2Up.flipBackToIndex.callCount).toBe(1);
|
162
162
|
});
|
163
163
|
});
|
164
164
|
|
@@ -169,7 +169,7 @@ describe('`BookReader.prototype.prev`', () => {
|
|
169
169
|
br.prev();
|
170
170
|
expect(br.jumpToIndex.callCount).toBe(1); // <-- gets called
|
171
171
|
expect(br.trigger.callCount).toBe(1); // <-- gets called by `jumpToIndex` internally
|
172
|
-
expect(br.flipBackToIndex.callCount).toBe(1); // <-- gets called by `jumpToIndex` internally
|
172
|
+
expect(br._modes.mode2Up.flipBackToIndex.callCount).toBe(1); // <-- gets called by `jumpToIndex` internally
|
173
173
|
});
|
174
174
|
});
|
175
175
|
});
|
@@ -22,7 +22,11 @@ const SAMPLE_DATA = [
|
|
22
22
|
function make_dummy_br(overrides = {}) {
|
23
23
|
return Object.assign({
|
24
24
|
updateFirstIndex() {},
|
25
|
-
|
25
|
+
_components: {
|
26
|
+
navbar: {
|
27
|
+
updateNavIndexThrottled() {},
|
28
|
+
}
|
29
|
+
},
|
26
30
|
data: []
|
27
31
|
}, overrides);
|
28
32
|
}
|
@@ -145,13 +145,13 @@ describe('2up Container sizing', () => {
|
|
145
145
|
test('baseLeafCss', () => {
|
146
146
|
const br = new BookReader({ data: SAMPLE_DATA });
|
147
147
|
br.init();
|
148
|
-
br.calculateSpreadSize();
|
148
|
+
br._modes.mode2Up.calculateSpreadSize();
|
149
149
|
expect(Object.keys(br._modes.mode2Up.baseLeafCss)).toEqual(['position', 'right', 'top', 'zIndex']);
|
150
150
|
});
|
151
151
|
test('heightCss', () => {
|
152
152
|
const br = new BookReader({ data: SAMPLE_DATA });
|
153
153
|
br.init();
|
154
|
-
br.calculateSpreadSize();
|
154
|
+
br._modes.mode2Up.calculateSpreadSize();
|
155
155
|
const heightStub = 1000;
|
156
156
|
br.twoPage.height = heightStub;
|
157
157
|
expect(Object.keys(br._modes.mode2Up.heightCss)).toEqual(['height']);
|
@@ -160,7 +160,7 @@ describe('2up Container sizing', () => {
|
|
160
160
|
describe('left side', () => {
|
161
161
|
const br = new BookReader({ data: SAMPLE_DATA });
|
162
162
|
br.init();
|
163
|
-
br.calculateSpreadSize();
|
163
|
+
br._modes.mode2Up.calculateSpreadSize();
|
164
164
|
|
165
165
|
test('leftLeafCss', () => {
|
166
166
|
expect(Object.keys(br._modes.mode2Up.leftLeafCss)).toEqual([
|
@@ -186,7 +186,7 @@ describe('2up Container sizing', () => {
|
|
186
186
|
describe('right side', () => {
|
187
187
|
const br = new BookReader({ data: SAMPLE_DATA });
|
188
188
|
br.init();
|
189
|
-
br.calculateSpreadSize();
|
189
|
+
br._modes.mode2Up.calculateSpreadSize();
|
190
190
|
|
191
191
|
test('rightLeafCss', () => {
|
192
192
|
expect(Object.keys(br._modes.mode2Up.rightLeafCss)).toEqual([
|
@@ -213,20 +213,20 @@ describe('2up Container sizing', () => {
|
|
213
213
|
test('mainContainerCss', () => {
|
214
214
|
const br = new BookReader({ data: SAMPLE_DATA });
|
215
215
|
br.init();
|
216
|
-
br.calculateSpreadSize();
|
216
|
+
br._modes.mode2Up.calculateSpreadSize();
|
217
217
|
|
218
218
|
expect(Object.keys(br._modes.mode2Up.mainContainerCss)).toEqual(['height', 'width', 'position']);
|
219
219
|
});
|
220
220
|
test('spreadCoverCss', () => {
|
221
221
|
const br = new BookReader({ data: SAMPLE_DATA });
|
222
222
|
br.init();
|
223
|
-
br.calculateSpreadSize();
|
223
|
+
br._modes.mode2Up.calculateSpreadSize();
|
224
224
|
expect(Object.keys(br._modes.mode2Up.spreadCoverCss)).toEqual(['width', 'height', 'visibility']);
|
225
225
|
});
|
226
226
|
test('spineCss', () => {
|
227
227
|
const br = new BookReader({ data: SAMPLE_DATA });
|
228
228
|
br.init();
|
229
|
-
br.calculateSpreadSize();
|
229
|
+
br._modes.mode2Up.calculateSpreadSize();
|
230
230
|
expect(Object.keys(br._modes.mode2Up.spineCss)).toEqual(['width', 'height', 'left', 'top']);
|
231
231
|
});
|
232
232
|
});
|
@@ -247,7 +247,7 @@ describe('prepareTwoPageView', () => {
|
|
247
247
|
const preparePopUp = sinon.spy(mode2Up, 'preparePopUp');
|
248
248
|
const updateBrClasses = sinon.spy(br, 'updateBrClasses');
|
249
249
|
|
250
|
-
|
250
|
+
mode2Up.prepare(undefined, undefined, true);
|
251
251
|
expect(prefetch.callCount).toBe(1);
|
252
252
|
|
253
253
|
expect(resizeSpread.callCount).toBe(0);
|
@@ -157,41 +157,6 @@ test('does not add q= term to urlMode=hash query string', () => {
|
|
157
157
|
)).toBe('?name=value');
|
158
158
|
});
|
159
159
|
|
160
|
-
test('_getPageURISrcset with 0 page book', () => {
|
161
|
-
br._models.book.getNumLeafs = jest.fn(() => 0);
|
162
|
-
br._models.book.getPageURI = jest.fn((index, scale, rotate) => "correctURL.png&scale=" + scale);
|
163
|
-
br.init();
|
164
|
-
expect(br._getPageURISrcset(5, undefined, undefined)).toBe("");
|
165
|
-
});
|
166
|
-
|
167
|
-
test('_getPageURISrcset with negative index', () => {
|
168
|
-
br._models.book.getNumLeafs = jest.fn(() => 0);
|
169
|
-
br._models.book.getPageURI = jest.fn((index, scale, rotate) => "correctURL.png&scale=" + scale);
|
170
|
-
br.init();
|
171
|
-
expect(br._getPageURISrcset(-7, undefined, undefined)).toBe("");
|
172
|
-
});
|
173
|
-
|
174
|
-
test('_getPageURISrcset with 0 elements in srcset', () => {
|
175
|
-
br._models.book.getNumLeafs = jest.fn(() => 30);
|
176
|
-
br._models.book.getPageURI = jest.fn((index, scale, rotate) => "correctURL.png&scale=" + scale);
|
177
|
-
br.init();
|
178
|
-
expect(br._getPageURISrcset(5, 1, undefined)).toBe("");
|
179
|
-
});
|
180
|
-
|
181
|
-
test('_getPageURISrcset with 2 elements in srcset', () => {
|
182
|
-
br._models.book.getNumLeafs = jest.fn(() => 30);
|
183
|
-
br._models.book.getPageURI = jest.fn((index, scale, rotate) => "correctURL.png&scale=" + scale);
|
184
|
-
br.init();
|
185
|
-
expect(br._getPageURISrcset(5, 5, undefined)).toBe("correctURL.png&scale=2 2x, correctURL.png&scale=1 4x");
|
186
|
-
});
|
187
|
-
|
188
|
-
test('_getPageURISrcset with the most elements in srcset', () => {
|
189
|
-
br._models.book.getNumLeafs = jest.fn(() => 30);
|
190
|
-
br._models.book.getPageURI = jest.fn((index, scale, rotate) => "correctURL.png&scale=" + scale);
|
191
|
-
br.init();
|
192
|
-
expect(br._getPageURISrcset(5, 35, undefined)).toBe("correctURL.png&scale=16 2x, correctURL.png&scale=8 4x, correctURL.png&scale=4 8x, correctURL.png&scale=2 16x, correctURL.png&scale=1 32x");
|
193
|
-
});
|
194
|
-
|
195
160
|
describe('Navigation Bars', () => {
|
196
161
|
test('Standard navigation is being used by default', () => {
|
197
162
|
br.initNavbar = jest.fn();
|
@@ -38,12 +38,12 @@ describe('Plugin: Menu Toggle', () => {
|
|
38
38
|
});
|
39
39
|
test('autoplay will run without `flipSpeed` parameters', () => {
|
40
40
|
const initialAutoTimer = br.autoTimer;
|
41
|
-
br.
|
41
|
+
br.next = jest.fn();
|
42
42
|
br.autoStop = jest.fn();
|
43
43
|
br.init();
|
44
44
|
br.autoToggle();
|
45
45
|
// internally referenced functions that fire
|
46
|
-
expect(br.
|
46
|
+
expect(br.next).toHaveBeenCalledTimes(1);
|
47
47
|
|
48
48
|
expect(initialAutoTimer).toBeFalsy();
|
49
49
|
// br.autoTimer changes when autoToggle turns on
|
@@ -55,6 +55,7 @@ const SAMPLE_TOC_UNDEF = [
|
|
55
55
|
}
|
56
56
|
];
|
57
57
|
|
58
|
+
/** @type {BookReader} */
|
58
59
|
let br;
|
59
60
|
beforeEach(() => {
|
60
61
|
$.ajax = jest.fn().mockImplementation((args) => {
|
@@ -97,9 +98,7 @@ describe('updateTOCState', () => {
|
|
97
98
|
|
98
99
|
beforeEach(() => {
|
99
100
|
window.HTMLElement.prototype.scrollIntoView = sinon.stub();
|
100
|
-
|
101
|
-
//which has a getter and setter
|
102
|
-
br.getPageIndex = (str) => parseFloat(str);
|
101
|
+
br.book.getPageIndex = (str) => parseFloat(str);
|
103
102
|
br.init();
|
104
103
|
});
|
105
104
|
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { runBaseTests } from '../helpers/base';
|
2
|
-
import BookReader from '../models/BookReader';
|
3
|
-
|
4
|
-
const localURL = 'https://archive.org/details/';
|
5
|
-
const books = [
|
6
|
-
'birdbookillustra00reedrich', // publicDomain
|
7
|
-
// 'pianoservicingtu00rebl_0', // borrowable,
|
8
|
-
// 'adventuresoftoms00twaiiala', // has chapter markers
|
9
|
-
// 'gendaitankashu00meijuoft', // Right to Left book
|
10
|
-
// 'gov.uspto.patents.application.10074026', // multiple files
|
11
|
-
];
|
12
|
-
|
13
|
-
books.forEach(function(page) {
|
14
|
-
const url = `${localURL}${page}`;
|
15
|
-
fixture `Archive.org BR Base Tests for: ${page}`.page `${url}`;
|
16
|
-
runBaseTests(new BookReader());
|
17
|
-
});
|