Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: replacing .keynote extension with .key #36

Merged
merged 1 commit into from
Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reminds me we should add a test for these errors!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests added!

};

export const PREVIEW_SCRIPT_NAME = 'preview.js';