Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Set up notification in Preview.finishLoading() #579

Merged
merged 1 commit into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/lib/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1064,14 +1064,17 @@ 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();
}

// Hide the loading indicator
this.ui.hideLoadingIndicator();

// Set up the notification
this.ui.setupNotification();

// Prefetch next few files
this.prefetchNextFiles();
}
Expand Down
13 changes: 10 additions & 3 deletions src/lib/PreviewUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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.
*
Expand Down
6 changes: 6 additions & 0 deletions src/lib/__tests__/Preview-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions src/lib/__tests__/PreviewUI-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()', () => {
Expand Down