How to use the uniforms-bridge-simple-schema.SimpleSchemaBridge function in uniforms-bridge-simple-schema

To help you get started, we’ve selected a few uniforms-bridge-simple-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vazco / uniforms / packages / uniforms / __tests__ / QuickForm.tsx View on Github external
describe('QuickForm', () => {
  /* eslint-disable react/display-name */
  class TestQuickForm extends QuickForm {
    getAutoField = () =&gt; () =&gt; <i>;
    getErrorsField = () =&gt; () =&gt; <i>;
    getSubmitField = () =&gt; () =&gt; <i>;
  }
  /* eslint-enable react/display-name */

  const schema = new SimpleSchemaBridge({
    getDefinition: () =&gt; {},
    messageForError: () =&gt; {},
    objectKeys: () =&gt; ['a', 'b', 'c'],
    validator: () =&gt; {},
  });

  describe('when rendered with custom fields', () =&gt; {
    it('renders `AutoField` for each field', () =&gt; {
      const wrapper = mount();

      expect(wrapper.find('.auto').length).toBeGreaterThan(0);
    });

    it('renders `ErrorsField`', () =&gt; {
      const wrapper = mount();
</i></i></i>
github vazco / uniforms / packages / uniforms / __tests__ / ValidatedForm.tsx View on Github external
it('uses the new validator settings if `validator` changes', () => {
        const validator = jest.fn();

        wrapper.setProps({
          schema: new SimpleSchemaBridge({
            getDefinition() {},
            messageForError() {},
            objectKeys() {},
            validator,
          }),
        });

        const validatorA = Symbol();
        const validatorB = Symbol();

        wrapper.setProps({ validator: validatorA });
        wrapper.setProps({ validator: validatorB });
        wrapper.setProps({ validator: validatorA });

        expect(validator).toHaveBeenCalledTimes(4);
        // First call is bridge implementation specific.
github vazco / uniforms / packages / uniforms / __tests__ / QuickForm.js View on Github external
describe('QuickForm', () =&gt; {
  /* eslint-disable react/display-name */
  class TestQuickForm extends QuickForm {
    getAutoField = () =&gt; () =&gt; <i>;
    getErrorsField = () =&gt; () =&gt; <i>;
    getSubmitField = () =&gt; () =&gt; <i>;
  }
  /* eslint-enable react/display-name */

  const schema = new SimpleSchemaBridge({
    getDefinition: () =&gt; {},
    messageForError: () =&gt; {},
    objectKeys: () =&gt; ['a', 'b', 'c'],
    validator: () =&gt; {}
  });

  describe('when rendered with custom fields', () =&gt; {
    it('renders `AutoField` for each field', () =&gt; {
      const wrapper = mount();

      expect(wrapper.find('.auto').length).toBeGreaterThan(0);
    });

    it('renders `ErrorsField`', () =&gt; {
      const wrapper = mount();
</i></i></i>
github vazco / uniforms / packages / uniforms / __tests__ / ValidatedForm.tsx View on Github external
it('does not revalidate when `schema` changes', () => {
        wrapper.setProps({ schema: new SimpleSchemaBridge(schemaDefinition) });
        expect(validator).not.toBeCalled();
      });
    });
github vazco / uniforms / packages / uniforms / __tests__ / ValidatedForm.tsx View on Github external
describe('ValidatedForm', () =&gt; {
  const onChange = jest.fn();
  const onSubmit = jest.fn(async () =&gt; {});
  const onValidate = jest.fn((model, error, next) =&gt; next());
  const validator = jest.fn();

  const error = new Error();
  const model = { a: 1 };
  const schemaDefinition = {
    getDefinition() {},
    messageForError() {},
    objectKeys() {},
    validator: () =&gt; validator,
  };
  const schema = new SimpleSchemaBridge(schemaDefinition);

  beforeEach(() =&gt; {
    onValidate.mockClear();

    onChange.mockReset();
    onSubmit.mockReset();
    validator.mockReset();
  });

  describe('on validation', () =&gt; {
    let wrapper;
    let form;

    beforeEach(() =&gt; {
      wrapper = mount(
        ,
github vazco / uniforms / packages / uniforms / __tests__ / AutoForm.js View on Github external
describe('AutoForm', () =&gt; {
  const onChangeModel = jest.fn();
  const validator = jest.fn();
  const onChange = jest.fn();
  const onSubmit = jest.fn();
  const model = { a: '1' };
  const schema = new SimpleSchemaBridge({
    getDefinition: () =&gt; ({ type: String, defaultValue: '' }),
    messageForError: () =&gt; {},
    objectKeys: () =&gt; ['a', 'b', 'c'],
    validator: () =&gt; validator
  });

  beforeEach(() =&gt; {
    onChange.mockReset();
    onChangeModel.mockReset();
    onSubmit.mockReset();
    validator.mockReset();
  });

  describe('when changed', () =&gt; {
    const wrapper = mount(
github vazco / uniforms / packages / uniforms / __tests__ / injectName.tsx View on Github external
describe('injectName', () => {
  const error = new Error();
  const onChange = () => {};
  const randomId = randomIds();
  const state = {
    changed: false,
    changedMap: {},
    submitting: false,
    label: true,
    disabled: false,
    placeholder: false,
    showInlineError: true,
  };

  const schema = new SimpleSchemaBridge({
    getDefinition(name) {
      return {
        fieldA: { type: Object, label: 'FieldA' },
        'fieldA.fieldB': { type: Object, label: 'FieldB' },
        'fieldA.fieldB.fieldC': { type: String, label: 'FieldC' },
      }[name];
    },

    messageForError() {},

    objectKeys(name) {
      return {
        fieldA: ['FieldB'],
        'fieldA.FieldB': ['FieldC'],
        'fieldA.FieldB.FieldC': [],
      }[name];
github vazco / uniforms / packages / uniforms / __tests__ / connectField.tsx View on Github external
describe('connectField', () => {
  const error = new Error();
  const onChange = jest.fn();
  const randomId = randomIds();
  const state = {
    changed: false,
    changedMap: {},
    submitting: false,
    label: true,
    disabled: false,
    placeholder: false,
    showInlineError: true,
  };

  const schema = new SimpleSchemaBridge({
    getDefinition(name) {
      return {
        field: { type: Object, label: 'Field' },
        'field.subfield': { type: Number, label: 'Subfield' },
        another: { type: String, optional: true },
      }[name];
    },

    messageForError() {},

    objectKeys(name) {
      return {
        field: ['subfield'],
        'field.subfield': [],
      }[name];
    },
github vazco / uniforms / packages / uniforms / __tests__ / injectName.js View on Github external
describe('injectName', () => {
  const error = new Error();
  const onChange = () => {};
  const randomId = randomIds();
  const state = {
    changed: false,
    changedMap: {},
    submitting: false,
    label: true,
    disabled: false,
    placeholder: false,
    showInlineError: true
  };

  const schema = new SimpleSchemaBridge({
    getDefinition(name) {
      return {
        fieldA: { type: Object, label: 'FieldA' },
        'fieldA.fieldB': { type: Object, label: 'FieldB' },
        'fieldA.fieldB.fieldC': { type: String, label: 'FieldC' }
      }[name];
    },

    messageForError() {},

    objectKeys(name) {
      return {
        fieldA: ['FieldB'],
        'fieldA.FieldB': ['FieldC'],
        'fieldA.FieldB.FieldC': []
      }[name];
github vazco / uniforms / packages / uniforms / __tests__ / connectField.js View on Github external
describe('connectField', () => {
  const error = new Error();
  const onChange = jest.fn();
  const randomId = randomIds();
  const state = {
    changed: false,
    changedMap: {},
    submitting: false,
    label: true,
    disabled: false,
    placeholder: false,
    showInlineError: true
  };

  const schema = new SimpleSchemaBridge({
    getDefinition(name) {
      return {
        field: { type: Object, label: 'Field' },
        'field.subfield': { type: Number, label: 'Subfield' },
        another: { type: String, optional: true }
      }[name];
    },

    messageForError() {},

    objectKeys(name) {
      return {
        field: ['subfield'],
        'field.subfield': []
      }[name];
    },

uniforms-bridge-simple-schema

SimpleSchema bridge for uniforms.

MIT
Latest version published 1 year ago

Package Health Score

52 / 100
Full package analysis