From bf41155071230c027cbb565dbba173bf044fe6e9 Mon Sep 17 00:00:00 2001 From: Jeremy Press Date: Wed, 29 Mar 2017 21:07:00 -0700 Subject: [PATCH] Fix: replacing .keynote extension with .key --- src/lib/__tests__/Preview-test.js | 24 ++++++++++++++++++++++++ src/lib/constants.js | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/lib/__tests__/Preview-test.js b/src/lib/__tests__/Preview-test.js index 47dc63f32..67d493a45 100644 --- a/src/lib/__tests__/Preview-test.js +++ b/src/lib/__tests__/Preview-test.js @@ -1195,6 +1195,30 @@ describe('lib/Preview', () => { expect(stubs.showLoadingDownloadButton).to.be.called; }); + it('should throw a generic error if there is no loader for general file types', () => { + preview.file.extension = 'zip'; + stubs.getLoader.returns(undefined); + const spy = sandbox.spy(preview, 'loadViewer'); + + try { + preview.loadViewer(); + } catch (e) { + expect(spy.threw('Error', __('error_default'))); + } + }); + + it('should throw a specific error if there is no loader for a specific file type', () => { + preview.file.extension = 'key'; + stubs.getLoader.returns(undefined); + const spy = sandbox.spy(preview, 'loadViewer'); + + try { + preview.loadViewer(); + } catch (e) { + expect(spy.threw('Error', __('error_iwork'))); + } + }); + it('should get the loader, viewer, and log the type of file', () => { preview.loadViewer(); expect(stubs.getLoader).to.be.calledWith(sinon.match.object); diff --git a/src/lib/constants.js b/src/lib/constants.js index eaf209beb..47206b5b3 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -81,7 +81,7 @@ export const TEXT_STATIC_ASSETS_VERSION = '0.112.0'; export const FILE_EXT_ERROR_MAP = { numbers: __('error_iwork'), pages: __('error_iwork'), - keynote: __('error_iwork') + key: __('error_iwork') }; export const PREVIEW_SCRIPT_NAME = 'preview.js';