UNPKG

react-jsonschema-form-validation

Version:
36 lines (34 loc) 1.27 kB
import React from 'react'; import { mount } from 'enzyme'; import FormContext, { useFormContext, withFormContext } from './Context'; describe('FormContext', function () { it('should be a React Context', function () { expect(FormContext.Provider).toBeDefined(); expect(FormContext.Consumer).toBeDefined(); }); }); describe('useFormContext', function () { it('should match snapshot', function () { var UseContextComponent = function UseContextComponent() { var context = useFormContext(); return React.createElement("span", null, context); }; var wrapper = mount(React.createElement(FormContext.Provider, { value: "FormContextSnapshot" }, React.createElement(UseContextComponent, null))); expect(wrapper).toMatchSnapshot(); }); }); describe('withFormContext', function () { it('should match snapshot', function () { var WithContextComponent = function WithContextComponent() { return withFormContext(function (context) { return React.createElement("span", null, context); }); }; var wrapper = mount(React.createElement(FormContext.Provider, { value: "FormContextSnapshot" }, React.createElement(WithContextComponent, null))); expect(wrapper).toMatchSnapshot(); }); });