useForm.spec.ts 863 B

12345678910111213141516171819202122232425262728293031
  1. import {createStore, initLocalVue, mountComposition} from '~/tests/unit/Helpers'
  2. import { form } from '~/tests/unit/fixture/state/profile'
  3. import {useForm} from "~/composables/form/useForm";
  4. import { AnyStore } from '~/types/interfaces'
  5. let store: AnyStore
  6. let useFormMount:any
  7. beforeAll(() => {
  8. store = createStore()
  9. store.registerModule('form', form)
  10. initLocalVue({store: store})
  11. const component = mountComposition(() => {
  12. useFormMount = useForm(store)
  13. });
  14. })
  15. describe('markFormAsDirty()', () => {
  16. it('should commit the form state dirty to true', async () => {
  17. useFormMount.markAsDirty()
  18. expect(store.state.form.dirty).toBeTruthy()
  19. })
  20. })
  21. describe('markAsNotDirty()', () => {
  22. it('should commit the form state dirty to false', async () => {
  23. useFormMount.markAsNotDirty()
  24. expect(store.state.form.dirty).toBeFalsy()
  25. })
  26. })