Repository URL to install this package:
|
Version:
3.7.2 ▾
|
import './_setup'
import * as React from 'react'
import { render, cleanup, fireEvent } from 'react-testing-library'
import { OnSubmitFormArgs } from '../new-forms/forms/typings'
import { OneFormState, OneObserverForm } from '../new-forms/OneForm/OneForm'
import { PluginsContext } from '../new-forms/plugins/PluginsContext'
import { TextBoxPlugin } from '../new-forms/plugins/TextPlugin'
import { SerializedObj } from '../new-forms/typings'
describe('@skava/forms - validation', () => {
afterEach(cleanup)
it('serializes properly by default', () => {
expect.assertions(2)
const inputsList = [
{
propertyName: 'eh',
value: 'canada',
type: 'text',
},
]
const formState = new OneFormState().setInputsList(inputsList)
const handleSubmit = (args: OnSubmitFormArgs) => {
const serialized = args.state.toJSON() as SerializedObj
expect(serialized.eh).toEqual('canada')
expect(Object.keys(serialized).length).toEqual(1)
}
// const MockedTextPlugin = jest.fn(TextBoxPlugin)
const view = (
<PluginsContext.Provider value={[TextBoxPlugin]}>
<OneObserverForm state={formState} onSubmit={handleSubmit} />
</PluginsContext.Provider>
)
const { getByText } = render(view)
fireEvent.click(getByText(/Continue/))
})
// it.skip('supports custom serialization with plugins', () => {
// //
// })
// it.skip('serializes with custom form state', () => {
// //
// })
})