mock-socket icon indicating copy to clipboard operation
mock-socket copied to clipboard

cannot emit a single array argument

Open olareoun opened this issue 7 years ago • 1 comments

This is the situation:

// emit a message with just one argument that is an array
      mockServer.emit('surveys', [
        { id: 1, name: 'Survey 1' },
        { id: 2, name: 'Survey 2' },
        { id: 3, name: 'Survey 3' }
      ])
// it is received as separated args, that is not the desired situation
    this.socket.on('surveys', data => { // here data is just { id: 1, name: 'Survey 1' } 
      this.setState({ surveys: data })
    })

olareoun avatar Mar 23 '18 14:03 olareoun

Before upgrading to version 8.0.5 It 'worked' by doubling the array

mockServer.emit('surveys', [[
    { id: 1, name: 'Survey 1' },
    { id: 2, name: 'Survey 2' },
    { id: 3, name: 'Survey 3' }
]])

But now with #212 fix, the socket.io emit is broken and it serializes everything to string.

Chalisi avatar Jan 11 '19 09:01 Chalisi