let successTestItem = {
  status: 'пройден',
  testState: 'isLoaded',
  isOpenData: false,
}

let errorTestItem = {
  status: 'не пройден',
  testState: "error",
  isOpenData: false,
}

const testsAdapters = async ({adapterOfMachines, adapterOfPacks}) => {
  let adaptersData = []
  await adapterOfMachines.fetchModalMachines().then((res) => {
    if (res && res.length > 0) {
      successTestItem = {...successTestItem, name: 'fetchModalMachines', resData: res}
      adaptersData = [...adaptersData, successTestItem]
      return adaptersData
    }
  }).catch((error) => {
    const errorTest = `Тест fetchModalMachines не пройден, ошибка - ${error}`
    errorTestItem = {...errorTestItem, name: 'fetchModalMachines', errorTest}
    adaptersData = [...adaptersData, errorTestItem]
    return adaptersData
  })

  await adapterOfMachines.fetchLastMachinesByPackNum([7683]).then((res) => {
    if (res && res.length > 0) {
      successTestItem = {...successTestItem, name: 'fetchLastMachinesByPackNum', resData: res}
      adaptersData = [...adaptersData, successTestItem]
      return adaptersData
    }
  }).catch((error) => {
    const errorTest = `Тест fetchModalMachines не пройден, ошибка - ${error}`
    errorTestItem = {...errorTestItem, name: 'fetchModalMachines', errorTest}
    adaptersData = [...adaptersData, errorTestItem]
    return adaptersData
  })

  await adapterOfPacks.getLastPacks("868136035512212", "2024-03-01T00:00:00", "2024-04-01T23:59:00").then((res) => {
    if (res && res.length > 0) {
      successTestItem = {...successTestItem, name: 'getLastPacks', resData: res}
      adaptersData = [...adaptersData, successTestItem]
      return adaptersData
    }
  }).catch((error) => {
    const errorTest = `Тест fetchModalMachines не пройден, ошибка - ${error}`
    errorTestItem = {...errorTestItem, name: 'fetchModalMachines', errorTest}
    adaptersData = [...adaptersData, errorTestItem]
    return adaptersData
  })
  
  return adaptersData

}

export {testsAdapters}