From e8145f5f954271325cfd65a9d9378a46fc66ce63 Mon Sep 17 00:00:00 2001 From: Jeremy Press Date: Mon, 22 May 2017 13:21:49 -0700 Subject: [PATCH] Fix: fix excel setup when enabling the Office viewer via options (#126) --- src/lib/viewers/office/OfficeViewer.js | 3 ++- .../office/__tests__/OfficeViewer-test.js | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lib/viewers/office/OfficeViewer.js b/src/lib/viewers/office/OfficeViewer.js index 020a6d7cc..d5db60fb3 100644 --- a/src/lib/viewers/office/OfficeViewer.js +++ b/src/lib/viewers/office/OfficeViewer.js @@ -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(); diff --git a/src/lib/viewers/office/__tests__/OfficeViewer-test.js b/src/lib/viewers/office/__tests__/OfficeViewer-test.js index 9beb0d615..61bf9833c 100644 --- a/src/lib/viewers/office/__tests__/OfficeViewer-test.js +++ b/src/lib/viewers/office/__tests__/OfficeViewer-test.js @@ -80,9 +80,13 @@ 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', () => { @@ -90,6 +94,16 @@ describe('lib/viewers/office/OfficeViewer', () => { 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()', () => {