testFormatting = (values, lastValue) => {
      _.each(values, (value) => {
        const element = document.createElement('div');

        Formio.createForm(element, form).then(form => {
          form.setPristine(false);

          const component = form.getComponent('textField');
          const input = component.refs.input[0];
          const inputEvent = new Event('input');
          input.value = value.value;
          input.dispatchEvent(inputEvent);

          setTimeout(() => {
            assert.equal(component.errors.length, 0, 'Should not contain error');
            assert.equal(component.getValue(), value.expected, 'Should set and format value');

            if (_.isEqual(value.value, lastValue)) {
              done();
            }
          }, 300);
        }).catch(done);
      });
    }
.*-*,**';

    const validValues = [
      '',
      'f4/D34.3-S,dd',
      'gg/ggg.g-g,gg',
      'DD/DDD.D-D,DD',
      '55/555.5-5,55',
    ];

    const invalidValues = [
      'er432ff',
      'rD5/F/R-y:d',
      '_=+dsds4',
      'sFFFFF--------2',
      'sd',
      'sf__df',
      'gg/ggg.g-g',
    ];

    const testValidity = (values, valid, lastValue) => {
      _.each(values, (value) => {
        const element = document.createElement('div');

        Formio.createForm(element, form).then(form => {
          form.setPristine(false);

          const component = form.getComponent('textField');
          const changed = component.setValue(value);
          const error = 'Text Field does not match the mask.';

          if (value) {
            assert.equal(changed, true, 'Should set value');
          }

          setTimeout(() => {
            if (valid) {
              assert.equal(component.errors.length, 0, 'Should not contain error');
            }
            else {
              assert.equal(component.errors.length, 1, 'Should contain error');
              assert.equal(component.errors[0].message, error, 'Should contain error message');
              assert.equal(component.element.classList.contains('has-error'), true, 'Should contain error class');
              assert.equal(component.refs.messageContainer.textContent.trim(), error, 'Should show error');
            }

            if (_.isEqual(value, lastValue)) {
              done();
            }
          }, 300);
        }).catch(done);
      });
    };

    testValidity(validValues, true);
    testValidity(invalidValues, false, invalidValues[invalidValues.length-1]);
  });

  it('Should allow inputing only letters and digits and format input according to input mask', (done) => {
    const form = _.cloneDeep(comp6);
    form.components[0].inputMask = '*