/* eslint-disable */
import {
  createServer,
  Model,
} from 'miragejs'

import { ResponseType } from 'requests/getFavouriteTeam'

import { surveys } from './fixtures/surveys'

export function makeServer({ environment = 'test' } = {}) {
  const server = createServer({
    environment,
    factories: {},
    fixtures: {
      surveys,
    },
    models: {
      surveys: Model.extend<Partial<ResponseType>>({}),
    },
    routes() {
      this.passthrough('https://api.insports.tv/***')
      this.passthrough('https://insports.tv/***')
      this.passthrough('https://images.insports.tv/***')
      this.passthrough('https://auth.insports.tv/***')
      this.passthrough('${URL_AWS}/***')
      this.get('https://api.insports.tv/v1/survey/teams/1/131/30', (schema: any) => schema.all('surveys').models[0].attrs)
    },
  })
  return server
}
