const mockAdapter = require("axios-mock-adapter");
const socketMock = require("socket-io-mock");

// https://webpack.js.org/guides/dependency-management/#requirecontext
const mockFiles = require.context("@/mock", true, /\.js$/);

export default ({ $axios, isDev }, inject) => {
  if (!isDev) {
    return;
  }
  // web socket
  // eslint-disable-next-line
  const webSocket = new socketMock();
  inject("webSocket", webSocket);
  // axios
  // eslint-disable-next-line
  const mock = new mockAdapter($axios, { onNoMatch: "passthrough" });

  // you do not need `import app from './modules/app'`
  // it will auto require all vuex module from modules file
  mockFiles.keys().forEach((mockPath) => {
    mockFiles(mockPath).default({ webSocket, mock, $axios });
  });
};
