diff --git a/src/lib/Preview.js b/src/lib/Preview.js index ea57a4222..27e38d280 100644 --- a/src/lib/Preview.js +++ b/src/lib/Preview.js @@ -1064,7 +1064,7 @@ class Preview extends EventEmitter { this.ui.finishProgressBar(); } - // Programmtically focus on the viewer after it loads + // Programmatically focus on the viewer after it loads if (this.viewer && this.viewer.containerEl) { this.viewer.containerEl.focus(); } @@ -1072,6 +1072,9 @@ class Preview extends EventEmitter { // Hide the loading indicator this.ui.hideLoadingIndicator(); + // Set up the notification + this.ui.setupNotification(); + // Prefetch next few files this.prefetchNextFiles(); } diff --git a/src/lib/PreviewUI.js b/src/lib/PreviewUI.js index a88660dad..d156330ca 100644 --- a/src/lib/PreviewUI.js +++ b/src/lib/PreviewUI.js @@ -117,9 +117,6 @@ class PreviewUI { // Setup progress bar this.progressBar = new ProgressBar(this.container); - // Setup notification - this.notification = new Notification(this.contentContainer); - // Setup loading indicator this.setupLoading(); @@ -292,6 +289,16 @@ class PreviewUI { this.progressBar.finish(); } + /** + * Setup notification + * + * @public + * @return {void} + */ + setupNotification() { + this.notification = new Notification(this.contentContainer); + } + /** * Shows a notification message. * diff --git a/src/lib/__tests__/Preview-test.js b/src/lib/__tests__/Preview-test.js index cc3091d4c..ebd3ee85d 100644 --- a/src/lib/__tests__/Preview-test.js +++ b/src/lib/__tests__/Preview-test.js @@ -1514,6 +1514,7 @@ describe('lib/Preview', () => { stubs.logPreviewEvent = sandbox.stub(preview, 'logPreviewEvent'); stubs.prefetchNextFiles = sandbox.stub(preview, 'prefetchNextFiles'); stubs.finishProgressBar = sandbox.stub(preview.ui, 'finishProgressBar'); + stubs.setupNotification = sandbox.stub(preview.ui, 'setupNotification'); stubs.logger = { done: sandbox.stub() @@ -1649,6 +1650,11 @@ describe('lib/Preview', () => { expect(stubs.hideLoadingIndicator).to.be.called; }); + it('should set up the notification', () => { + preview.finishLoading(); + expect(stubs.setupNotification).to.be.called; + }); + it('should prefetch next files', () => { preview.finishLoading(); expect(stubs.prefetchNextFiles).to.be.called; diff --git a/src/lib/__tests__/PreviewUI-test.js b/src/lib/__tests__/PreviewUI-test.js index da89c9f83..e7091438c 100644 --- a/src/lib/__tests__/PreviewUI-test.js +++ b/src/lib/__tests__/PreviewUI-test.js @@ -57,9 +57,6 @@ describe('lib/PreviewUI', () => { // Check progress bar expect(resultEl).to.contain(constants.SELECTOR_BOX_PREVIEW_PROGRESS_BAR); - // Check notification - expect(resultEl).to.contain(constants.SELECTOR_BOX_PREVIEW_NOTIFICATION); - // Check loading state const loadingWrapperEl = resultEl.querySelector(constants.SELECTOR_BOX_PREVIEW_LOADING_WRAPPER); expect(loadingWrapperEl).to.contain(constants.SELECTOR_BOX_PREVIEW_ICON); @@ -202,6 +199,13 @@ describe('lib/PreviewUI', () => { expect(crawlerEl).to.not.have.class(constants.CLASS_HIDDEN); }); }); + + describe('setupNotification()', () => { + it('should set up the notification', () => { + ui.setupNotification(); + expect(containerEl).to.contain(constants.SELECTOR_BOX_PREVIEW_NOTIFICATION); + }) + }); }); describe('startProgressBar()', () => {