|
|
@@ -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()
|
|
|
+ });
|
|
|
+
|
|
|
})
|
|
|
})
|