index.spec.ts 1021 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. import initializeForm, { getFormPlugins } from '@common/form'
  3. import type { ImportGlobEagerOutput } from '@common/types/utils'
  4. import type { FormKitPlugin } from '@formkit/core'
  5. import { createApp } from 'vue'
  6. describe('getFormPlugins', () => {
  7. // eslint-disable-next-line @typescript-eslint/no-empty-function
  8. const examplePlugin = (): void => {}
  9. const pluginModules: ImportGlobEagerOutput<FormKitPlugin> = {
  10. 'common/test/plugins/test.ts': {
  11. default: examplePlugin,
  12. },
  13. 'common/test/plugins/example.ts': {
  14. default: examplePlugin,
  15. },
  16. }
  17. it('should return the plugin list', () => {
  18. expect(getFormPlugins(pluginModules)).toEqual([
  19. examplePlugin,
  20. examplePlugin,
  21. ])
  22. })
  23. })
  24. describe('initializeForm', () => {
  25. const app = createApp({})
  26. vi.spyOn(app, 'use')
  27. it('check use form plugin without an error', () => {
  28. initializeForm(app)
  29. expect(app.use).toHaveBeenCalled()
  30. })
  31. })