import DataProvider from "~/services/data/dataProvider";
import {useDataUtils} from "~/composables/data/useDataUtils";
import {Organization} from "~/models/Organization/Organization";
import {Ref, ref} from "@nuxtjs/composition-api";
import {mountComposition} from "~/tests/unit/Helpers";
jest.mock('~/services/data/dataProvider')


let useDataUtilsMount:any
const dataproviderMock = DataProvider as jest.Mocked<typeof DataProvider>

beforeAll(() => {
  useDataUtilsMount = useDataUtils(dataproviderMock.prototype)
})

describe('getItemToEdit()', () => {
  let route:Ref<{}>

  beforeAll(() => {
    const component = mountComposition(() => {
      route = ref({})
    });
  })


  it('should throw an error if route id is empty', () => {
    route.value = {params: 'foo'}
    expect(() => useDataUtilsMount.getItemToEdit(route, Organization)).toThrowError('id must be exist')
  })
})
