hideField.spec.ts 738 B

123456789101112131415161718192021222324252627282930313233
  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. })