Vincent GUFFON 3 gadi atpakaļ
vecāks
revīzija
822de957a7

+ 2 - 0
tests/unit/Helpers.ts

@@ -1,9 +1,11 @@
 import { Store } from 'vuex'
 import VuexORM from '@vuex-orm/core'
+import VueCompositionAPI from '@vue/composition-api';
 import { mount, createLocalVue } from '@vue/test-utils'
 import { AnyJson } from '~/types/interfaces'
 
 const localVue = createLocalVue()
+localVue.use(VueCompositionAPI);
 
 export function initLocalVue (ctx:AnyJson) {
   localVue.prototype.$nuxt = {

+ 10 - 1
tests/unit/services/connection/urlBuilder.spec.ts

@@ -17,7 +17,7 @@ describe('invoke()', () => {
       expect(UrlBuilder.build({
         type: QUERY_TYPE.DEFAULT,
         url: 'users'
-      })).toEqual('users')
+      })).toEqual('/users')
     })
   })
 
@@ -114,4 +114,13 @@ describe('invoke()', () => {
       jest.useRealTimers();
     })
   })
+
+  describe('getFileUrl()', () => {
+    it('should return the URL concat with Root URL and base URL', () => {
+      expect(UrlBuilder.build({
+        type: QUERY_TYPE.FILE,
+        baseUrl: 'http://local.opentalent.fr'
+      })).toEqual('http://local.opentalent.fr/api/files')
+    })
+  })
 })

+ 13 - 10
tests/unit/use/form/useForm.spec.ts

@@ -1,4 +1,4 @@
-import { createStore } from '~/tests/unit/Helpers'
+import {createStore, initLocalVue, mountComposition} from '~/tests/unit/Helpers'
 import { form } from '~/tests/unit/fixture/state/profile'
 import { $useForm, UseForm } from '~/use/form/useForm'
 import { AnyStore } from '~/types/interfaces'
@@ -8,20 +8,20 @@ let store: AnyStore
 beforeAll(() => {
   store = createStore()
   store.registerModule('form', form)
+  initLocalVue({store: store})
 })
 
-function setup(){
-  return $useForm()
-}
 
 describe('markFormAsDirty()', () => {
   it('should call addEventListener one time', async () => {
     const spy = jest.spyOn(UseForm.prototype as any, 'addEventListener')
     spy.mockImplementation(() => {})
 
-    const { markFormAsDirty } = setup()
-    markFormAsDirty()
-    expect(spy).toHaveBeenCalled()
+    const component = mountComposition(() => {
+      const {markFormAsDirty} = $useForm();
+      markFormAsDirty()
+      expect(spy).toHaveBeenCalled()
+    });
   })
 })
 
@@ -30,8 +30,11 @@ describe('markAsNotDirty()', () => {
     const spy = jest.spyOn(UseForm.prototype as any, 'clearEventListener')
     spy.mockImplementation(() => {})
 
-    const { markFormAsNotDirty } = $useForm()
-    markFormAsNotDirty()
-    expect(spy).toHaveBeenCalled()
+    const component = mountComposition(() => {
+      const { markFormAsNotDirty } = $useForm()
+      markFormAsNotDirty()
+      expect(spy).toHaveBeenCalled()
+    });
+
   })
 })

+ 7 - 3
tests/unit/use/updater/useMyProfileUpdater.spec.ts

@@ -1,5 +1,5 @@
-import { createStore } from '~/tests/unit/Helpers'
-import { accessState, AnyStore } from '~/types/interfaces'
+import { createStore, initLocalVue, mountComposition } from '~/tests/unit/Helpers'
+import { AnyStore } from '~/types/interfaces'
 import DataPersister from '~/services/data/dataPersister'
 import { UseMyProfileUpdater } from '~/use/updater/useMyProfileUpdater'
 import { repositoryHelper } from '~/services/store/repository'
@@ -12,7 +12,11 @@ beforeAll(() => {
   store = createStore()
   dataPersister = new DataPersister()
   repositoryHelper.setStore(store)
-  useMyProfileUpdater = new UseMyProfileUpdater() as any
+  initLocalVue({store: store})
+
+  const component = mountComposition(() => {
+    useMyProfileUpdater = new UseMyProfileUpdater() as any
+  });
 })
 
 describe('setActivityYear()', () => {