old_contents: import {
    CONNECTED,
    MEMORY_STAT_RECEIVED,
    INVALID_MESSAGE_RECEIVED,
  } from '../../../../shared/action-types';
  
  import config from '../../../../shared/config';
  
  const webSocketsMiddleware = (store) => {
    const socket = new WebSocket(config.websockets.address);
  
    socket.addEventListener('open', () => {
      store.dispatch({ type: CONNECTED });
    });
  
    socket.addEventListener('message', ({ data = '{}' }) => {
      let payload;
  
      try {
        payload = JSON.parse(data);
      } catch (err) {
        payload = {};
      }
  
      if ([MEMORY_STAT_RECEIVED].includes(payload.type)) {
        store.dispatch(payload);
      } else {
        store.dispatch({ type: INVALID_MESSAGE_RECEIVED, payload });
      }
    });
  };
  
  export default webSocketsMiddleware;
  
new_contents: import {
    CONNECTED,
    MEMORY_STAT_RECEIVED,
    INVALID_MESSAGE_RECEIVED,
  } from '../../../../shared/action-types';
  
  import config from '../../../../shared/config';
  
  const webSocketsMiddleware = (store) => {
    const socket = new WebSocket(config.websockets.address);
  
    socket.addEventListener('open', () => {
      store.dispatch({ type: CONNECTED });
    });
  
    socket.addEventListener('message', ({ data = '{}' }) => {
      let payload;
  
      try {
        payload = JSON.parse(data);
      } catch (err) {
        payload = {};
      }
  
      if (payload.type) {
        store.dispatch(payload);
      } else {
        store.dispatch({ type: INVALID_MESSAGE_RECEIVED, payload });
      }
    });
  };
  
  export default webSocketsMiddleware;
  
subject: fix tests for c9