From add4b11df3812b19eea6a83e3ac7c62526fe8fff Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Tue, 13 Mar 2018 21:47:56 -0400 Subject: [PATCH] Skip invalid attachments and make function sync --- js/modules/types/attachment.js | 7 ++++++- test/modules/types/attachment_test.js | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/modules/types/attachment.js b/js/modules/types/attachment.js index 27e7416b5..1e09ad338 100644 --- a/js/modules/types/attachment.js +++ b/js/modules/types/attachment.js @@ -176,7 +176,12 @@ exports._replaceUnicodeOrderOverridesSync = (attachment) => { exports.replaceUnicodeOrderOverrides = async attachment => exports._replaceUnicodeOrderOverridesSync(attachment); -exports.removeSchemaVersion = async (attachment) => { +exports.removeSchemaVersion = (attachment) => { + if (!exports.isValid(attachment)) { + console.log('Attachment.removeSchemaVersion: Invalid input attachment:', attachment); + return attachment; + } + const attachmentWithoutSchemaVersion = Object.assign({}, attachment); delete attachmentWithoutSchemaVersion.schemaVersion; return attachmentWithoutSchemaVersion; diff --git a/test/modules/types/attachment_test.js b/test/modules/types/attachment_test.js index bc79b3768..305d16194 100644 --- a/test/modules/types/attachment_test.js +++ b/test/modules/types/attachment_test.js @@ -245,7 +245,7 @@ describe('Attachment', () => { }); describe('removeSchemaVersion', () => { - it('should remove existing schema version', async () => { + it('should remove existing schema version', () => { const input = { contentType: 'image/jpeg', data: null, @@ -261,7 +261,7 @@ describe('Attachment', () => { size: 1111, }; - const actual = await Attachment.removeSchemaVersion(input); + const actual = Attachment.removeSchemaVersion(input); assert.deepEqual(actual, expected); }); });