index.spec.ts 952 B

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