Repository URL to install this package:
|
Version:
3.1.1 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("./_setup");
const React = require("react");
const react_testing_library_1 = require("react-testing-library");
const OneForm_1 = require("../new-forms/OneForm/OneForm");
const PluginsContext_1 = require("../new-forms/plugins/PluginsContext");
const TextPlugin_1 = require("../new-forms/plugins/TextPlugin");
describe('@skava/forms - validation', () => {
afterEach(react_testing_library_1.cleanup);
it('serializes properly by default', () => {
expect.assertions(2);
const inputsList = [
{
propertyName: 'eh',
value: 'canada',
type: 'text',
},
];
const formState = new OneForm_1.OneFormState().setInputsList(inputsList);
const handleSubmit = (args) => {
const serialized = args.state.toJSON();
expect(serialized.eh).toEqual('canada');
expect(Object.keys(serialized).length).toEqual(1);
};
// const MockedTextPlugin = jest.fn(TextBoxPlugin)
const view = (React.createElement(PluginsContext_1.PluginsContext.Provider, { value: [TextPlugin_1.TextBoxPlugin] },
React.createElement(OneForm_1.OneObserverForm, { state: formState, onSubmit: handleSubmit })));
const { getByText } = react_testing_library_1.render(view);
react_testing_library_1.fireEvent.click(getByText(/Continue/));
});
// it.skip('supports custom serialization with plugins', () => {
// //
// })
// it.skip('serializes with custom form state', () => {
// //
// })
});
//# sourceMappingURL=serialization.test.js.map