@internetarchive/bookreader 5.0.0-8 → 5.0.0-80

Sign up to get free protection for your applications and to get access to all the features.
Files changed (313) hide show
  1. package/.eslintrc.js +17 -15
  2. package/.github/workflows/node.js.yml +73 -10
  3. package/.github/workflows/npm-publish.yml +6 -20
  4. package/.testcaferc.js +10 -0
  5. package/BookReader/BookReader.css +398 -1133
  6. package/BookReader/BookReader.js +1 -1
  7. package/BookReader/BookReader.js.LICENSE.txt +20 -20
  8. package/BookReader/BookReader.js.map +1 -1
  9. package/BookReader/ia-bookreader-bundle.js +1782 -0
  10. package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +7 -0
  11. package/BookReader/ia-bookreader-bundle.js.map +1 -0
  12. package/BookReader/icons/1up.svg +1 -1
  13. package/BookReader/icons/2up.svg +1 -1
  14. package/BookReader/icons/advance.svg +1 -1
  15. package/BookReader/icons/chevron-right.svg +1 -1
  16. package/BookReader/icons/close-circle-dark.svg +1 -1
  17. package/BookReader/icons/close-circle.svg +1 -1
  18. package/BookReader/icons/fullscreen.svg +1 -1
  19. package/BookReader/icons/fullscreen_exit.svg +1 -1
  20. package/BookReader/icons/hamburger.svg +1 -1
  21. package/BookReader/icons/left-arrow.svg +1 -1
  22. package/BookReader/icons/magnify-minus.svg +1 -1
  23. package/BookReader/icons/magnify-plus.svg +1 -1
  24. package/BookReader/icons/magnify.svg +1 -1
  25. package/BookReader/icons/pause.svg +1 -1
  26. package/BookReader/icons/play.svg +1 -1
  27. package/BookReader/icons/playback-speed.svg +1 -1
  28. package/BookReader/icons/read-aloud.svg +1 -1
  29. package/BookReader/icons/review.svg +1 -1
  30. package/BookReader/icons/thumbnails.svg +1 -1
  31. package/BookReader/icons/voice.svg +1 -0
  32. package/BookReader/icons/volume-full.svg +1 -1
  33. package/BookReader/images/BRicons.svg +3 -3
  34. package/BookReader/images/books_graphic.svg +1 -1
  35. package/BookReader/images/icon_book.svg +1 -1
  36. package/BookReader/images/icon_bookmark.svg +1 -1
  37. package/BookReader/images/icon_gear.svg +1 -1
  38. package/BookReader/images/icon_hamburger.svg +1 -1
  39. package/BookReader/images/icon_home.svg +1 -1
  40. package/BookReader/images/icon_info.svg +1 -1
  41. package/BookReader/images/icon_one_page.svg +1 -1
  42. package/BookReader/images/icon_pause.svg +1 -1
  43. package/BookReader/images/icon_play.svg +1 -1
  44. package/BookReader/images/icon_playback-rate.svg +1 -1
  45. package/BookReader/images/icon_search_button.svg +1 -1
  46. package/BookReader/images/icon_share.svg +1 -1
  47. package/BookReader/images/icon_skip-ahead.svg +1 -1
  48. package/BookReader/images/icon_skip-back.svg +1 -1
  49. package/BookReader/images/icon_speaker.svg +1 -1
  50. package/BookReader/images/icon_speaker_open.svg +1 -1
  51. package/BookReader/images/icon_thumbnails.svg +1 -1
  52. package/BookReader/images/icon_toc.svg +1 -1
  53. package/BookReader/images/icon_two_pages.svg +1 -1
  54. package/BookReader/images/marker_chap-off.svg +1 -1
  55. package/BookReader/images/marker_chap-on.svg +1 -1
  56. package/BookReader/images/marker_srch-on.svg +1 -1
  57. package/BookReader/jquery-3.js +2 -0
  58. package/BookReader/jquery-3.js.LICENSE.txt +24 -0
  59. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  60. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  61. package/BookReader/plugins/plugin.autoplay.js +1 -1
  62. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  63. package/BookReader/plugins/plugin.chapters.js +25 -1
  64. package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +1 -0
  65. package/BookReader/plugins/plugin.chapters.js.map +1 -1
  66. package/BookReader/plugins/plugin.iframe.js +1 -1
  67. package/BookReader/plugins/plugin.iframe.js.map +1 -1
  68. package/BookReader/plugins/plugin.iiif.js +2 -0
  69. package/BookReader/plugins/plugin.iiif.js.map +1 -0
  70. package/BookReader/plugins/plugin.resume.js +1 -1
  71. package/BookReader/plugins/plugin.resume.js.map +1 -1
  72. package/BookReader/plugins/plugin.search.js +2 -1
  73. package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -0
  74. package/BookReader/plugins/plugin.search.js.map +1 -1
  75. package/BookReader/plugins/plugin.text_selection.js +2 -1
  76. package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -0
  77. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  78. package/BookReader/plugins/plugin.tts.js +1 -1
  79. package/BookReader/plugins/plugin.tts.js.LICENSE.txt +2 -0
  80. package/BookReader/plugins/plugin.tts.js.map +1 -1
  81. package/BookReader/plugins/plugin.url.js +1 -1
  82. package/BookReader/plugins/plugin.url.js.map +1 -1
  83. package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
  84. package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
  85. package/BookReader/webcomponents-bundle.js +3 -0
  86. package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
  87. package/BookReader/webcomponents-bundle.js.map +1 -0
  88. package/BookReaderDemo/BookReaderDemo.css +18 -19
  89. package/BookReaderDemo/BookReaderJSAdvanced.js +0 -3
  90. package/BookReaderDemo/BookReaderJSAutoplay.js +4 -1
  91. package/BookReaderDemo/BookReaderJSSimple.js +1 -0
  92. package/BookReaderDemo/IADemoBr.js +147 -0
  93. package/BookReaderDemo/demo-advanced.html +2 -2
  94. package/BookReaderDemo/demo-autoplay.html +2 -3
  95. package/BookReaderDemo/demo-embed-iframe-src.html +2 -1
  96. package/BookReaderDemo/demo-fullscreen-mobile.html +3 -5
  97. package/BookReaderDemo/demo-fullscreen.html +2 -4
  98. package/BookReaderDemo/demo-iiif.html +99 -12
  99. package/BookReaderDemo/demo-internetarchive.html +214 -18
  100. package/BookReaderDemo/demo-multiple.html +2 -1
  101. package/BookReaderDemo/demo-preview-pages.html +2 -1
  102. package/BookReaderDemo/demo-simple.html +2 -1
  103. package/BookReaderDemo/demo-vendor-fullscreen.html +2 -4
  104. package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
  105. package/BookReaderDemo/immersion-1up.html +2 -2
  106. package/BookReaderDemo/immersion-mode.html +2 -4
  107. package/BookReaderDemo/toggle_controls.html +3 -2
  108. package/BookReaderDemo/view_mode.html +2 -1
  109. package/BookReaderDemo/viewmode-cycle.html +2 -3
  110. package/CHANGELOG.md +536 -33
  111. package/README.md +14 -1
  112. package/babel.config.js +20 -0
  113. package/codecov.yml +6 -0
  114. package/index.html +4 -1
  115. package/jsconfig.json +19 -0
  116. package/netlify.toml +9 -0
  117. package/package.json +70 -60
  118. package/renovate.json +52 -0
  119. package/scripts/preversion.js +0 -1
  120. package/src/BookNavigator/assets/bookmark-colors.js +1 -1
  121. package/src/BookNavigator/assets/button-base.js +4 -2
  122. package/src/BookNavigator/assets/ia-logo.js +17 -0
  123. package/src/BookNavigator/assets/icon_checkmark.js +1 -1
  124. package/src/BookNavigator/assets/icon_close.js +1 -1
  125. package/src/BookNavigator/book-navigator.js +590 -0
  126. package/src/BookNavigator/bookmarks/bookmark-button.js +3 -2
  127. package/src/BookNavigator/bookmarks/bookmark-edit.js +3 -4
  128. package/src/BookNavigator/bookmarks/bookmarks-list.js +2 -3
  129. package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +3 -8
  130. package/src/BookNavigator/bookmarks/bookmarks-provider.js +27 -17
  131. package/src/BookNavigator/bookmarks/ia-bookmarks.js +116 -67
  132. package/src/BookNavigator/delete-modal-actions.js +1 -1
  133. package/src/BookNavigator/downloads/downloads-provider.js +36 -21
  134. package/src/BookNavigator/downloads/downloads.js +41 -25
  135. package/src/BookNavigator/search/search-provider.js +49 -27
  136. package/src/BookNavigator/search/search-results.js +23 -9
  137. package/src/BookNavigator/sharing.js +27 -0
  138. package/src/BookNavigator/viewable-files.js +95 -0
  139. package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +11 -10
  140. package/src/BookNavigator/visual-adjustments/visual-adjustments.js +3 -3
  141. package/src/BookReader/BookModel.js +64 -34
  142. package/src/BookReader/DragScrollable.js +233 -0
  143. package/src/BookReader/Mode1Up.js +56 -351
  144. package/src/BookReader/Mode1UpLit.js +388 -0
  145. package/src/BookReader/Mode2Up.js +73 -1318
  146. package/src/BookReader/Mode2UpLit.js +776 -0
  147. package/src/BookReader/ModeCoordinateSpace.js +29 -0
  148. package/src/BookReader/ModeSmoothZoom.js +312 -0
  149. package/src/BookReader/ModeThumb.js +18 -12
  150. package/src/BookReader/Navbar/Navbar.js +14 -40
  151. package/src/BookReader/PageContainer.js +81 -6
  152. package/src/BookReader/ReduceSet.js +1 -1
  153. package/src/BookReader/Toolbar/Toolbar.js +10 -37
  154. package/src/BookReader/events.js +2 -3
  155. package/src/BookReader/options.js +27 -2
  156. package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
  157. package/src/BookReader/utils/ScrollClassAdder.js +31 -0
  158. package/src/BookReader/utils/SelectionObserver.js +45 -0
  159. package/src/BookReader/utils.js +118 -13
  160. package/src/BookReader.js +427 -1061
  161. package/src/assets/icons/magnify-minus.svg +3 -7
  162. package/src/assets/icons/magnify-plus.svg +3 -7
  163. package/src/assets/icons/voice.svg +1 -0
  164. package/src/css/BookReader.scss +1 -5
  165. package/src/css/_BRBookmarks.scss +1 -1
  166. package/src/css/_BRComponent.scss +1 -1
  167. package/src/css/_BRmain.scss +16 -3
  168. package/src/css/_BRnav.scss +12 -39
  169. package/src/css/_BRpages.scss +149 -40
  170. package/src/css/_BRsearch.scss +68 -25
  171. package/src/css/_BRtoolbar.scss +5 -5
  172. package/src/css/_TextSelection.scss +87 -27
  173. package/src/css/_colorbox.scss +2 -2
  174. package/src/css/_controls.scss +20 -7
  175. package/src/css/_icons.scss +1 -1
  176. package/src/ia-bookreader/ia-bookreader.js +224 -0
  177. package/src/plugins/plugin.archive_analytics.js +3 -3
  178. package/src/plugins/plugin.autoplay.js +5 -11
  179. package/src/plugins/plugin.chapters.js +237 -191
  180. package/src/plugins/plugin.iiif.js +151 -0
  181. package/src/plugins/plugin.resume.js +3 -3
  182. package/src/plugins/plugin.text_selection.js +464 -134
  183. package/src/plugins/plugin.vendor-fullscreen.js +4 -4
  184. package/src/plugins/search/plugin.search.js +142 -125
  185. package/src/plugins/search/utils.js +43 -0
  186. package/src/plugins/search/view.js +33 -58
  187. package/src/plugins/tts/AbstractTTSEngine.js +71 -40
  188. package/src/plugins/tts/FestivalTTSEngine.js +13 -14
  189. package/src/plugins/tts/PageChunk.js +15 -21
  190. package/src/plugins/tts/PageChunkIterator.js +8 -12
  191. package/src/plugins/tts/WebTTSEngine.js +87 -71
  192. package/src/plugins/tts/plugin.tts.js +96 -127
  193. package/src/plugins/tts/utils.js +15 -25
  194. package/src/plugins/url/UrlPlugin.js +191 -0
  195. package/src/plugins/{plugin.url.js → url/plugin.url.js} +45 -16
  196. package/src/util/browserSniffing.js +22 -0
  197. package/src/util/docCookies.js +21 -2
  198. package/tests/e2e/README.md +37 -0
  199. package/tests/e2e/autoplay.test.js +2 -2
  200. package/tests/e2e/base.test.js +8 -16
  201. package/tests/e2e/helpers/base.js +53 -48
  202. package/tests/e2e/helpers/debug.js +1 -1
  203. package/tests/e2e/helpers/params.js +17 -0
  204. package/tests/e2e/helpers/rightToLeft.js +8 -14
  205. package/tests/e2e/helpers/search.js +73 -0
  206. package/tests/e2e/models/Navigation.js +20 -37
  207. package/tests/e2e/rightToLeft.test.js +4 -5
  208. package/tests/e2e/viewmode.test.js +40 -33
  209. package/tests/jest/BookNavigator/book-navigator.test.js +661 -0
  210. package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +43 -0
  211. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
  212. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
  213. package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
  214. package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +67 -0
  215. package/tests/jest/BookNavigator/downloads/downloads.test.js +53 -0
  216. package/tests/jest/BookNavigator/search/search-provider.test.js +167 -0
  217. package/tests/{karma → jest}/BookNavigator/search/search-results.test.js +109 -60
  218. package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +49 -0
  219. package/tests/jest/BookNavigator/viewable-files/viewable-files-provider.test.js +80 -0
  220. package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
  221. package/tests/{BookReader → jest/BookReader}/BookModel.test.js +74 -14
  222. package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +193 -0
  223. package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
  224. package/tests/jest/BookReader/Mode1UpLit.test.js +73 -0
  225. package/tests/jest/BookReader/Mode2Up.test.js +98 -0
  226. package/tests/jest/BookReader/Mode2UpLit.test.js +190 -0
  227. package/tests/jest/BookReader/ModeCoordinateSpace.test.js +16 -0
  228. package/tests/jest/BookReader/ModeSmoothZoom.test.js +218 -0
  229. package/tests/jest/BookReader/ModeThumb.test.js +71 -0
  230. package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +10 -10
  231. package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +88 -6
  232. package/tests/{BookReader → jest/BookReader}/ReduceSet.test.js +1 -1
  233. package/tests/{BookReader → jest/BookReader}/Toolbar/Toolbar.test.js +2 -2
  234. package/tests/jest/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
  235. package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
  236. package/tests/jest/BookReader/utils/SelectionObserver.test.js +57 -0
  237. package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
  238. package/tests/jest/BookReader/utils.test.js +229 -0
  239. package/tests/jest/BookReader.keyboard.test.js +190 -0
  240. package/tests/{BookReader.options.test.js → jest/BookReader.options.test.js} +9 -1
  241. package/tests/{BookReader.test.js → jest/BookReader.test.js} +26 -37
  242. package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
  243. package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +4 -4
  244. package/tests/jest/plugins/plugin.chapters.test.js +195 -0
  245. package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
  246. package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
  247. package/tests/jest/plugins/plugin.text_selection.test.js +317 -0
  248. package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
  249. package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +25 -47
  250. package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +39 -6
  251. package/tests/jest/plugins/search/utils.js +25 -0
  252. package/tests/jest/plugins/search/utils.test.js +29 -0
  253. package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +29 -9
  254. package/tests/{plugins → jest/plugins}/tts/FestivalTTSEngine.test.js +4 -4
  255. package/tests/{plugins → jest/plugins}/tts/PageChunk.test.js +1 -1
  256. package/tests/{plugins → jest/plugins}/tts/PageChunkIterator.test.js +3 -3
  257. package/tests/{plugins → jest/plugins}/tts/WebTTSEngine.test.js +47 -1
  258. package/tests/{plugins → jest/plugins}/tts/utils.test.js +1 -60
  259. package/tests/jest/plugins/url/UrlPlugin.test.js +198 -0
  260. package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +53 -14
  261. package/tests/jest/setup.js +3 -0
  262. package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
  263. package/tests/jest/util/docCookies.test.js +24 -0
  264. package/tests/{util → jest/util}/strings.test.js +1 -1
  265. package/tests/{utils.js → jest/utils.js} +38 -0
  266. package/webpack.config.js +12 -6
  267. package/.babelrc +0 -12
  268. package/.dependabot/config.yml +0 -6
  269. package/.testcaferc.json +0 -5
  270. package/BookReader/bookreader-component-bundle.js +0 -1450
  271. package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
  272. package/BookReader/bookreader-component-bundle.js.map +0 -1
  273. package/BookReader/jquery-1.10.1.js +0 -2
  274. package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
  275. package/BookReader/plugins/plugin.menu_toggle.js +0 -2
  276. package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
  277. package/BookReader/plugins/plugin.mobile_nav.js +0 -2
  278. package/BookReader/plugins/plugin.mobile_nav.js.map +0 -1
  279. package/BookReaderDemo/IIIFBookReader.js +0 -207
  280. package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
  281. package/BookReaderDemo/demo-iiif.js +0 -26
  282. package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
  283. package/karma.conf.js +0 -23
  284. package/src/BookNavigator/BookModel.js +0 -14
  285. package/src/BookNavigator/BookNavigator.js +0 -446
  286. package/src/BookNavigator/assets/book-loader.js +0 -27
  287. package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
  288. package/src/BookNavigator/search/a-search-result.js +0 -55
  289. package/src/BookReader/DebugConsole.js +0 -54
  290. package/src/BookReaderComponent/BookReaderComponent.js +0 -112
  291. package/src/ItemNavigator/ItemNavigator.js +0 -376
  292. package/src/ItemNavigator/providers/sharing.js +0 -29
  293. package/src/css/_MobileNav.scss +0 -194
  294. package/src/dragscrollable-br.js +0 -261
  295. package/src/lit-wrapper.js +0 -2
  296. package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
  297. package/src/plugins/plugin.mobile_nav.js +0 -287
  298. package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
  299. package/tests/BookReader/DebugConsole.test.js +0 -25
  300. package/tests/BookReader/Mode1Up.test.js +0 -164
  301. package/tests/BookReader/Mode2Up.test.js +0 -247
  302. package/tests/BookReader/utils.test.js +0 -109
  303. package/tests/e2e/helpers/desktopSearch.js +0 -72
  304. package/tests/e2e/helpers/mobileSearch.js +0 -85
  305. package/tests/e2e/ia-production/ia-prod-base.js +0 -17
  306. package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
  307. package/tests/karma/BookNavigator/search/search-provider.test.js +0 -23
  308. package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
  309. package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
  310. package/tests/plugins/plugin.chapters.test.js +0 -130
  311. package/tests/plugins/plugin.mobile_nav.test.js +0 -66
  312. package/tests/plugins/plugin.text_selection.test.js +0 -203
  313. package/tests/util/docCookies.test.js +0 -15
