<commit_before>/*global describe, inject, beforeEach, afterEach, module, it, expect */
describe('avValProvider', function() {

  'use strict';

  var provider;
  var avVal;
  var avValConfig;

  beforeEach(module('availity'));

  beforeEach(module(function(avValProvider) {
    provider = avValProvider;
  }));

  beforeEach(inject(function(_avVal_, _avValConfig_) {
    avVal = _avVal_;
    avValConfig = _avValConfig_;
  }));

  it('should be defined', function() {
    expect(provider.$get).toBeDefined();
    expect(provider.addRules).toBeDefined();
    expect(provider.addValidators).toBeDefined();
  });

  it('should add rules', function() {

    var defaultRules = {
      'ssn': {
        'required': {
          'message': 'SSN is required.'
        }
      }
    };

    var result = provider.addRules({
      'defaultRules': defaultRules
    });

    expect(result).toBeEqual({'defaultRules': defaultRules});
  });

  it('should add validators', function() {
    var validators = provider.addValidators(['avValPattern1', 'avValPattern2']);
    var allValidators = avValConfig.validators.concat(['avValPattern1', 'avValPattern2']);

    expect(allValidators).toBeEqual(validators);
  });

});<commit_msg>add spec for avVal broadcast event on rules change<commit_after>/*global describe, inject, beforeEach, spyOn, module, it, expect */
describe('avValProvider', function() {

  'use strict';

  var provider;
  var avVal;
  var avValConfig;
  var $rootScope;
  var AV_VAL;

  var defaultRules = {
    'defaultRules': {
      'ssn': {
        'required': {
          'message': 'SSN is required.'
        }
      }
    }
  };

  beforeEach(module('availity'));

  beforeEach(module(function(avValProvider) {
    provider = avValProvider;
  }));

  beforeEach(inject(function(_avVal_, _avValConfig_, _$rootScope_, _AV_VAL_) {
    avVal = _avVal_;
    avValConfig = _avValConfig_;
    $rootScope = _$rootScope_;
    AV_VAL = _AV_VAL_;
  }));

  it('should be defined', function() {
    expect(provider.$get).toBeDefined();
    expect(provider.addRules).toBeDefined();
    expect(provider.addValidators).toBeDefined();
  });

  it('should add rules', function() {
    var result = provider.addRules(defaultRules);
    expect(result).toBeEqual(defaultRules);
  });

  it('should add validators', function() {
    var validators = provider.addValidators(['avValPattern1', 'avValPattern2']);
    var allValidators = avValConfig.validators.concat(['avValPattern1', 'avValPattern2']);

    expect(allValidators).toBeEqual(validators);
  });

  describe('avVal', function() {

    it('should broadcast re-validate event when adding rules', function() {

      spyOn($rootScope, '$broadcast');

      avVal.addRules(defaultRules);
      expect($rootScope.$broadcast).toHaveBeenCalledWith(AV_VAL.EVENTS.REVALIDATE);

    });
  });

});
{'fraction_non_alphanumeric': 0.14855328158080452, 'fraction_numerical': 0.0028228652081863093, 'mean_word_length': 3.8461538461538463, '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': '5553046', 'n_tokens_mistral': 892, 'n_tokens_neox': 868, 'n_words': 164}