|
|
@@ -1,6 +1,6 @@
|
|
|
import { createStore } from '~/tests/unit/Helpers'
|
|
|
import { form } from '~/tests/unit/fixture/state/profile'
|
|
|
-import { $useDirtyForm, UseDirtyForm } from '~/use/form/useDirtyForm'
|
|
|
+import { $useForm, UseForm } from '~/use/form/useForm'
|
|
|
import { AnyStore } from '~/types/interfaces'
|
|
|
|
|
|
let store: AnyStore
|
|
|
@@ -10,12 +10,16 @@ beforeAll(() => {
|
|
|
store.registerModule('form', form)
|
|
|
})
|
|
|
|
|
|
+function setup(){
|
|
|
+ return $useForm()
|
|
|
+}
|
|
|
+
|
|
|
describe('markFormAsDirty()', () => {
|
|
|
it('should call addEventListener one time', async () => {
|
|
|
- const spy = jest.spyOn(UseDirtyForm.prototype as any, 'addEventListener')
|
|
|
+ const spy = jest.spyOn(UseForm.prototype as any, 'addEventListener')
|
|
|
spy.mockImplementation(() => {})
|
|
|
|
|
|
- const { markFormAsDirty } = $useDirtyForm(store)
|
|
|
+ const { markFormAsDirty } = setup()
|
|
|
markFormAsDirty()
|
|
|
expect(spy).toHaveBeenCalled()
|
|
|
})
|
|
|
@@ -23,10 +27,10 @@ describe('markFormAsDirty()', () => {
|
|
|
|
|
|
describe('markAsNotDirty()', () => {
|
|
|
it('should call clearEventListener one time', async () => {
|
|
|
- const spy = jest.spyOn(UseDirtyForm.prototype as any, 'clearEventListener')
|
|
|
+ const spy = jest.spyOn(UseForm.prototype as any, 'clearEventListener')
|
|
|
spy.mockImplementation(() => {})
|
|
|
|
|
|
- const { markFormAsNotDirty } = $useDirtyForm(store)
|
|
|
+ const { markFormAsNotDirty } = $useForm()
|
|
|
markFormAsNotDirty()
|
|
|
expect(spy).toHaveBeenCalled()
|
|
|
})
|