@@ -0,0 +1,98 @@
1
+
2
+ import sinon from 'sinon';
3
+ import { Mode2Up } from '@/src/BookReader/Mode2Up.js';
4
+ import BookReader from '@/src/BookReader.js';
5
+ import { BookModel } from '@/src/BookReader/BookModel.js';
6
+ import { afterEventLoop } from '../utils';
7
+ /** @typedef {import('@/src/BookReader/options.js').BookReaderOptions} BookReaderOptions */
8
+
9
+ beforeAll(() => {
10
+ global.alert = jest.fn();
11
+ });
12
+ afterEach(() => {
13
+ jest.restoreAllMocks();
14
+ sinon.restore();
15
+ });
16
+
17
+ /** @type {BookReaderOptions['data']} */
18
+ const SAMPLE_DATA = [
19
+ [
20
+ { width: 123, height: 123, uri: 'https://archive.org/image0.jpg', pageNum: '1' },
21
+ ],
22
+ [
23
+ { width: 123, height: 123, uri: 'https://archive.org/image1.jpg', pageNum: '2' },
24
+ { width: 123, height: 123, uri: 'https://archive.org/image2.jpg', pageNum: '3' },
25
+ ],
26
+ [
27
+ { width: 123, height: 123, uri: 'https://archive.org/image3.jpg', pageNum: '4' },
28
+ { width: 123, height: 123, uri: 'https://archive.org/image4.jpg', pageNum: '5' },
29
+ ],
30
+ [
31
+ { width: 123, height: 123, uri: 'https://archive.org/image5.jpg', pageNum: '6' },
32
+ ],
33
+ ];
34
+
35
+
36
+ describe('Mode2Up', () => {
37
+ /** @type {BookReader} */
38
+ let br;
39
+ /** @type {BookModel} */
40
+ let bookModel;
41
+ /** @type {Mode2Up} */
42
+ let mode2Up;
43
+
44
+ beforeEach(() => {
45
+ br = new BookReader({
46
+ data: SAMPLE_DATA,
47
+ el: document.createElement('div'),
48
+ });
49
+ br.init();
50
+ bookModel = new BookModel(br);
51
+ mode2Up = new Mode2Up(br, bookModel);
52
+ });
53
+
54
+ describe('prepare', () => {
55
+ it('initializes DOM properly', async () => {
56
+ const spyAppend = sinon.spy(br.refs.$brContainer, 'append');
57
+ const spyRequestUpdate = sinon.spy(mode2Up.mode2UpLit, 'requestUpdate');
58
+ const initFirstRenderSpy = sinon.spy(mode2Up.mode2UpLit, 'initFirstRender');
59
+ const jumpToIndexSpy = sinon.spy(mode2Up.mode2UpLit, 'jumpToIndex');
60
+ sinon.stub(mode2Up.mode2UpLit, 'updateComplete').get(() => Promise.resolve());
61
+ mode2Up.prepare();
62
+
63
+ expect(br.refs.$brContainer[0].style.overflow).toEqual('hidden');
64
+ expect(spyAppend.calledWith(mode2Up.$el)).toBe(true);
65
+ expect(mode2Up.mode2UpLit.style.opacity).toEqual('0');
66
+
67
+ await afterEventLoop();
68
+
69
+ expect(initFirstRenderSpy.called).toBe(true);
70
+ expect(jumpToIndexSpy.called).toBe(false);
71
+ expect(mode2Up.everShown).toBe(true);
72
+ expect(spyRequestUpdate.called).toBe(true);
73
+ expect(mode2Up.mode2UpLit.style.opacity).toEqual('1');
74
+ });
75
+ });
76
+
77
+ describe('resizePageView', () => {
78
+ it('updates autoFit when possible', async () => {
79
+ const updateClientSizesSpy = sinon.stub(mode2Up.mode2UpLit.htmlDimensionsCacher, 'updateClientSizes');
80
+ const resizeViaAutofitSpy = sinon.spy(mode2Up.mode2UpLit, 'resizeViaAutofit');
81
+ const recenterStub = sinon.stub(mode2Up.mode2UpLit, 'recenter');
82
+
83
+ mode2Up.resizePageView();
84
+ expect(updateClientSizesSpy.called).toBe(true);
85
+ expect(resizeViaAutofitSpy.called).toBe(true);
86
+ expect(recenterStub.called).toBe(true);
87
+
88
+ // Test with scale and autoFit as 'none'
89
+ mode2Up.mode2UpLit.scale = 0.1;
90
+ mode2Up.mode2UpLit.autoFit = 'none';
91
+ mode2Up.resizePageView();
92
+
93
+ expect(mode2Up.mode2UpLit.autoFit).toEqual('auto');
94
+ expect(resizeViaAutofitSpy.callCount).toEqual(2);
95
+ expect(recenterStub.callCount).toEqual(2);
96
+ });
97
+ });
98
+ });
@@ -0,0 +1,190 @@
1
+ import sinon from "sinon";
2
+ import { BookModel } from "@/src/BookReader/BookModel.js";
3
+ import { Mode2UpLit } from "@/src/BookReader/Mode2UpLit.js";
4
+
5
+ /** @type {import('@/src/BookReader/options.js').BookReaderOptions['data']} */
6
+ const SAMPLE_DATA = [
7
+ [
8
+ {
9
+ width: 123,
10
+ height: 123,
11
+ uri: "https://archive.org/image0.jpg",
12
+ pageNum: "1",
13
+ },
14
+ ],
15
+ [
16
+ {
17
+ width: 123,
18
+ height: 123,
19
+ uri: "https://archive.org/image1.jpg",
20
+ pageNum: "2",
21
+ },
22
+ {
23
+ width: 123,
24
+ height: 123,
25
+ uri: "https://archive.org/image2.jpg",
26
+ pageNum: "3",
27
+ },
28
+ ],
29
+ [
30
+ {
31
+ width: 123,
32
+ height: 123,
33
+ uri: "https://archive.org/image3.jpg",
34
+ pageNum: "4",
35
+ },
36
+ {
37
+ width: 123,
38
+ height: 123,
39
+ uri: "https://archive.org/image4.jpg",
40
+ pageNum: "5",
41
+ },
42
+ ],
43
+ [
44
+ {
45
+ width: 123,
46
+ height: 123,
47
+ uri: "https://archive.org/image5.jpg",
48
+ pageNum: "6",
49
+ },
50
+ ],
51
+ ];
52
+
53
+ function make_dummy_br(overrides = {}) {
54
+ return Object.assign({
55
+ updateFirstIndex() {},
56
+ _components: {
57
+ navbar: {
58
+ updateNavIndexThrottled() {},
59
+ },
60
+ },
61
+ data: [],
62
+ }, overrides);
63
+ }
64
+
65
+ afterEach(() => {
66
+ sinon.restore();
67
+ });
68
+
69
+ describe("computePageHeight", () => {
70
+ test("Always returns the median", () => {
71
+ const mode = new Mode2UpLit({
72
+ getMedianPageSizeInches: () => ({ width: 100, height: 200 }),
73
+ }, null);
74
+ expect(mode.computePageHeight(null)).toEqual(200);
75
+ expect(mode.computePageHeight({ widthInches: 300, heightInches: 400 }))
76
+ .toEqual(200);
77
+ });
78
+ });
79
+
80
+ describe("computePageWidth", () => {
81
+ test("returns relative to pageHeight", () => {
82
+ const mode = new Mode2UpLit(null, null);
83
+ sinon.stub(mode, "computePageHeight").returns(6);
84
+
85
+ expect(mode.computePageWidth({ widthInches: 2, heightInches: 6 })).toEqual(
86
+ 2,
87
+ );
88
+ expect(mode.computePageWidth({ widthInches: 3, heightInches: 6 })).toEqual(
89
+ 3,
90
+ );
91
+ expect(mode.computePageWidth({ widthInches: 2, heightInches: 4 })).toEqual(
92
+ 2 * 6 / 4,
93
+ );
94
+ });
95
+ });
96
+
97
+ describe("computePositions", () => {
98
+ const LEFT_COVER_EXPECTED = {
99
+ leafEdgesLeftStart: -0.246,
100
+ leafEdgesLeftMainWidth: 0,
101
+ leafEdgesLeftMovingStart: -0.246,
102
+ leafEdgesLeftMovingWidth: 0,
103
+ leafEdgesLeftEnd: -0.246,
104
+ leafEdgesLeftFullWidth: 0,
105
+ pageLeftStart: -0.246,
106
+ pageLeftWidth: 0.246,
107
+ pageLeftEnd: 0,
108
+ gutter: 0,
109
+ pageRightStart: 0,
110
+ pageRightWidth: 0.246,
111
+ pageRightEnd: 0.246,
112
+ leafEdgesRightStart: 0.246,
113
+ leafEdgesRightMovingWidth: 0,
114
+ leafEdgesRightMainStart: 0.246,
115
+ leafEdgesRightMainWidth: 0.006,
116
+ leafEdgesRightEnd: 0.252,
117
+ leafEdgesRightFullWidth: 0.006,
118
+ spreadWidth: 0.492,
119
+ bookWidth: 0.498
120
+ };
121
+ const SPREAD_EXPECTED = {
122
+ leafEdgesLeftStart: -0.246,
123
+ leafEdgesLeftMainWidth: 0.002,
124
+ leafEdgesLeftMovingStart: -0.244,
125
+ leafEdgesLeftMovingWidth: 0,
126
+ leafEdgesLeftEnd: -0.244,
127
+ leafEdgesLeftFullWidth: 0.002,
128
+ pageLeftStart: -0.244,
129
+ pageLeftWidth: 0.246,
130
+ pageLeftEnd: 0.002,
131
+ gutter: 0.002,
132
+ pageRightStart: 0.002,
133
+ pageRightWidth: 0.246,
134
+ pageRightEnd: 0.248,
135
+ leafEdgesRightStart: 0.248,
136
+ leafEdgesRightMovingWidth: 0,
137
+ leafEdgesRightMainStart: 0.248,
138
+ leafEdgesRightMainWidth: 0.004,
139
+ leafEdgesRightEnd: 0.252,
140
+ leafEdgesRightFullWidth: 0.004,
141
+ spreadWidth: 0.492,
142
+ bookWidth: 0.498
143
+ };
144
+ const RIGHT_COVER_EXPECTED = {
145
+ leafEdgesLeftStart: -0.242,
146
+ leafEdgesLeftMainWidth: 0.006,
147
+ leafEdgesLeftMovingStart: -0.236,
148
+ leafEdgesLeftMovingWidth: 0,
149
+ leafEdgesLeftEnd: -0.236,
150
+ leafEdgesLeftFullWidth: 0.006,
151
+ pageLeftStart: -0.236,
152
+ pageLeftWidth: 0.246,
153
+ pageLeftEnd: 0.01,
154
+ gutter: 0.01,
155
+ pageRightStart: 0.01,
156
+ pageRightWidth: 0,
157
+ pageRightEnd: 0.01,
158
+ leafEdgesRightStart: 0.01,
159
+ leafEdgesRightMovingWidth: 0,
160
+ leafEdgesRightMainStart: 0.01,
161
+ leafEdgesRightMainWidth: 0,
162
+ leafEdgesRightEnd: 0.01,
163
+ leafEdgesRightFullWidth: 0,
164
+ spreadWidth: 0.246,
165
+ bookWidth: 0.252
166
+ };
167
+
168
+ test("left cover page", () => {
169
+ const br = make_dummy_br({ data: SAMPLE_DATA });
170
+ const book = new BookModel(br);
171
+ const mode = new Mode2UpLit(book, br);
172
+ expect(mode.computePositions(null, book.getPage(0))).toEqual(LEFT_COVER_EXPECTED);
173
+ });
174
+
175
+ test("spread", () => {
176
+ const br = make_dummy_br({ data: SAMPLE_DATA });
177
+ const book = new BookModel(br);
178
+ const mode = new Mode2UpLit(book, br);
179
+
180
+ expect(mode.computePositions(book.getPage(1), book.getPage(2))).toEqual(SPREAD_EXPECTED);
181
+ });
182
+
183
+ test("right cover page", () => {
184
+ const br = make_dummy_br({ data: SAMPLE_DATA });
185
+ const book = new BookModel(br);
186
+ const mode = new Mode2UpLit(book, br);
187
+
188
+ expect(mode.computePositions(book.getPage(-1), null)).toEqual(RIGHT_COVER_EXPECTED);
189
+ });
190
+ });
@@ -0,0 +1,16 @@
1
+ import { ModeCoordinateSpace } from "@/src/BookReader/ModeCoordinateSpace";
2
+
3
+ describe("worldUnitsToRenderedPixels", () => {
4
+ test("0 case", () => {
5
+ const mcs = new ModeCoordinateSpace({ scale: 1 });
6
+ expect(mcs.worldUnitsToRenderedPixels(0)).toBe(0);
7
+ });
8
+
9
+ test("Misc cases", () => {
10
+ const mcs = new ModeCoordinateSpace({ scale: 1 });
11
+ mcs.screenDPI = 100;
12
+ expect(mcs.worldUnitsToRenderedPixels(1)).toBe(100);
13
+ mcs.screenDPI = 78;
14
+ expect(mcs.worldUnitsToRenderedPixels(1)).toBe(78);
15
+ });
16
+ });
@@ -0,0 +1,218 @@
1
+ import sinon from 'sinon';
2
+ import interact from 'interactjs';
3
+ import { EventTargetSpy, afterEventLoop } from '../utils.js';
4
+ import { ModeSmoothZoom, TouchesMonitor } from '@/src/BookReader/ModeSmoothZoom.js';
5
+ /** @typedef {import('@/src/BookReader/ModeSmoothZoom.js').SmoothZoomable} SmoothZoomable */
6
+
7
+ /**
8
+ * @param {Partial<SmoothZoomable>} overrides
9
+ * @returns {SmoothZoomable}
10
+ */
11
+ function dummy_mode(overrides = {}) {
12
+ return {
13
+ $container: document.createElement('div'),
14
+ $visibleWorld: document.createElement('div'),
15
+ scale: 1,
16
+ htmlDimensionsCacher: {
17
+ clientWidth: 100,
18
+ clientHeight: 100,
19
+ boundingClientRect: { left: 0, top: 0 },
20
+ },
21
+ scaleCenter: {x: 0.5, y: 0.5},
22
+ ...overrides
23
+ };
24
+ }
25
+
26
+ afterEach(() => {
27
+ sinon.restore();
28
+ try {
29
+ interact.removeDocument(document);
30
+ } catch (e) {}
31
+ });
32
+
33
+ describe('ModeSmoothZoom', () => {
34
+ test('handle iOS-only gesture events', () => {
35
+ const mode = dummy_mode();
36
+ const msz = new ModeSmoothZoom(mode);
37
+ sinon.stub(msz, '_pinchStart');
38
+ sinon.stub(msz, '_pinchMove');
39
+ sinon.stub(msz, '_pinchEnd');
40
+
41
+ msz.attach();
42
+
43
+ const gesturestart = new Event('gesturestart', {});
44
+ mode.$container.dispatchEvent(gesturestart);
45
+ expect(msz._pinchStart.callCount).toBe(1);
46
+ });
47
+
48
+ test('sets will-change', async () => {
49
+ const mode = dummy_mode();
50
+ const msz = new ModeSmoothZoom(mode);
51
+ msz.attach();
52
+ expect(mode.$visibleWorld.style.willChange).toBeFalsy();
53
+ msz._pinchStart();
54
+ expect(mode.$visibleWorld.style.willChange).toBe('transform');
55
+ await msz._pinchEnd();
56
+ expect(mode.$visibleWorld.style.willChange).toBe('auto');
57
+ });
58
+
59
+ test('pinch move updates scale', () => {
60
+ const mode = dummy_mode();
61
+ const msz = new ModeSmoothZoom(mode);
62
+ msz.attach();
63
+ // disable buffering
64
+ msz.bufferFn = (callback) => callback();
65
+ msz._pinchStart();
66
+ expect(mode.scale).toBe(1);
67
+ msz._pinchMove({ scale: 2, center: { x: 0, y: 0 }});
68
+ expect(mode.scale).toBe(2);
69
+ });
70
+
71
+ test('updateScaleCenter sets scaleCenter in unitless coordinates', () => {
72
+ const mode = dummy_mode({
73
+ htmlDimensionsCacher: {
74
+ clientWidth: 200,
75
+ clientHeight: 100,
76
+ boundingClientRect: {
77
+ left: 5,
78
+ top: 50
79
+ }
80
+ }
81
+ });
82
+ const msz = new ModeSmoothZoom(mode);
83
+ expect(msz.scaleCenter).toEqual({ x: 0.5, y: 0.5 });
84
+ msz.updateScaleCenter({ clientX: 85, clientY: 110 });
85
+ expect(msz.scaleCenter).toEqual({ x: 0.4, y: 0.6 });
86
+ });
87
+
88
+ test('detaches all listeners', async () => {
89
+ const mode = dummy_mode();
90
+ const msz = new ModeSmoothZoom(mode);
91
+
92
+ const documentEventSpy = EventTargetSpy.wrap(document);
93
+ const containerEventSpy = EventTargetSpy.wrap(mode.$container);
94
+ const visibleWorldSpy = EventTargetSpy.wrap(mode.$visibleWorld);
95
+
96
+ msz.attach();
97
+ await afterEventLoop();
98
+ expect(documentEventSpy._totalListenerCount).toBeGreaterThan(0);
99
+ expect(containerEventSpy._totalListenerCount).toBeGreaterThan(0);
100
+
101
+ msz.detach();
102
+ expect(documentEventSpy._totalListenerCount).toBe(0);
103
+ expect(containerEventSpy._totalListenerCount).toBe(0);
104
+ expect(visibleWorldSpy._totalListenerCount).toBe(0);
105
+ });
106
+
107
+ test('attach can be called twice without double attachments', () => {
108
+ const mode = dummy_mode();
109
+ const msz = new ModeSmoothZoom(mode);
110
+
111
+ const documentEventSpy = EventTargetSpy.wrap(document);
112
+ const containerEventSpy = EventTargetSpy.wrap(mode.$container);
113
+ const visibleWorldSpy = EventTargetSpy.wrap(mode.$visibleWorld);
114
+
115
+ msz.attach();
116
+ const documentListenersCount = documentEventSpy._totalListenerCount;
117
+ const containerListenersCount = containerEventSpy._totalListenerCount;
118
+ const visibleWorldListenersCount = visibleWorldSpy._totalListenerCount;
119
+
120
+ msz.attach();
121
+ expect(documentEventSpy._totalListenerCount).toBe(documentListenersCount);
122
+ expect(containerEventSpy._totalListenerCount).toBe(containerListenersCount);
123
+ expect(visibleWorldSpy._totalListenerCount).toBe(visibleWorldListenersCount);
124
+ });
125
+
126
+ describe('_handleCtrlWheel', () => {
127
+ test('non-ctrl wheel events ignored', () => {
128
+ const mode = dummy_mode();
129
+ const msz = new ModeSmoothZoom(mode);
130
+ expect(mode.scale).toBe(1);
131
+ const ev = new WheelEvent('wheel', { ctrlKey: false, deltaY: 20 });
132
+ const preventDefaultSpy = sinon.spy(ev, 'preventDefault');
133
+ msz._handleCtrlWheel(ev);
134
+ expect(preventDefaultSpy.callCount).toBe(0);
135
+ expect(mode.scale).toBe(1);
136
+ });
137
+
138
+ test('ctrl-wheel events update scale', () => {
139
+ const mode = dummy_mode();
140
+ const msz = new ModeSmoothZoom(mode);
141
+ expect(mode.scale).toBe(1);
142
+ const ev = new WheelEvent('wheel', { ctrlKey: true, deltaY: 20 });
143
+ const preventDefaultSpy = sinon.spy(ev, 'preventDefault');
144
+ msz._handleCtrlWheel(ev);
145
+ expect(preventDefaultSpy.callCount).toBe(1);
146
+ expect(mode.scale).not.toBe(1);
147
+ });
148
+ });
149
+
150
+ describe("updateViewportOnZoom", () => {
151
+ test("adjusts scroll position when zooming in", () => {
152
+ const mode = dummy_mode();
153
+ const msz = new ModeSmoothZoom(mode);
154
+ mode.$container.scrollTop = 100;
155
+ mode.$container.scrollLeft = 100;
156
+
157
+ msz.updateViewportOnZoom(2, 1);
158
+
159
+ expect(mode.$container.scrollTop).toBeGreaterThan(100);
160
+ expect(mode.$container.scrollLeft).toBeGreaterThan(100);
161
+ });
162
+
163
+ test("updates scroll position when zooming out", () => {
164
+ const mode = dummy_mode();
165
+ const msz = new ModeSmoothZoom(mode);
166
+ mode.$container.scrollTop = 100;
167
+ mode.$container.scrollLeft = 100;
168
+
169
+ msz.updateViewportOnZoom(0.5, 1);
170
+
171
+ expect(mode.$container.scrollTop).toBeLessThan(100);
172
+ expect(mode.$container.scrollLeft).toBeLessThan(100);
173
+ });
174
+ });
175
+ });
176
+
177
+
178
+ describe("TouchesMonitor", () => {
179
+ /** @type {HTMLElement} */
180
+ let container;
181
+ /** @type {TouchesMonitor} */
182
+ let monitor;
183
+
184
+ beforeEach(() => {
185
+ container = document.createElement("div");
186
+ monitor = new TouchesMonitor(container);
187
+ });
188
+
189
+ afterEach(() => {
190
+ monitor.detach();
191
+ });
192
+
193
+ test("should start with 0 touches", () => {
194
+ expect(monitor.touches).toBe(0);
195
+ });
196
+
197
+ test("should update touch count on touch events", () => {
198
+ monitor.attach();
199
+ container.dispatchEvent(new TouchEvent("touchstart", { touches: [{}] }));
200
+ expect(monitor.touches).toBe(1);
201
+
202
+ container.dispatchEvent(new TouchEvent("touchstart", { touches: [{}, {}] }));
203
+ expect(monitor.touches).toBe(2);
204
+
205
+ container.dispatchEvent(new TouchEvent("touchend", { touches: [{}] }));
206
+ expect(monitor.touches).toBe(1);
207
+
208
+ container.dispatchEvent(new TouchEvent("touchend", { touches: [] }));
209
+ });
210
+
211
+ test("should detach all listeners", () => {
212
+ const spy = EventTargetSpy.wrap(container);
213
+ monitor.attach();
214
+ expect(spy._totalListenerCount).toBeGreaterThan(0);
215
+ monitor.detach();
216
+ expect(spy._totalListenerCount).toBe(0);
217
+ });
218
+ });
@@ -0,0 +1,71 @@
1
+
2
+ import sinon from 'sinon';
3
+ import BookReader from '@/src/BookReader.js';
4
+ /** @typedef {import('@/src/BookReader/options.js').BookReaderOptions} BookReaderOptions */
5
+
6
+ beforeAll(() => {
7
+ global.alert = jest.fn();
8
+ });
9
+ afterEach(() => {
10
+ jest.restoreAllMocks();
11
+ sinon.restore();
12
+ });
13
+
14
+ /** @type {BookReaderOptions['data']} */
15
+ const SAMPLE_DATA = [
16
+ [
17
+ { width: 123, height: 123, uri: 'https://archive.org/image0.jpg', pageNum: '1' },
18
+ ],
19
+ [
20
+ { width: 123, height: 123, uri: 'https://archive.org/image1.jpg', pageNum: '2' },
21
+ { width: 123, height: 123, uri: 'https://archive.org/image2.jpg', pageNum: '3' },
22
+ ],
23
+ [
24
+ { width: 123, height: 123, uri: 'https://archive.org/image3.jpg', pageNum: '4' },
25
+ { width: 123, height: 123, uri: 'https://archive.org/image4.jpg', pageNum: '5' },
26
+ ],
27
+ [
28
+ { width: 123, height: 123, uri: 'https://archive.org/image5.jpg', pageNum: '6' },
29
+ ],
30
+ ];
31
+
32
+ describe('zoom', () => {
33
+ const br = new BookReader({ data: SAMPLE_DATA });
34
+ br.init();
35
+
36
+ test('initializes with default columns', () => {
37
+ expect(br.thumbColumns).toBe(br.options.thumbColumns);
38
+ });
39
+
40
+ test('removes column and redraws zooming in', () => {
41
+ const prepare = sinon.spy(br._modes.modeThumb, 'prepare');
42
+ const startColumns = br.thumbColumns;
43
+ br._modes.modeThumb.zoom('in');
44
+ expect(br.thumbColumns).toBe(startColumns - 1);
45
+ expect(prepare.callCount).toBe(1);
46
+ });
47
+
48
+ test('adds column and redraws zooming out', () => {
49
+ const prepare = sinon.spy(br._modes.modeThumb, 'prepare');
50
+ const startColumns = br.thumbColumns;
51
+ br._modes.modeThumb.zoom('out');
52
+ expect(br.thumbColumns).toBe(startColumns + 1);
53
+ expect(prepare.callCount).toBe(1);
54
+ });
55
+
56
+ test('keeps columns and no redraw at zooming in limit', () => {
57
+ const prepare = sinon.spy(br._modes.modeThumb, 'prepare');
58
+ br.thumbColumns = br.options.thumbMinZoomColumns;
59
+ br._modes.modeThumb.zoom('in');
60
+ expect(br.thumbColumns).toBe(br.options.thumbMinZoomColumns);
61
+ expect(prepare.callCount).toBe(0);
62
+ });
63
+
64
+ test('keeps columns and no redraw at zooming out limit', () => {
65
+ const prepare = sinon.spy(br._modes.modeThumb, 'prepare');
66
+ br.thumbColumns = br.options.thumbMaxZoomColumns;
67
+ br._modes.modeThumb.zoom('out');
68
+ expect(br.thumbColumns).toBe(br.options.thumbMaxZoomColumns);
69
+ expect(prepare.callCount).toBe(0);
70
+ });
71
+ });
@@ -1,19 +1,19 @@
1
1
  import sinon from 'sinon';
