Skip to content

Commit

Permalink
Fix: replacing .keynote extension with .key (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Press authored Mar 30, 2017
1 parent b1f20b4 commit b7eefb7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/lib/__tests__/Preview-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit b7eefb7

Please sign in to comment.