diff --git a/src/lib/icons/icons.js b/src/lib/icons/icons.js index 681e17e90..afae71fe6 100644 --- a/src/lib/icons/icons.js +++ b/src/lib/icons/icons.js @@ -167,7 +167,7 @@ export const ICON_FILE_MAP = {}; }); // EXCEL ICON EXTENSIONS -['xls', 'xlsm', 'xlsx'].forEach((extension) => { +['xls', 'xlsm', 'xlsx', 'xlsb'].forEach((extension) => { ICON_FILE_MAP[extension] = 'FILE_EXCEL'; }); diff --git a/src/lib/viewers/office/OfficeLoader.js b/src/lib/viewers/office/OfficeLoader.js index f8b3aea7e..355c69b6d 100644 --- a/src/lib/viewers/office/OfficeLoader.js +++ b/src/lib/viewers/office/OfficeLoader.js @@ -12,7 +12,7 @@ const VIEWERS = [ NAME: 'Office', CONSTRUCTOR: OfficeViewer, REP: ORIGINAL_REP_NAME, - EXT: ['xlsx'] + EXT: ['xlsx', 'xlsm', 'xlsb'] } ]; diff --git a/src/lib/viewers/office/README.md b/src/lib/viewers/office/README.md index 032a06ada..0b67953b2 100755 --- a/src/lib/viewers/office/README.md +++ b/src/lib/viewers/office/README.md @@ -17,7 +17,7 @@ There are several limitations at the moment: ## Supported File Extensions -`xlsx` +`xlsx`, `xlsm`, `xlsb` ## Events diff --git a/src/lib/viewers/office/__tests__/OfficeLoader-test.js b/src/lib/viewers/office/__tests__/OfficeLoader-test.js index fa8900a73..e23b31de9 100644 --- a/src/lib/viewers/office/__tests__/OfficeLoader-test.js +++ b/src/lib/viewers/office/__tests__/OfficeLoader-test.js @@ -4,74 +4,82 @@ import * as file from '../../../file'; import { PERMISSION_DOWNLOAD } from '../../../constants'; const sandbox = sinon.sandbox.create(); -let fakeFile; describe('lib/viewers/office/OfficeLoader', () => { - beforeEach(() => { - fakeFile = { - extension: 'xlsx', - size: 1000, - permissions: { - can_download: true - }, - representations: { - entries: [ - { - representation: 'ORIGINAL' - } - ] - } - }; - }); + const fakeFileTemplate = { + size: 1000, + permissions: { + can_download: true + }, + representations: { + entries: [ + { + representation: 'ORIGINAL' + } + ] + } + }; afterEach(() => { sandbox.verifyAndRestore(); }); describe('determineViewer()', () => { - it('should choose the Office viewer if it is not disabled and the file is ok', () => { - const viewer = OfficeLoader.determineViewer(fakeFile); - expect(viewer).to.deep.equal({ - NAME: 'Office', - CONSTRUCTOR: OfficeViewer, - REP: 'ORIGINAL', - EXT: ['xlsx'] - }); - }); - - it('should choose the Office viewer if it is not disabled and the file is a shared link that is not password-protected', () => { - fakeFile.shared_link = { - is_password_enabled: false - }; + const fakeFiles = [ + Object.assign({}, fakeFileTemplate, { extension: 'xlsx' }), + Object.assign({}, fakeFileTemplate, { extension: 'xlsm' }), + Object.assign({}, fakeFileTemplate, { extension: 'xlsb' }) + ]; - const viewer = OfficeLoader.determineViewer(fakeFile); - expect(viewer.NAME).to.equal('Office'); - }); + fakeFiles.forEach((fakeFile) => { + it('should choose the Office viewer if it is not disabled and the file is ok', () => { + const viewer = OfficeLoader.determineViewer(fakeFile); + expect(viewer).to.deep.equal({ + NAME: 'Office', + CONSTRUCTOR: OfficeViewer, + REP: 'ORIGINAL', + EXT: ['xlsx', 'xlsm', 'xlsb'] + }); + }); - it('should not return a viewer if the Office viewer is disabled', () => { - const viewer = OfficeLoader.determineViewer(fakeFile, ['Office']); - expect(viewer).to.equal(undefined); - }); + it('should choose the Office viewer if it is not disabled and the file is a shared link that is not password-protected', () => { + const editedFakeFile = fakeFile; + editedFakeFile.shared_link = { + is_password_enabled: false + }; + const viewer = OfficeLoader.determineViewer(editedFakeFile); + expect(viewer.NAME).to.equal('Office'); + }); - it('should not return a viewer if the file is too large', () => { - fakeFile.size = 5242881; - const viewer = OfficeLoader.determineViewer(fakeFile, []); - expect(viewer).to.equal(undefined); - }); + it('should not return a viewer if the Office viewer is disabled', () => { + const viewer = OfficeLoader.determineViewer(fakeFile, ['Office']); + expect(viewer).to.equal(undefined); + }); - it('should not return a viewer if the user does not have download permissions', () => { - sandbox.stub(file, 'checkPermission').withArgs(fakeFile, PERMISSION_DOWNLOAD).returns(false); - const viewer = OfficeLoader.determineViewer(fakeFile, []); - expect(viewer).to.equal(undefined); - }); + it('should not return a viewer if the file is too large', () => { + const editedFakeFile = fakeFile; + editedFakeFile.size = 5242881; + const viewer = OfficeLoader.determineViewer(editedFakeFile, []); + expect(viewer).to.equal(undefined); + }); - it('should not return a viewer if the file is a password-protected shared link', () => { - fakeFile.shared_link = { - is_password_enabled: true - }; + it('should not return a viewer if the user does not have download permissions', () => { + sandbox + .stub(file, 'checkPermission') + .withArgs(fakeFile, PERMISSION_DOWNLOAD) + .returns(false); + const viewer = OfficeLoader.determineViewer(fakeFile, []); + expect(viewer).to.equal(undefined); + }); - const viewer = OfficeLoader.determineViewer(fakeFile, []); - expect(viewer).to.equal(undefined); + it('should not return a viewer if the file is a password-protected shared link', () => { + const editedFakeFile = fakeFile; + editedFakeFile.shared_link = { + is_password_enabled: true + }; + const viewer = OfficeLoader.determineViewer(editedFakeFile, []); + expect(viewer).to.equal(undefined); + }); }); }); });