hideField.spec.ts 737 B

1234567891011121314151617181920212223242526272829303132
  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 hideField from '../hideField.ts'
  5. describe('hideField', () => {
  6. it('can hide a field', () => {
  7. const node = createNode({
  8. plugins: [
  9. createLibraryPlugin({
  10. text: {
  11. type: 'input',
  12. features: [hideField],
  13. props: ['label'],
  14. },
  15. }),
  16. ],
  17. props: {
  18. type: 'text',
  19. label: 'example',
  20. hidden: true,
  21. },
  22. })
  23. expect(node.props.outerClass).toContain('hidden')
  24. node.props.hidden = false
  25. expect(node.props.outerClass).eq('')
  26. })
  27. })