|
| 1 | +import createConnectedInstances from './create-connected-instances' |
| 2 | +import {iposMessagingType} from '../messaging' |
| 3 | + |
| 4 | +async function testMalformedMessageNotToThrow(type: iposMessagingType, data?: {}) { |
| 5 | + const {main_ipos, sub_ipos, sub_process} = await createConnectedInstances() |
| 6 | + // @ts-ignore |
| 7 | + expect(() => main_ipos.sendToAll(type, data)).not.toThrow() |
| 8 | +} |
| 9 | + |
| 10 | +describe('Sending malformed messages', () => { |
| 11 | + it('Set message without "key"/"value"', async () => { |
| 12 | + await testMalformedMessageNotToThrow('set', {}) |
| 13 | + }) |
| 14 | + |
| 15 | + it('Update message without "do"/"on"', async () => { |
| 16 | + await testMalformedMessageNotToThrow('update', {}) |
| 17 | + }) |
| 18 | + |
| 19 | + it('Update message without "with"', async () => { |
| 20 | + await testMalformedMessageNotToThrow('update', { |
| 21 | + do: '$$iposDefine', |
| 22 | + on: 'myKey', |
| 23 | + }) |
| 24 | + }) |
| 25 | + |
| 26 | + it('Delete message without "key"', async () => { |
| 27 | + await testMalformedMessageNotToThrow('delete', {}) |
| 28 | + }) |
| 29 | + |
| 30 | + it('Delete message without "key"', async () => { |
| 31 | + await testMalformedMessageNotToThrow('delete', {}) |
| 32 | + }) |
| 33 | + |
| 34 | + it('Sync message without "fields"', async () => { |
| 35 | + await testMalformedMessageNotToThrow('sync', {}) |
| 36 | + }) |
| 37 | +}) |
0 commit comments