Skip to content

Commit

Permalink
Fix: fix excel setup when enabling the Office viewer via options (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Press authored May 22, 2017
1 parent 81802c1 commit e8145f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib/viewers/office/OfficeViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class OfficeViewer extends BaseViewer {
super.setup();
// Set to false only in the WebApp, everywhere else we want to avoid hitting a runmode.
// This flag will be removed once we run the entire integration through the client.
this.platformSetup = this.options.viewers.Office ? !!this.options.viewers.Office.shouldUsePlatformSetup : true;
const hasSetupOption = this.options.viewers.Office && 'shouldUsePlatformSetup' in this.options.viewers.Office;
this.platformSetup = hasSetupOption ? !!this.options.viewers.Office.shouldUsePlatformSetup : true;
this.setupIframe();
this.initPrint();
this.setupPDFUrl();
Expand Down
16 changes: 15 additions & 1 deletion src/lib/viewers/office/__tests__/OfficeViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,30 @@ describe('lib/viewers/office/OfficeViewer', () => {
expect(stubs.setupPDFUrl).to.be.called;
});

it('should not use the platform setup if the option is passed in', () => {
it('should not determine setup based on the option if it is passed in', () => {
office.setup();
expect(office.platformSetup).to.be.false;

office.options.viewers.Office.shouldUsePlatformSetup = true;
office.setup();
expect(office.platformSetup).to.be.true;
});

it('should use the platform setup if no option is passed in', () => {
office.options.viewers = {};
office.setup();
expect(office.platformSetup).to.be.true;
});

it('should still use the platform setup if the viewer option, but no setup option exists', () => {
office.options.viewers = {
Office: {
disabled: false
}
};
office.setup();
expect(office.platformSetup).to.be.true;
});
});

describe('destroy()', () => {
Expand Down

0 comments on commit e8145f5

Please sign in to comment.