diff --git a/js/modules/debug.js b/js/modules/debug.js index 7a3f7fd28..cfa39cd45 100644 --- a/js/modules/debug.js +++ b/js/modules/debug.js @@ -91,31 +91,32 @@ const createRandomMessage = ({ conversationId } = {}) => { type, }; - const message = (() => { - switch (type) { - case 'incoming': - return Object.assign({}, commonProperties, { - flags: 0, - source: conversationId, - sourceDevice: 1, - }); - case 'outgoing': - return Object.assign({}, commonProperties, { - delivered: 1, - delivered_to: [conversationId], - expireTimer: 0, - recipients: [conversationId], - sent_to: [conversationId], - synced: true, - }); - default: - throw new TypeError(`Unknown message type: '${type}'`); - } - })(); - + const message = _createMessage({ commonProperties, conversationId, type }); return Message.initializeSchemaVersion(message); }; +const _createMessage = ({ commonProperties, conversationId, type } = {}) => { + switch (type) { + case 'incoming': + return Object.assign({}, commonProperties, { + flags: 0, + source: conversationId, + sourceDevice: 1, + }); + case 'outgoing': + return Object.assign({}, commonProperties, { + delivered: 1, + delivered_to: [conversationId], + expireTimer: 0, + recipients: [conversationId], + sent_to: [conversationId], + synced: true, + }); + default: + throw new TypeError(`Unknown message type: '${type}'`); + } +}; + const MEGA_BYTE = 1e6; const createRandomInMemoryAttachment = () => { const numBytes = (1 + Math.ceil((Math.random() * 50))) * MEGA_BYTE;