Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/forms / src / __tests__ / lifecycle.test.tsx
Size: Mime:
import './_setup'
import * as React from 'react'
import { render, cleanup } from 'react-testing-library'
import { InputState } from '../new-forms/inputs/InputState'
import { OneFormState, OneObserverForm } from '..//new-forms/OneForm/OneForm'
import { PluginsContext } from '../new-forms/plugins/PluginsContext'
import { TextBoxPlugin } from '../new-forms/plugins/TextPlugin'

/**
 * @todo check all forms for functionality used...
 */
function toTest() {
  const formState = new OneFormState().setInputsList([
    {
      identifier: '0',
      value: 'testing',
      type: 'text',
    },
  ])

  const handlePreFill = (inputState: InputState) => {
    inputState.setIdentifier('100x')
  }
  const view = (
    <PluginsContext.Provider value={[TextBoxPlugin]}>
      <OneObserverForm state={formState} onPreFill={handlePreFill} />
    </PluginsContext.Provider>
  )
  return {
    view,
  }
}

describe('@skava/forms - lifecycle', () => {
  afterEach(cleanup)
  it('should prefil', () => {
    const { view } = toTest()
    const { container } = render(view)
    const found = container.querySelector('input')!
    const id = found.getAttribute('id')
    expect(id).toEqual('100x')
  })
})