translateWrapperProps.spec.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { createNode } from '@formkit/core'
  3. import { createLibraryPlugin } from '@formkit/inputs'
  4. import { i18n } from '#shared/i18n.ts'
  5. import translateWrapperProps from '../translateWrapperProps.ts'
  6. const map = new Map([
  7. ['example', 'Beispiel'],
  8. ['help me!', 'Hilf mir!'],
  9. ])
  10. i18n.setTranslationMap(map)
  11. describe('translateWrapperProps', () => {
  12. it('can translate the label, placeholder (as a prop) and help text', () => {
  13. const node = createNode({
  14. plugins: [
  15. createLibraryPlugin({
  16. text: {
  17. type: 'input',
  18. features: [translateWrapperProps],
  19. props: ['label', 'placeholder', 'help'],
  20. },
  21. }),
  22. ],
  23. props: {
  24. type: 'text',
  25. placeholder: 'example',
  26. label: 'example',
  27. help: 'help me!',
  28. },
  29. })
  30. expect(node.props.label.value).toEqual('Beispiel')
  31. expect(node.props.placeholder.value).toEqual('Beispiel')
  32. expect(node.props.help.value).toEqual('Hilf mir!')
  33. })
  34. })