2
- import { getNavPageNumHtml } from '../../../src/BookReader/Navbar/Navbar.js';
3
- import BookReader from '../../../src/BookReader.js';
2
+ import { getNavPageNumHtml } from '@/src/BookReader/Navbar/Navbar.js';
3
+ import BookReader from '@/src/BookReader.js';
4
4
 
5
5
  describe('getNavPageNumHtml', () => {
6
6
  const f = getNavPageNumHtml;
7
7
  test('handle n-prefixed page numbers', () => {
8
- expect(f(3, 40, 'n3', '', 40)).toBe('Page (4 of 40)');
8
+ expect(f(3, 40, 'n3', '', 40)).toBe('(4 of 40)');
9
9
  });
10
10
 
11
11
  test('handle regular page numbers', () => {
12
- expect(f(3, 40, '14', '', 40)).toBe('Page 14 of 40');
12
+ expect(f(3, 40, '14', '', 40)).toBe('14 of 40');
13
13
  });
14
14
 
15
15
  test('handle no max page', () => {
16
- expect(f(3, 40, '14', '', null)).toBe('Page 14');
16
+ expect(f(3, 40, '14', '', null)).toBe('14');
17
17
  });
18
18
  });
19
19
 
@@ -63,14 +63,14 @@ describe('Navbar slider', () => {
63
63
 
64
64
  test('on slide change, actual page changes', () => {
65
65
  const $slider = navbar.$root.find('.BRpager');
66
- const jumpToIndexSpy = sinon.spy(br, 'jumpToIndex');
66
+ const jumpToIndexStub = sinon.stub(br, 'jumpToIndex');
67
67
  expect(br.currentIndex()).toBe(0);
68
68
 
69
69
  $slider.trigger('slidechange', { value: 3 });
70
70
 
71
71
  expect(navbar.$root.find('.BRcurrentpage').text().includes('3'));
72
- expect(jumpToIndexSpy.callCount).toBe(1);
73
- expect(jumpToIndexSpy.args[0][0]).toBe(3);
72
+ expect(jumpToIndexStub.callCount).toBe(1);
73
+ expect(jumpToIndexStub.args[0][0]).toBe(3);
74
74
  });
75
75
  });
76
76
 
@@ -97,9 +97,9 @@ describe('Navbar controls overrides', () => {
97
97
  const $viewMode = navbar.$root.find('.viewmode');
98
98
 
99
99
  expect($viewMode.find('.icon-thumb').length).toBe(1);
100
- $viewMode.click();
100
+ $viewMode.trigger("click");
101
101
  expect($viewMode.find('.icon-twopg').length).toBe(1);
102
- $viewMode.click();
102
+ $viewMode.trigger("click");
103
103
  expect($viewMode.find('.icon-thumb').length).toBe(1);
104
104
  });
105
105