Skip to content

Commit

Permalink
Fix: Only initialize PreviewUI.notification after viewer is loaded (#273
Browse files Browse the repository at this point in the history
)
  • Loading branch information
pramodsum authored Aug 2, 2017
1 parent 2a1e6cd commit 060687b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 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 loading indicator
this.setupLoading();

// Setup notification
this.notification = new Notification(this.contentContainer);

// Attach keyboard events
document.addEventListener('keydown', this.keydownHandler);

Expand Down Expand Up @@ -258,6 +255,9 @@ class PreviewUI {
// part of finishLoadingSetup in BaseViewer.js
crawler.classList.remove(CLASS_HIDDEN);
}

// Setup viewer notification
this.notification = new Notification(this.contentContainer);
}
}

Expand Down
8 changes: 4 additions & 4 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('.bp-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 @@ -190,10 +187,13 @@ describe('lib/PreviewUI', () => {
});

describe('hideLoadingIndicator()', () => {
it('should hide loading indicator', () => {
it('should hide loading indicator and intializes the notification', () => {
const contentContainerEl = containerEl.querySelector(constants.SELECTOR_BOX_PREVIEW);
ui.hideLoadingIndicator();
expect(contentContainerEl).to.have.class(constants.CLASS_PREVIEW_LOADED);

// Check that notification is initialized
expect(contentContainerEl).to.contain('.bp-notification');
});

it('should remove the hidden class from the crawler', () => {
Expand Down

0 comments on commit 060687b

Please sign in to comment.