Add Attachment.removeSchemaVersion
This commit is contained in:
parent
37d35db3c3
commit
3dfc823716
2 changed files with 28 additions and 0 deletions
|
@ -176,6 +176,12 @@ exports._replaceUnicodeOrderOverridesSync = (attachment) => {
|
||||||
exports.replaceUnicodeOrderOverrides = async attachment =>
|
exports.replaceUnicodeOrderOverrides = async attachment =>
|
||||||
exports._replaceUnicodeOrderOverridesSync(attachment);
|
exports._replaceUnicodeOrderOverridesSync(attachment);
|
||||||
|
|
||||||
|
exports.removeSchemaVersion = async (attachment) => {
|
||||||
|
const attachmentWithoutSchemaVersion = Object.assign({}, attachment);
|
||||||
|
delete attachmentWithoutSchemaVersion.schemaVersion;
|
||||||
|
return attachmentWithoutSchemaVersion;
|
||||||
|
};
|
||||||
|
|
||||||
// Public API
|
// Public API
|
||||||
const toVersion1 = exports.withSchemaVersion(1, autoOrientJPEG);
|
const toVersion1 = exports.withSchemaVersion(1, autoOrientJPEG);
|
||||||
const toVersion2 = exports.withSchemaVersion(2, exports.replaceUnicodeOrderOverrides);
|
const toVersion2 = exports.withSchemaVersion(2, exports.replaceUnicodeOrderOverrides);
|
||||||
|
|
|
@ -243,4 +243,26 @@ describe('Attachment', () => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('removeSchemaVersion', () => {
|
||||||
|
it('should remove existing schema version', async () => {
|
||||||
|
const input = {
|
||||||
|
contentType: 'image/jpeg',
|
||||||
|
data: null,
|
||||||
|
fileName: 'foo.jpg',
|
||||||
|
size: 1111,
|
||||||
|
schemaVersion: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const expected = {
|
||||||
|
contentType: 'image/jpeg',
|
||||||
|
data: null,
|
||||||
|
fileName: 'foo.jpg',
|
||||||
|
size: 1111,
|
||||||
|
};
|
||||||
|
|
||||||
|
const actual = await Attachment.removeSchemaVersion(input);
|
||||||
|
assert.deepEqual(actual, expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue