| 123456789101112131415161718192021222324252627282930313233 |
- import { createStore } from '~/tests/unit/Helpers'
- import { form } from '~/tests/unit/fixture/state/profile'
- import { $useDirtyForm, UseDirtyForm } from '~/use/form/useDirtyForm'
- import { AnyStore } from '~/types/interfaces'
- let store: AnyStore
- beforeAll(() => {
- store = createStore()
- store.registerModule('form', form)
- })
- describe('markFormAsDirty()', () => {
- it('should call addEventListener one time', async () => {
- const spy = jest.spyOn(UseDirtyForm.prototype as any, 'addEventListener')
- spy.mockImplementation(() => {})
- const { markFormAsDirty } = $useDirtyForm(store)
- markFormAsDirty()
- expect(spy).toHaveBeenCalled()
- })
- })
- describe('markAsNotDirty()', () => {
- it('should call clearEventListener one time', async () => {
- const spy = jest.spyOn(UseDirtyForm.prototype as any, 'clearEventListener')
- spy.mockImplementation(() => {})
- const { markFormAsNotDirty } = $useDirtyForm(store)
- markFormAsNotDirty()
- expect(spy).toHaveBeenCalled()
- })
- })
|