<commit_before>describe("validate.async", function() {
  var error = null
    , success = null;

  beforeEach(function() {
    success = jasmine.createSpy("success");
    error = jasmine.createSpy("error");

    validate.validators.asyncFail = function() {
      return validate.Promise(function(resolve, reject) {
        setTimeout(function() {
          reject("failz");
        }, 1);
      });
    };

    validate.validators.asyncSuccess = function() {
      return validate.Promise(function(resolve, reject) {
        setTimeout(function() {
          resolve();
        }, 1);
      });
    };
  });

  afterEach(function() {
    delete validate.validators.asyncFail;
    delete validate.validators.asyncSuccess;
  });

  it("makes validate return a promise", function() {
    var promise = validate.async({}, {});
    expect(promise).toBeAPromise();
  });

  it.promise("resolves the promise if all constraints pass", function(done) {
    return validate.async({}, {});
  });

  it.promise("rejects the promise if any constraint fails", function() {
    var c = {name: {presence: true}};
    return validate.async({}, c).then(success, error).then(function() {
      expect(success).not.toHaveBeenCalled();
      expect(error).toHaveBeenCalled();
    });
  });

  it.promise("handles validators returning an promise", function() {
    var c = {
      name: {
        asyncFail: true,
        asyncSuccess: true<commit_msg>Remove a unused function parameter<commit_after>describe("validate.async", function() {
  var error = null
    , success = null;

  beforeEach(function() {
    success = jasmine.createSpy("success");
    error = jasmine.createSpy("error");

    validate.validators.asyncFail = function() {
      return validate.Promise(function(resolve, reject) {
        setTimeout(function() {
          reject("failz");
        }, 1);
      });
    };

    validate.validators.asyncSuccess = function() {
      return validate.Promise(function(resolve, reject) {
        setTimeout(function() {
          resolve();
        }, 1);
      });
    };
  });

  afterEach(function() {
    delete validate.validators.asyncFail;
    delete validate.validators.asyncSuccess;
  });

  it("makes validate return a promise", function() {
    var promise = validate.async({}, {});
    expect(promise).toBeAPromise();
  });

  it.promise("resolves the promise if all constraints pass", function() {
    return validate.async({}, {});
  });

  it.promise("rejects the promise if any constraint fails", function() {
    var c = {name: {presence: true}};
    return validate.async({}, c).then(success, error).then(function() {
      expect(success).not.toHaveBeenCalled();
      expect(error).toHaveBeenCalled();
    });
  });

  it.promise("handles validators returning an promise", function() {
    var c = {
      name: {
        asyncFail: true,
        asyncSuccess: true
{'fraction_non_alphanumeric': 0.15154675008689608, 'fraction_numerical': 0.0013903371567605145, 'mean_word_length': 3.025174825174825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6691740', 'n_tokens_mistral': 833, 'n_tokens_neox': 814, 'n_words': 173}