How to use the uniforms.randomIds function in uniforms

To help you get started, we’ve selected a few uniforms 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__ / BaseField.tsx View on Github external
render() {
      return (
        <div>
          
          {this.props.children}
        </div>
      );
    }
  }

  const error1 = { details: [{ name: 'a' }, { name: 'i' }] };
  const error2 = { details: [{ name: 'b' }] };
  const model = { a: { b: { c: 'example' } } };
  const onChange = jest.fn();
  const randomId = randomIds();
  const state = {
    changed: false,
    changedMap: {},
    submitting: false,
    label: true,
    disabled: false,
    placeholder: true,
    showInlineError: true,
  };

  const schema = new SimpleSchemaBridge({
    getDefinition(name) {
      // Simulate SimpleSchema.
      name = name.replace(/\d+/g, '$');

      return {
github vazco / uniforms / packages / uniforms / __tests__ / randomIds.ts View on Github external
it('generate random id', () => {
    const amount = 100;

    const generator = randomIds();
    const generated = Array.from({ length: amount }, generator);

    const unique = generated.filter((a, b, c) => c.indexOf(a) === b);

    expect(unique).toHaveLength(amount);
  });
});
github vazco / uniforms / packages / uniforms / __tests__ / randomIds.ts View on Github external
it('returns a function', () => {
    expect(randomIds()).toBeInstanceOf(Function);
  });
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 },
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' },