Repository URL to install this package:
|
Version:
3.7.2 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// - [ ] validation
// - run through validators with test data (don't fill it overly much, ask qa to fill)
// - test plugin validation
const React = require("react");
const snapshotDiff = require("snapshot-diff");
const react_testing_library_1 = require("react-testing-library");
require("./_setup");
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('validate on submit using default render', () => {
const inputsList = [
{
type: 'text',
},
];
const formState = new OneForm_1.OneFormState().setInputsList(inputsList);
const handleSubmit = (serialized) => {
// doing nothing now
// console.log(serialized)
};
const mockSubmit = jest.fn(handleSubmit);
const view = (React.createElement(PluginsContext_1.PluginsContext.Provider, { value: [TextPlugin_1.TextBoxPlugin] },
React.createElement(OneForm_1.OneObserverForm, { state: formState, onSubmit: mockSubmit })));
// const rendered = render(view)
const { getByText, asFragment } = react_testing_library_1.render(view);
expect(mockSubmit.mock.calls.length).toEqual(0);
const firstRender = asFragment();
react_testing_library_1.fireEvent.click(getByText(/Continue/));
expect(mockSubmit.mock.calls.length).toEqual(1);
const renderDiff = snapshotDiff(firstRender, asFragment());
expect(renderDiff).toMatchSnapshot();
// const renderer = ReactTestRenderer.create(view)
// expect(renderer.toJSON()).toMatchSnapshot()
});
});
//# sourceMappingURL=validation.test.js.map