@internetarchive/bookreader 5.0.0-95 → 5.0.0-96
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.
- package/BookReader/BookReader.css +2251 -0
- package/BookReader/BookReader.js +3 -0
- package/BookReader/BookReader.js.LICENSE.txt +72 -0
- package/BookReader/BookReader.js.map +1 -0
- package/BookReader/hypothesis/LICENSE +50 -0
- package/BookReader/hypothesis/README.md +55 -0
- package/BookReader/hypothesis/build/boot.js +1 -0
- package/BookReader/hypothesis/build/manifest.json +20 -0
- package/BookReader/hypothesis/build/scripts/annotator.bundle.js +184 -0
- package/BookReader/hypothesis/build/scripts/annotator.bundle.js.map +1 -0
- package/BookReader/hypothesis/build/scripts/sidebar.bundle.js +798 -0
- package/BookReader/hypothesis/build/scripts/sidebar.bundle.js.map +1 -0
- package/BookReader/hypothesis/build/scripts/ui-playground.bundle.js +711 -0
- package/BookReader/hypothesis/build/scripts/ui-playground.bundle.js.map +1 -0
- package/BookReader/hypothesis/build/styles/annotator.css +2235 -0
- package/BookReader/hypothesis/build/styles/annotator.css.map +1 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/highlights.css +2 -0
- package/BookReader/hypothesis/build/styles/highlights.css.map +1 -0
- package/BookReader/hypothesis/build/styles/katex.min.css +2 -0
- package/BookReader/hypothesis/build/styles/katex.min.css.map +1 -0
- package/BookReader/hypothesis/build/styles/pdfjs-overrides.css +2 -0
- package/BookReader/hypothesis/build/styles/pdfjs-overrides.css.map +1 -0
- package/BookReader/hypothesis/build/styles/sidebar.css +2731 -0
- package/BookReader/hypothesis/build/styles/sidebar.css.map +1 -0
- package/BookReader/hypothesis/build/styles/ui-playground.css +2659 -0
- package/BookReader/hypothesis/build/styles/ui-playground.css.map +1 -0
- package/BookReader/hypothesis/package.json +126 -0
- package/BookReader/ia-bookreader-bundle.js +1782 -0
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +7 -0
- package/BookReader/ia-bookreader-bundle.js.map +1 -0
- package/BookReader/icons/1up.svg +1 -0
- package/BookReader/icons/2up.svg +1 -0
- package/BookReader/icons/advance.svg +3 -0
- package/BookReader/icons/chevron-right.svg +1 -0
- package/BookReader/icons/close-circle-dark.svg +1 -0
- package/BookReader/icons/close-circle.svg +1 -0
- package/BookReader/icons/fullscreen.svg +1 -0
- package/BookReader/icons/fullscreen_exit.svg +1 -0
- package/BookReader/icons/hamburger.svg +1 -0
- package/BookReader/icons/left-arrow.svg +1 -0
- package/BookReader/icons/magnify-minus.svg +1 -0
- package/BookReader/icons/magnify-plus.svg +1 -0
- package/BookReader/icons/magnify.svg +1 -0
- package/BookReader/icons/pause.svg +1 -0
- package/BookReader/icons/play.svg +1 -0
- package/BookReader/icons/playback-speed.svg +1 -0
- package/BookReader/icons/read-aloud.svg +1 -0
- package/BookReader/icons/review.svg +3 -0
- package/BookReader/icons/thumbnails.svg +1 -0
- package/BookReader/icons/voice.svg +1 -0
- package/BookReader/icons/volume-full.svg +1 -0
- package/BookReader/images/BRicons.png +0 -0
- package/BookReader/images/BRicons.svg +5 -0
- package/BookReader/images/BRicons_ia.png +0 -0
- package/BookReader/images/back_pages.png +0 -0
- package/BookReader/images/book_bottom_icon.png +0 -0
- package/BookReader/images/book_down_icon.png +0 -0
- package/BookReader/images/book_left_icon.png +0 -0
- package/BookReader/images/book_leftmost_icon.png +0 -0
- package/BookReader/images/book_right_icon.png +0 -0
- package/BookReader/images/book_rightmost_icon.png +0 -0
- package/BookReader/images/book_top_icon.png +0 -0
- package/BookReader/images/book_up_icon.png +0 -0
- package/BookReader/images/books_graphic.svg +1 -0
- package/BookReader/images/booksplit.png +0 -0
- package/BookReader/images/control_pause_icon.png +0 -0
- package/BookReader/images/control_play_icon.png +0 -0
- package/BookReader/images/embed_icon.png +0 -0
- package/BookReader/images/hypothesis.ico +0 -0
- package/BookReader/images/icon-home-ia.png +0 -0
- package/BookReader/images/icon_OL-logo-xs.png +0 -0
- package/BookReader/images/icon_alert-xs.png +0 -0
- package/BookReader/images/icon_book.svg +1 -0
- package/BookReader/images/icon_bookmark.svg +1 -0
- package/BookReader/images/icon_close-pop.png +0 -0
- package/BookReader/images/icon_download.png +0 -0
- package/BookReader/images/icon_gear.svg +1 -0
- package/BookReader/images/icon_hamburger.svg +1 -0
- package/BookReader/images/icon_home.png +0 -0
- package/BookReader/images/icon_home.svg +1 -0
- package/BookReader/images/icon_home_ia.png +0 -0
- package/BookReader/images/icon_indicator.png +0 -0
- package/BookReader/images/icon_info.svg +1 -0
- package/BookReader/images/icon_one_page.svg +1 -0
- package/BookReader/images/icon_pause.svg +1 -0
- package/BookReader/images/icon_play.svg +1 -0
- package/BookReader/images/icon_playback-rate.svg +1 -0
- package/BookReader/images/icon_return.png +0 -0
- package/BookReader/images/icon_search_button.svg +1 -0
- package/BookReader/images/icon_share.svg +1 -0
- package/BookReader/images/icon_skip-ahead.svg +1 -0
- package/BookReader/images/icon_skip-back.svg +2 -0
- package/BookReader/images/icon_speaker.svg +1 -0
- package/BookReader/images/icon_speaker_open.svg +1 -0
- package/BookReader/images/icon_thumbnails.svg +1 -0
- package/BookReader/images/icon_toc.svg +1 -0
- package/BookReader/images/icon_two_pages.svg +1 -0
- package/BookReader/images/icon_zoomer.png +0 -0
- package/BookReader/images/loading.gif +0 -0
- package/BookReader/images/logo_icon.png +0 -0
- package/BookReader/images/marker_chap-off.png +0 -0
- package/BookReader/images/marker_chap-off.svg +1 -0
- package/BookReader/images/marker_chap-off_ia.png +0 -0
- package/BookReader/images/marker_chap-on.png +0 -0
- package/BookReader/images/marker_chap-on.svg +1 -0
- package/BookReader/images/marker_srch-on.svg +1 -0
- package/BookReader/images/marker_srchchap-off.png +0 -0
- package/BookReader/images/marker_srchchap-on.png +0 -0
- package/BookReader/images/nav_control-dn.png +0 -0
- package/BookReader/images/nav_control-dn_ia.png +0 -0
- package/BookReader/images/nav_control-up.png +0 -0
- package/BookReader/images/nav_control-up_ia.png +0 -0
- package/BookReader/images/nav_control.png +0 -0
- package/BookReader/images/one_page_mode_icon.png +0 -0
- package/BookReader/images/paper-badge.png +0 -0
- package/BookReader/images/print_icon.png +0 -0
- package/BookReader/images/progressbar.gif +0 -0
- package/BookReader/images/right_edges.png +0 -0
- package/BookReader/images/slider.png +0 -0
- package/BookReader/images/slider_ia.png +0 -0
- package/BookReader/images/thumbnail_mode_icon.png +0 -0
- package/BookReader/images/transparent.png +0 -0
- package/BookReader/images/two_page_mode_icon.png +0 -0
- package/BookReader/images/unviewable_page.png +0 -0
- package/BookReader/images/zoom_in_icon.png +0 -0
- package/BookReader/images/zoom_out_icon.png +0 -0
- package/BookReader/jquery-3.js +2 -0
- package/BookReader/jquery-3.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +2 -0
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -0
- package/BookReader/plugins/plugin.autoplay.js +2 -0
- package/BookReader/plugins/plugin.autoplay.js.map +1 -0
- package/BookReader/plugins/plugin.chapters.js +26 -0
- package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.chapters.js.map +1 -0
- package/BookReader/plugins/plugin.experiments.js +3 -0
- package/BookReader/plugins/plugin.experiments.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.experiments.js.map +1 -0
- package/BookReader/plugins/plugin.iframe.js +2 -0
- package/BookReader/plugins/plugin.iframe.js.map +1 -0
- package/BookReader/plugins/plugin.iiif.js +2 -0
- package/BookReader/plugins/plugin.iiif.js.map +1 -0
- package/BookReader/plugins/plugin.resume.js +2 -0
- package/BookReader/plugins/plugin.resume.js.map +1 -0
- package/BookReader/plugins/plugin.search.js +3 -0
- package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.search.js.map +1 -0
- package/BookReader/plugins/plugin.text_selection.js +3 -0
- package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.text_selection.js.map +1 -0
- package/BookReader/plugins/plugin.tts.js +3 -0
- package/BookReader/plugins/plugin.tts.js.LICENSE.txt +29 -0
- package/BookReader/plugins/plugin.tts.js.map +1 -0
- package/BookReader/plugins/plugin.url.js +2 -0
- package/BookReader/plugins/plugin.url.js.map +1 -0
- package/BookReader/plugins/plugin.vendor-fullscreen.js +2 -0
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -0
- package/BookReader/webcomponents-bundle.js +3 -0
- package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
- package/BookReader/webcomponents-bundle.js.map +1 -0
- package/package.json +6 -1
- package/src/BookReader/BookModel.js +564 -0
- package/src/BookReader/DragScrollable.js +233 -0
- package/src/BookReader/ImageCache.js +149 -0
- package/src/BookReader/Mode1Up.js +110 -0
- package/src/BookReader/Mode1UpLit.js +388 -0
- package/src/BookReader/Mode2Up.js +107 -0
- package/src/BookReader/Mode2UpLit.js +777 -0
- package/src/BookReader/ModeCoordinateSpace.js +29 -0
- package/src/BookReader/ModeSmoothZoom.js +312 -0
- package/src/BookReader/ModeThumb.js +344 -0
- package/src/BookReader/Navbar/Navbar.js +355 -0
- package/src/BookReader/PageContainer.js +172 -0
- package/src/BookReader/ReduceSet.js +26 -0
- package/src/BookReader/Toolbar/Toolbar.js +362 -0
- package/src/BookReader/events.js +19 -0
- package/src/BookReader/options.js +387 -0
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/BookReader/utils/SelectionObserver.js +45 -0
- package/src/BookReader/utils/classes.js +36 -0
- package/src/BookReader/utils.js +313 -0
- package/.eslintrc.cjs +0 -51
- package/.gitattributes +0 -2
- package/.github/ISSUE_TEMPLATE/bug.md +0 -32
- package/.github/ISSUE_TEMPLATE/feature-request.md +0 -30
- package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +0 -15
- package/.github/workflows/node.js.yml +0 -102
- package/.github/workflows/npm-publish.yml +0 -23
- package/.testcaferc.cjs +0 -10
- package/BookReaderDemo/BookReaderDemo.css +0 -40
- package/BookReaderDemo/BookReaderJSAdvanced.js +0 -112
- package/BookReaderDemo/BookReaderJSSimple.js +0 -56
- package/BookReaderDemo/IADemoBr.js +0 -149
- package/BookReaderDemo/assets/v5/Bookreader-logo-cool-grad.svg +0 -1
- package/BookReaderDemo/assets/v5/Bookreader-logo-flat.svg +0 -1
- package/BookReaderDemo/assets/v5/Bookreader-logo-hex-cool-grad.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-hex-flat.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-lines.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-lines.svg +0 -1
- package/BookReaderDemo/assets/v5/Bookreader-logo-warm.svg +0 -1
- package/BookReaderDemo/assets/v5/bookreader-logo-renders@1x.png +0 -0
- package/BookReaderDemo/assets/v5/bookreader-logo-renders@2x.png +0 -0
- package/BookReaderDemo/assets/v5/bookreader-v5-screenshot.png +0 -0
- package/BookReaderDemo/demo-advanced.html +0 -33
- package/BookReaderDemo/demo-embed-iframe-src.html +0 -85
- package/BookReaderDemo/demo-embed.html +0 -26
- package/BookReaderDemo/demo-fullscreen-mobile.html +0 -34
- package/BookReaderDemo/demo-fullscreen.html +0 -31
- package/BookReaderDemo/demo-iiif.html +0 -121
- package/BookReaderDemo/demo-internetarchive.html +0 -271
- package/BookReaderDemo/demo-multiple.html +0 -44
- package/BookReaderDemo/demo-preview-pages.html +0 -1093
- package/BookReaderDemo/demo-simple.html +0 -35
- package/BookReaderDemo/demo-vendor-fullscreen.html +0 -34
- package/BookReaderDemo/ia-multiple-volumes-manifest.js +0 -169
- package/BookReaderDemo/immersion-1up.html +0 -64
- package/BookReaderDemo/immersion-mode.html +0 -33
- package/BookReaderDemo/toggle_controls.html +0 -54
- package/BookReaderDemo/view_mode.html +0 -40
- package/BookReaderDemo/viewmode-cycle.html +0 -40
- package/CHANGELOG.md +0 -1087
- package/CONTRIBUTING.md +0 -7
- package/babel.config.cjs +0 -20
- package/codecov.yml +0 -23
- package/index.html +0 -34
- package/netlify.toml +0 -9
- package/renovate.json +0 -52
- package/screenshot.png +0 -0
- package/scripts/postversion.js +0 -11
- package/scripts/preversion.js +0 -15
- package/scripts/version.js +0 -24
- package/tests/e2e/README.md +0 -112
- package/tests/e2e/autoplay.test.js +0 -16
- package/tests/e2e/base.test.js +0 -27
- package/tests/e2e/helpers/base.js +0 -263
- package/tests/e2e/helpers/debug.js +0 -13
- package/tests/e2e/helpers/mockSearch.js +0 -90
- package/tests/e2e/helpers/params.js +0 -17
- package/tests/e2e/helpers/rightToLeft.js +0 -23
- package/tests/e2e/helpers/search.js +0 -73
- package/tests/e2e/models/BookReader.js +0 -11
- package/tests/e2e/models/Navigation.js +0 -39
- package/tests/e2e/rightToLeft.test.js +0 -19
- package/tests/e2e/viewmode.test.js +0 -44
- package/tests/jest/BookNavigator/book-navigator.test.js +0 -653
- package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +0 -43
- package/tests/jest/BookNavigator/bookmarks/bookmark-edit.test.js +0 -132
- package/tests/jest/BookNavigator/bookmarks/bookmarks-list.test.js +0 -221
- package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +0 -45
- package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +0 -67
- package/tests/jest/BookNavigator/downloads/downloads.test.js +0 -53
- package/tests/jest/BookNavigator/search/search-provider.test.js +0 -179
- package/tests/jest/BookNavigator/search/search-results.test.js +0 -289
- package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +0 -49
- package/tests/jest/BookNavigator/viewable-files/viewable-files-provider.test.js +0 -80
- package/tests/jest/BookNavigator/visual-adjustments.test.js +0 -200
- package/tests/jest/BookReader.keyboard.test.js +0 -190
- package/tests/jest/BookReader.options.test.js +0 -47
- package/tests/jest/BookReader.test.js +0 -316
- package/tests/jest/plugins/plugin.archive_analytics.test.js +0 -20
- package/tests/jest/plugins/plugin.autoplay.test.js +0 -35
- package/tests/jest/plugins/plugin.chapters.test.js +0 -193
- package/tests/jest/plugins/plugin.iframe.test.js +0 -42
- package/tests/jest/plugins/plugin.resume.test.js +0 -85
- package/tests/jest/plugins/plugin.text_selection.test.js +0 -447
- package/tests/jest/plugins/plugin.vendor-fullscreen.test.js +0 -65
- package/tests/jest/plugins/search/plugin.search.test.js +0 -120
- package/tests/jest/plugins/search/plugin.search.view.test.js +0 -131
- package/tests/jest/plugins/search/utils.js +0 -25
- package/tests/jest/plugins/search/utils.test.js +0 -29
- package/tests/jest/plugins/tts/AbstractTTSEngine.test.js +0 -173
- package/tests/jest/plugins/tts/FestivalTTSEngine.test.js +0 -59
- package/tests/jest/plugins/tts/PageChunk.test.js +0 -57
- package/tests/jest/plugins/tts/PageChunkIterator.test.js +0 -179
- package/tests/jest/plugins/tts/WebTTSEngine.test.js +0 -178
- package/tests/jest/plugins/tts/utils.test.js +0 -74
- package/tests/jest/plugins/url/UrlPlugin.test.js +0 -198
- package/tests/jest/plugins/url/plugin.url.test.js +0 -168
- package/tests/jest/setup.js +0 -3
- package/tests/jest/util/browserSniffing.test.js +0 -62
- package/tests/jest/util/docCookies.test.js +0 -24
- package/tests/jest/util/strings.test.js +0 -63
- package/tests/jest/utils.js +0 -83
- package/webpack.config.js +0 -97
@@ -1,190 +0,0 @@
|
|
1
|
-
import BookReader from '@/src/BookReader.js';
|
2
|
-
import * as utils from '@/src/BookReader/utils.js';
|
3
|
-
|
4
|
-
let br;
|
5
|
-
beforeAll(() => {
|
6
|
-
document.body.innerHTML = '<div id="BookReader">';
|
7
|
-
br = new BookReader();
|
8
|
-
});
|
9
|
-
|
10
|
-
afterEach(() => {
|
11
|
-
jest.clearAllMocks();
|
12
|
-
});
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Only run init() once. Otherwise multiple EventListeners will be added.
|
16
|
-
*/
|
17
|
-
test('Initialzation enables IntersectionObserver and defaults', () => {
|
18
|
-
const observe = jest.fn();
|
19
|
-
window.IntersectionObserver = jest.fn(() => ({
|
20
|
-
observe,
|
21
|
-
}));
|
22
|
-
br.init();
|
23
|
-
expect(br.hasKeyFocus).toBe(true);
|
24
|
-
expect(observe).toHaveBeenCalledTimes(1);
|
25
|
-
});
|
26
|
-
|
27
|
-
describe('Keyboard shortcuts turned off', () => {
|
28
|
-
|
29
|
-
test('Focus flag disables', () => {
|
30
|
-
br.next = jest.fn();
|
31
|
-
br.hasKeyFocus = false;
|
32
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowDown'});
|
33
|
-
keyEvent.preventDefault = jest.fn();
|
34
|
-
document.dispatchEvent(keyEvent);
|
35
|
-
expect(br.next).toHaveBeenCalledTimes(0);
|
36
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(0);
|
37
|
-
// Must reset for following tests
|
38
|
-
br.hasKeyFocus = true;
|
39
|
-
});
|
40
|
-
|
41
|
-
test('Input active disables', () => {
|
42
|
-
// eslint-disable-next-line no-import-assign
|
43
|
-
utils.isInputActive = jest.fn(() => true);
|
44
|
-
br.next = jest.fn();
|
45
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowDown'});
|
46
|
-
keyEvent.preventDefault = jest.fn();
|
47
|
-
document.dispatchEvent(keyEvent);
|
48
|
-
expect(br.next).toHaveBeenCalledTimes(0);
|
49
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(0);
|
50
|
-
// Must reset for following tests
|
51
|
-
utils.isInputActive.mockReset();
|
52
|
-
});
|
53
|
-
|
54
|
-
});
|
55
|
-
|
56
|
-
describe('Keyboard shortcuts', () => {
|
57
|
-
|
58
|
-
test('Home key', () => {
|
59
|
-
br.first = jest.fn();
|
60
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'Home'});
|
61
|
-
keyEvent.preventDefault = jest.fn();
|
62
|
-
document.dispatchEvent(keyEvent);
|
63
|
-
expect(br.first).toHaveBeenCalledTimes(1);
|
64
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
65
|
-
});
|
66
|
-
|
67
|
-
test('End key', () => {
|
68
|
-
br.last = jest.fn();
|
69
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'End'});
|
70
|
-
keyEvent.preventDefault = jest.fn();
|
71
|
-
document.dispatchEvent(keyEvent);
|
72
|
-
expect(br.last).toHaveBeenCalledTimes(1);
|
73
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
74
|
-
});
|
75
|
-
|
76
|
-
test('ArrowDown key', () => {
|
77
|
-
br.mode = br.constMode2up;
|
78
|
-
br.next = jest.fn();
|
79
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowDown'});
|
80
|
-
keyEvent.preventDefault = jest.fn();
|
81
|
-
document.dispatchEvent(keyEvent);
|
82
|
-
expect(br.next).toHaveBeenCalledTimes(1);
|
83
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
84
|
-
});
|
85
|
-
|
86
|
-
test('PageDown key', () => {
|
87
|
-
br.mode = br.constMode2up;
|
88
|
-
br.next = jest.fn();
|
89
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'PageDown'});
|
90
|
-
keyEvent.preventDefault = jest.fn();
|
91
|
-
document.dispatchEvent(keyEvent);
|
92
|
-
expect(br.next).toHaveBeenCalledTimes(1);
|
93
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
94
|
-
});
|
95
|
-
|
96
|
-
test('ArrowUp key', () => {
|
97
|
-
br.mode = br.constMode2up;
|
98
|
-
br.prev = jest.fn();
|
99
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowUp'});
|
100
|
-
keyEvent.preventDefault = jest.fn();
|
101
|
-
document.dispatchEvent(keyEvent);
|
102
|
-
expect(br.prev).toHaveBeenCalledTimes(1);
|
103
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
104
|
-
});
|
105
|
-
|
106
|
-
test('PageUp key', () => {
|
107
|
-
br.mode = br.constMode2up;
|
108
|
-
br.prev = jest.fn();
|
109
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'PageUp'});
|
110
|
-
keyEvent.preventDefault = jest.fn();
|
111
|
-
document.dispatchEvent(keyEvent);
|
112
|
-
expect(br.prev).toHaveBeenCalledTimes(1);
|
113
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
114
|
-
});
|
115
|
-
|
116
|
-
test('ArrowLeft key', () => {
|
117
|
-
br.mode = br.constMode2up;
|
118
|
-
br.left = jest.fn();
|
119
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowLeft'});
|
120
|
-
keyEvent.preventDefault = jest.fn();
|
121
|
-
document.dispatchEvent(keyEvent);
|
122
|
-
expect(br.left).toHaveBeenCalledTimes(1);
|
123
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
124
|
-
});
|
125
|
-
|
126
|
-
test('ArrowRight key', () => {
|
127
|
-
br.mode = br.constMode2up;
|
128
|
-
br.right = jest.fn();
|
129
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowRight'});
|
130
|
-
keyEvent.preventDefault = jest.fn();
|
131
|
-
document.dispatchEvent(keyEvent);
|
132
|
-
expect(br.right).toHaveBeenCalledTimes(1);
|
133
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
134
|
-
});
|
135
|
-
|
136
|
-
test('Subtract key', () => {
|
137
|
-
br.zoom = jest.fn();
|
138
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'Subtract'});
|
139
|
-
keyEvent.preventDefault = jest.fn();
|
140
|
-
document.dispatchEvent(keyEvent);
|
141
|
-
expect(br.zoom).toHaveBeenCalledTimes(1);
|
142
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
143
|
-
});
|
144
|
-
|
145
|
-
test('- key', () => {
|
146
|
-
br.zoom = jest.fn();
|
147
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': '-'});
|
148
|
-
keyEvent.preventDefault = jest.fn();
|
149
|
-
document.dispatchEvent(keyEvent);
|
150
|
-
expect(br.zoom).toHaveBeenCalledTimes(1);
|
151
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
152
|
-
});
|
153
|
-
|
154
|
-
test('Add key', () => {
|
155
|
-
br.zoom = jest.fn();
|
156
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'Add'});
|
157
|
-
keyEvent.preventDefault = jest.fn();
|
158
|
-
document.dispatchEvent(keyEvent);
|
159
|
-
expect(br.zoom).toHaveBeenCalledTimes(1);
|
160
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
161
|
-
});
|
162
|
-
|
163
|
-
test('+ key', () => {
|
164
|
-
br.zoom = jest.fn();
|
165
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': '+'});
|
166
|
-
keyEvent.preventDefault = jest.fn();
|
167
|
-
document.dispatchEvent(keyEvent);
|
168
|
-
expect(br.zoom).toHaveBeenCalledTimes(1);
|
169
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
170
|
-
});
|
171
|
-
|
172
|
-
test('= key', () => {
|
173
|
-
br.zoom = jest.fn();
|
174
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': '='});
|
175
|
-
keyEvent.preventDefault = jest.fn();
|
176
|
-
document.dispatchEvent(keyEvent);
|
177
|
-
expect(br.zoom).toHaveBeenCalledTimes(1);
|
178
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
179
|
-
});
|
180
|
-
|
181
|
-
test('F key', () => {
|
182
|
-
br.toggleFullscreen = jest.fn();
|
183
|
-
const keyEvent = new KeyboardEvent('keydown', {'key': 'F'});
|
184
|
-
keyEvent.preventDefault = jest.fn();
|
185
|
-
document.dispatchEvent(keyEvent);
|
186
|
-
expect(br.toggleFullscreen).toHaveBeenCalledTimes(1);
|
187
|
-
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
188
|
-
});
|
189
|
-
|
190
|
-
});
|
@@ -1,47 +0,0 @@
|
|
1
|
-
|
2
|
-
import BookReader from '@/src/BookReader.js';
|
3
|
-
|
4
|
-
beforeAll(() => {
|
5
|
-
document.body.innerHTML = '<div id="BookReader">';
|
6
|
-
});
|
7
|
-
|
8
|
-
afterEach(() => {
|
9
|
-
jest.clearAllMocks();
|
10
|
-
});
|
11
|
-
|
12
|
-
describe('BookReader options', () => {
|
13
|
-
describe('`autoResize`', () => {
|
14
|
-
it('is on by default', () => {
|
15
|
-
const br = new BookReader();
|
16
|
-
br.init();
|
17
|
-
expect(br.options.autoResize).toBe(true);
|
18
|
-
});
|
19
|
-
});
|
20
|
-
|
21
|
-
describe('`startFullscreen`', () => {
|
22
|
-
it('initializes BookReader to fullscreen', () => {
|
23
|
-
const br = new BookReader({
|
24
|
-
startFullscreen: true,
|
25
|
-
});
|
26
|
-
br.init();
|
27
|
-
|
28
|
-
expect(document.getElementById('BookReader').classList.contains('br-ui-full')).toBe(true);
|
29
|
-
});
|
30
|
-
});
|
31
|
-
|
32
|
-
describe('`useSrcSet`', () => {
|
33
|
-
it('is on by default', () => {
|
34
|
-
const br = new BookReader();
|
35
|
-
br.init();
|
36
|
-
expect(br.options.autoResize).toBe(true);
|
37
|
-
});
|
38
|
-
});
|
39
|
-
|
40
|
-
describe('`showNavbar`', () => {
|
41
|
-
it('is on by default', () => {
|
42
|
-
const br = new BookReader();
|
43
|
-
br.init();
|
44
|
-
expect(br.options.showNavbar).toBe(true);
|
45
|
-
});
|
46
|
-
});
|
47
|
-
});
|
@@ -1,316 +0,0 @@
|
|
1
|
-
|
2
|
-
import BookReader, {_modeStringToNumber} from '@/src/BookReader.js';
|
3
|
-
import '@/src/plugins/plugin.resume.js';
|
4
|
-
import '@/src/plugins/url/plugin.url.js';
|
5
|
-
|
6
|
-
/** @type {import('@/src/BookReader.js').default} */
|
7
|
-
let br;
|
8
|
-
beforeAll(() => {
|
9
|
-
document.body.innerHTML = '<div id="BookReader">';
|
10
|
-
br = new BookReader({
|
11
|
-
server: '',
|
12
|
-
bookId: '',
|
13
|
-
subPrefix: '',
|
14
|
-
bookPath: '',
|
15
|
-
});
|
16
|
-
});
|
17
|
-
|
18
|
-
afterEach(() => {
|
19
|
-
jest.clearAllMocks();
|
20
|
-
});
|
21
|
-
|
22
|
-
test('has registered PostInit events', () => {
|
23
|
-
expect(BookReader.eventNames.PostInit).toBeTruthy();
|
24
|
-
});
|
25
|
-
|
26
|
-
test('has registered zoom events', () => {
|
27
|
-
expect(BookReader.eventNames.zoomIn).toBeTruthy();
|
28
|
-
expect(BookReader.eventNames.zoomOut).toBeTruthy();
|
29
|
-
});
|
30
|
-
|
31
|
-
test('has registered view type selected events', () => {
|
32
|
-
expect(BookReader.eventNames['1PageViewSelected']).toBeTruthy();
|
33
|
-
expect(BookReader.eventNames['2PageViewSelected']).toBeTruthy();
|
34
|
-
expect(BookReader.eventNames['3PageViewSelected']).toBeTruthy();
|
35
|
-
});
|
36
|
-
|
37
|
-
test('has registered fullscreen toggle event', () => {
|
38
|
-
expect(BookReader.eventNames.fullscreenToggled).toBeTruthy();
|
39
|
-
});
|
40
|
-
|
41
|
-
test('checks cookie when initParams called', () => {
|
42
|
-
br.plugins.resume.getResumeValue = jest.fn(() => 15);
|
43
|
-
br.urlReadFragment = jest.fn(() => '');
|
44
|
-
|
45
|
-
const params = br.initParams();
|
46
|
-
expect(br.plugins.resume.getResumeValue).toHaveBeenCalledTimes(1);
|
47
|
-
expect(params.init).toBe(true);
|
48
|
-
expect(params.index).toBe(15);
|
49
|
-
expect(params.fragmentChange).toBe(true);
|
50
|
-
});
|
51
|
-
|
52
|
-
test('does not check cookie when initParams called', () => {
|
53
|
-
br.plugins.resume.getResumeValue = jest.fn(() => null);
|
54
|
-
br.urlReadFragment = jest.fn(() => '');
|
55
|
-
br.options.plugins.resume.enabled = false;
|
56
|
-
|
57
|
-
const params = br.initParams();
|
58
|
-
expect(br.plugins.resume.getResumeValue).toHaveBeenCalledTimes(0);
|
59
|
-
expect(params.init).toBe(true);
|
60
|
-
expect(params.index).toBe(0);
|
61
|
-
expect(params.fragmentChange).toBe(false);
|
62
|
-
});
|
63
|
-
|
64
|
-
test('gets index from fragment when both fragment and cookie when InitParams called', () => {
|
65
|
-
br.plugins.resume.getResumeValue = jest.fn(() => 15);
|
66
|
-
br.urlReadFragment = jest.fn(() => 'page/n4');
|
67
|
-
br.options.plugins.resume.enabled = true;
|
68
|
-
|
69
|
-
const params = br.initParams();
|
70
|
-
expect(br.plugins.resume.getResumeValue).toHaveBeenCalledTimes(1);
|
71
|
-
expect(params.init).toBe(true);
|
72
|
-
expect(params.index).toBe(4);
|
73
|
-
expect(params.fragmentChange).toBe(true);
|
74
|
-
});
|
75
|
-
|
76
|
-
test('sets prevReadMode when init called', () => {
|
77
|
-
br.init();
|
78
|
-
expect(br.prevReadMode).toBeTruthy();
|
79
|
-
});
|
80
|
-
|
81
|
-
// Default behavior same in
|
82
|
-
// BookReader.prototype.drawLeafsThumbnail
|
83
|
-
// BookReader.prototype.getPrevReadMode
|
84
|
-
test('sets prevPageMode if initial mode is thumb', () => {
|
85
|
-
br.urlReadFragment = jest.fn(() => 'page/n4/mode/thumb');
|
86
|
-
|
87
|
-
br.init();
|
88
|
-
expect(br.prevReadMode).toBe(BookReader.constMode1up);
|
89
|
-
});
|
90
|
-
|
91
|
-
test('calls switchMode with init option when init called', () => {
|
92
|
-
br.switchMode = jest.fn();
|
93
|
-
|
94
|
-
br.init();
|
95
|
-
expect(br.switchMode.mock.calls[0][1])
|
96
|
-
.toHaveProperty('init', true);
|
97
|
-
});
|
98
|
-
|
99
|
-
test('has added BR property: server', () => {
|
100
|
-
expect(br).toHaveProperty('server');
|
101
|
-
expect(br.server).toBeDefined();
|
102
|
-
});
|
103
|
-
|
104
|
-
test('has added BR property: bookId', () => {
|
105
|
-
expect(br).toHaveProperty('bookId');
|
106
|
-
expect(br.bookId).toBeDefined();
|
107
|
-
});
|
108
|
-
|
109
|
-
test('has added BR property: subPrefix', () => {
|
110
|
-
expect(br).toHaveProperty('subPrefix');
|
111
|
-
expect(br.subPrefix).toBeDefined();
|
112
|
-
});
|
113
|
-
|
114
|
-
test('has added BR property: bookPath', () => {
|
115
|
-
expect(br).toHaveProperty('bookPath');
|
116
|
-
expect(br.bookPath).toBeDefined();
|
117
|
-
});
|
118
|
-
|
119
|
-
test('has suppressFragmentChange true when init with no input', () => {
|
120
|
-
br.plugins.resume.getResumeValue = jest.fn(() => null);
|
121
|
-
br.urlReadFragment = jest.fn(() => '');
|
122
|
-
br.urlReadHashFragment = jest.fn(() => '');
|
123
|
-
br.switchMode = jest.fn();
|
124
|
-
|
125
|
-
br.init();
|
126
|
-
expect(br.switchMode.mock.calls[0][1])
|
127
|
-
.toHaveProperty('suppressFragmentChange', true);
|
128
|
-
});
|
129
|
-
|
130
|
-
test('has suppressFragmentChange false when init with cookie', () => {
|
131
|
-
br.plugins.resume.getResumeValue = jest.fn(() => 5);
|
132
|
-
br.urlReadFragment = jest.fn(() => '');
|
133
|
-
br.switchMode = jest.fn();
|
134
|
-
|
135
|
-
br.init();
|
136
|
-
expect(br.switchMode.mock.calls[0][1])
|
137
|
-
.toHaveProperty('suppressFragmentChange', false);
|
138
|
-
});
|
139
|
-
|
140
|
-
test('has suppressFragmentChange false when init with fragment', () => {
|
141
|
-
br.plugins.resume.getResumeValue = jest.fn(() => null);
|
142
|
-
br.urlReadFragment = jest.fn(() => 'mode/1up');
|
143
|
-
br.switchMode = jest.fn();
|
144
|
-
|
145
|
-
br.init();
|
146
|
-
expect(br.switchMode.mock.calls[0][1])
|
147
|
-
.toHaveProperty('suppressFragmentChange', false);
|
148
|
-
});
|
149
|
-
|
150
|
-
test('has suppressFragmentChange false when init with hash fragment', () => {
|
151
|
-
br.plugins.resume.getResumeValue = jest.fn(() => null);
|
152
|
-
br.urlReadFragment = jest.fn(() => '');
|
153
|
-
br.urlReadHashFragment = jest.fn(() => 'mode/1up');
|
154
|
-
br.switchMode = jest.fn();
|
155
|
-
br.options.urlMode = 'history',
|
156
|
-
|
157
|
-
br.init();
|
158
|
-
expect(br.switchMode.mock.calls[0][1])
|
159
|
-
.toHaveProperty('suppressFragmentChange', false);
|
160
|
-
});
|
161
|
-
|
162
|
-
test('adds q= term to urlMode=history query string', () => {
|
163
|
-
expect(br.queryStringFromParams(
|
164
|
-
{ search: 'test value' },
|
165
|
-
'name=value',
|
166
|
-
'history',
|
167
|
-
)).toBe('?name=value&q=test+value');
|
168
|
-
});
|
169
|
-
|
170
|
-
test('replaces q= term in urlMode=history query string', () => {
|
171
|
-
expect(br.queryStringFromParams(
|
172
|
-
{ search: 'test+value' },
|
173
|
-
'q=foo&a=1&b=2&c=3',
|
174
|
-
'history',
|
175
|
-
)).toBe('?q=test%2Bvalue&a=1&b=2&c=3');
|
176
|
-
});
|
177
|
-
|
178
|
-
test('does not add q= term to urlMode=hash query string', () => {
|
179
|
-
expect(br.queryStringFromParams(
|
180
|
-
{ search: 'test value' },
|
181
|
-
'name=value',
|
182
|
-
'hash',
|
183
|
-
)).toBe('?name=value');
|
184
|
-
});
|
185
|
-
|
186
|
-
describe('Navigation Bars', () => {
|
187
|
-
test('Standard navigation is being used by default', () => {
|
188
|
-
br.initNavbar = jest.fn();
|
189
|
-
br.options.ui = '';
|
190
|
-
br.init();
|
191
|
-
expect(br.initNavbar).toHaveBeenCalledTimes(1);
|
192
|
-
});
|
193
|
-
test('Standard navigation is being used by default - when bookreader is embedded', () => {
|
194
|
-
br.initNavbar = jest.fn();
|
195
|
-
br.options.ui = 'embed';
|
196
|
-
br.init();
|
197
|
-
expect(br.initNavbar).toHaveBeenCalledTimes(1);
|
198
|
-
expect(br.options.ui).toEqual('embed');
|
199
|
-
});
|
200
|
-
});
|
201
|
-
|
202
|
-
describe('quantizeReduce', () => {
|
203
|
-
const quantizeReduce = BookReader.prototype.quantizeReduce;
|
204
|
-
const SAMPLE_FACTORS = [
|
205
|
-
{ reduce: 0.5 },
|
206
|
-
{ reduce: 1 },
|
207
|
-
{ reduce: 2 },
|
208
|
-
{ reduce: 3 },
|
209
|
-
{ reduce: 4 },
|
210
|
-
{ reduce: 6 },
|
211
|
-
];
|
212
|
-
test('Number larger than max', () => {
|
213
|
-
expect(quantizeReduce(10, SAMPLE_FACTORS)).toBe(6);
|
214
|
-
});
|
215
|
-
|
216
|
-
test('Number lower than max', () => {
|
217
|
-
expect(quantizeReduce(0.25, SAMPLE_FACTORS)).toBe(0.5);
|
218
|
-
});
|
219
|
-
|
220
|
-
test('Number directly between two reduction factors chooses first factor', () => {
|
221
|
-
expect(quantizeReduce(5, SAMPLE_FACTORS)).toBe(4);
|
222
|
-
});
|
223
|
-
|
224
|
-
test('Exact match', () => {
|
225
|
-
expect(quantizeReduce(2, SAMPLE_FACTORS)).toBe(2);
|
226
|
-
});
|
227
|
-
|
228
|
-
test('Closer to a lower boundary', () => {
|
229
|
-
expect(quantizeReduce(1.115, SAMPLE_FACTORS)).toBe(1);
|
230
|
-
});
|
231
|
-
|
232
|
-
test('Closer to an upper bound', () => {
|
233
|
-
expect(quantizeReduce(1.95, SAMPLE_FACTORS)).toBe(2);
|
234
|
-
});
|
235
|
-
|
236
|
-
test('Only one reduction factor', () => {
|
237
|
-
expect(quantizeReduce(17, [{reduce: 10}])).toBe(10);
|
238
|
-
});
|
239
|
-
});
|
240
|
-
|
241
|
-
|
242
|
-
describe('nextReduce', () => {
|
243
|
-
describe('Test matrix', () => {
|
244
|
-
const nextReduce = BookReader.prototype.nextReduce;
|
245
|
-
const SAMPLE_FACTORS = [
|
246
|
-
{ reduce: 0.5 },
|
247
|
-
{ reduce: 1 },
|
248
|
-
{ reduce: 2 },
|
249
|
-
{ reduce: 3 },
|
250
|
-
{ reduce: 3.3, autofit: "width" },
|
251
|
-
{ reduce: 4 },
|
252
|
-
{ reduce: 6 },
|
253
|
-
{ reduce: 6.1, autofit: "height" },
|
254
|
-
// auto doesn't get read by nextReduce (bug)
|
255
|
-
// It looks like width/height are set for 1up, and auto is set for 2up,
|
256
|
-
// and neither is set for thumb
|
257
|
-
{ reduce: 6.2, autofit: "auto" },
|
258
|
-
];
|
259
|
-
|
260
|
-
const currentReduces = [
|
261
|
-
{ name: 'Exact match', value: 2 },
|
262
|
-
{ name: 'In-between', value: 4.5 },
|
263
|
-
{ name: '< Min', value: 0.25 },
|
264
|
-
{ name: '> Max', value: 10 },
|
265
|
-
|
266
|
-
{ name: '= Min', value: 0.5 },
|
267
|
-
{ name: '= Max', value: 6.2 },
|
268
|
-
];
|
269
|
-
|
270
|
-
const directions = [ 'in', 'out', 'width', 'height', 'auto' ];
|
271
|
-
|
272
|
-
const expectations = [
|
273
|
-
// currentReduces <->
|
274
|
-
// v^ directions
|
275
|
-
/* 2, 4.5, 0.25, 10, 0.5, 6.2 */
|
276
|
-
/* in */ [ 1, 4, 0.5, 6.2, 0.5, 6.1 ],
|
277
|
-
/* out */ [ 3, 6, 0.5, 6.2, 1, 6.2 ],
|
278
|
-
/* width */ [ 3.3, 3.3, 3.3, 3.3, 3.3, 3.3 ],
|
279
|
-
/* height */ [ 6.1, 6.1, 6.1, 6.1, 6.1, 6.1 ],
|
280
|
-
/* auto */ [ 6.2, 6.2, 6.2, 6.2, 6.2, 6.2 ],
|
281
|
-
];
|
282
|
-
|
283
|
-
for (const [y, row] of expectations.entries()) {
|
284
|
-
for (const [x, expectedValue] of row.entries()) {
|
285
|
-
test(`${currentReduces[x].name} ${directions[y]}`, () => {
|
286
|
-
expect(nextReduce(currentReduces[x].value, directions[y], SAMPLE_FACTORS).reduce)
|
287
|
-
.toBe(expectedValue);
|
288
|
-
});
|
289
|
-
}
|
290
|
-
}
|
291
|
-
});
|
292
|
-
|
293
|
-
describe('No matching reduction', () => {
|
294
|
-
const nextReduce = BookReader.prototype.nextReduce;
|
295
|
-
const SAMPLE_FACTORS = [
|
296
|
-
{ reduce: 0.5 },
|
297
|
-
{ reduce: 1 },
|
298
|
-
{ reduce: 2 },
|
299
|
-
{ reduce: 3 },
|
300
|
-
];
|
301
|
-
|
302
|
-
test('Returns first reduction when no match found', () => {
|
303
|
-
expect(nextReduce(2, 'width', SAMPLE_FACTORS).reduce).toBe(0.5);
|
304
|
-
expect(nextReduce(2, 'height', SAMPLE_FACTORS).reduce).toBe(0.5);
|
305
|
-
expect(nextReduce(2, 'auto', SAMPLE_FACTORS).reduce).toBe(0.5);
|
306
|
-
});
|
307
|
-
});
|
308
|
-
});
|
309
|
-
|
310
|
-
describe('_modeStringToNumber', () => {
|
311
|
-
test('Returns correct number', () => {
|
312
|
-
expect(_modeStringToNumber('mode/1up')).toBe(1);
|
313
|
-
expect(_modeStringToNumber('mode/2up')).toBe(2);
|
314
|
-
expect(_modeStringToNumber('mode/thumb')).toBe(3);
|
315
|
-
});
|
316
|
-
});
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import sinon from 'sinon';
|
2
|
-
import {ArchiveAnalyticsPlugin} from '@/src/plugins/plugin.archive_analytics.js';
|
3
|
-
|
4
|
-
describe('sendEvent', () => {
|
5
|
-
test('logs if debug set to true', () => {
|
6
|
-
const stub = sinon.stub(console, 'log');
|
7
|
-
const p = new ArchiveAnalyticsPlugin({});
|
8
|
-
p.setup({ debug: true });
|
9
|
-
p.sendEvent();
|
10
|
-
expect(stub.callCount).toBe(1);
|
11
|
-
stub.restore();
|
12
|
-
});
|
13
|
-
|
14
|
-
test('Does not error if window.archive_analytics is undefined', () => {
|
15
|
-
const p = new ArchiveAnalyticsPlugin({});
|
16
|
-
const spy = sinon.spy(p.sendEvent);
|
17
|
-
p.sendEvent();
|
18
|
-
expect(spy.threw()).toBe(false);
|
19
|
-
});
|
20
|
-
});
|
@@ -1,35 +0,0 @@
|
|
1
|
-
|
2
|
-
import BookReader from '@/src/BookReader.js';
|
3
|
-
import '@/src/plugins/plugin.autoplay.js';
|
4
|
-
|
5
|
-
/** @type {BookReader} */
|
6
|
-
let br;
|
7
|
-
beforeEach(() => {
|
8
|
-
document.body.innerHTML = '<div id="BookReader">';
|
9
|
-
br = new BookReader();
|
10
|
-
});
|
11
|
-
|
12
|
-
afterEach(() => {
|
13
|
-
jest.clearAllMocks();
|
14
|
-
});
|
15
|
-
|
16
|
-
describe('Plugin: Menu Toggle', () => {
|
17
|
-
test('autoplay does not start when BookReaderInitializes', () => {
|
18
|
-
br.plugins.autoplay.toggle = jest.fn();
|
19
|
-
br.init();
|
20
|
-
expect(br.plugins.autoplay.toggle).toHaveBeenCalledTimes(0);
|
21
|
-
});
|
22
|
-
test('autoplay will run without `flipSpeed` parameters', () => {
|
23
|
-
const initialTimer = br.plugins.autoplay.timer;
|
24
|
-
br.next = jest.fn();
|
25
|
-
br.plugins.autoplay.stop = jest.fn();
|
26
|
-
br.init();
|
27
|
-
br.plugins.autoplay.toggle();
|
28
|
-
// internally referenced functions that fire
|
29
|
-
expect(br.next).toHaveBeenCalledTimes(1);
|
30
|
-
|
31
|
-
expect(initialTimer).toBeFalsy();
|
32
|
-
// timer changes when autoplay turns on
|
33
|
-
expect(br.plugins.autoplay.timer).toBeTruthy();
|
34
|
-
});
|
35
|
-
});
|