Repository URL to install this package:
|
Version:
3.7.2 ▾
|
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')
})
})