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 / build / dist / __tests__ / validation.test.js
Size: Mime:
"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