useDataUtils.spec.ts 953 B

1234567891011121314151617181920212223242526272829303132
  1. import DataProvider from "~/services/data/dataProvider";
  2. import {useDataUtils} from "~/composables/data/useDataUtils";
  3. import {Organization} from "~/models/Organization/Organization";
  4. import {Ref, ref} from "@nuxtjs/composition-api";
  5. import {mountComposition} from "~/tests/unit/Helpers";
  6. import {useForm} from "~/composables/form/useForm";
  7. jest.mock('~/services/data/dataProvider')
  8. let useDataUtilsMount:any
  9. const dataproviderMock = DataProvider as jest.Mocked<typeof DataProvider>
  10. beforeAll(() => {
  11. useDataUtilsMount = useDataUtils(dataproviderMock.prototype)
  12. })
  13. describe('getItemToEdit()', () => {
  14. let route:Ref<{}>
  15. beforeAll(() => {
  16. const component = mountComposition(() => {
  17. route = ref({})
  18. });
  19. })
  20. it('should throw an error if id is empty', () => {
  21. const component = mountComposition(() => {
  22. expect(() => useDataUtilsMount.getItemToEdit(null, Organization)).toThrowError('id must be exist')
  23. });
  24. })
  25. })