import Response from '../src/response'; describe('parse', () => { it('with group chat message one returns expected', () => { const msg = 'CMDC_RESULT code=2000 reason=OK\r\nCMDC_VALUE _t2=7036\r\nCMDC_VALUE _ds=43\r\nCMDC_CMSG messageKey=23a7d4c627454fcfa033a2314895a497 style=g sound=text msgType=chat from=andrei text=%20message%20from%20another%20user\r\n'; const response = Response.parse(msg); const expectedResponse = new Response(2000, 'OK'); expectedResponse.ok = true; expectedResponse.time = 0; expectedResponse.values = { _t2: '7036', _ds: '43' }; expectedResponse.commands = [ { command: 'CMSG', id: undefined, values: { messageKey: '23a7d4c627454fcfa033a2314895a497', style: 'g', sound: 'text', msgType: 'chat', from: 'andrei', text: ' message from another user', }, }, ]; expect(response).toEqual(expectedResponse); }); it('with group chat message two returns expected', () => { const msg = 'CMDC_RESULT code=2000 reason=OK\r\nCMDC_VALUE _t2=4003\r\nCMDC_VALUE _ds=43\r\nCMDC_CMSG messageKey=0b0ada469989432eb44d838d64aeebc5 style=g sound=text msgType=chat from=andrei text=%20here%20we%20have%20andrei\r\n'; const response = Response.parse(msg); const expectedResponse = new Response(2000, 'OK'); expectedResponse.ok = true; expectedResponse.time = 0; expectedResponse.values = { _t2: '4003', _ds: '43' }; expectedResponse.commands = [ { command: 'CMSG', id: undefined, values: { messageKey: '0b0ada469989432eb44d838d64aeebc5', style: 'g', sound: 'text', msgType: 'chat', from: 'andrei', text: ' here we have andrei', }, }, ]; expect(response).toEqual(expectedResponse); }); });