<commit_before>'use strict';

/* jasmine specs for controllers go here */
describe('Controllers', function() {

  describe('ConfListCtrl', function(){
    var scope, ctrl, $httpBackend;

    beforeEach(function() {
      module('smart-table');
      module('app');
    });

    beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) {
      $httpBackend = _$httpBackend_;
      $httpBackend.expectGET('data/confs.json').respond([{name: 'Agile Australia'}, {year: '2014'}]);

      scope = $rootScope.$new();
      ctrl = $controller('ConfListCtrl', {$scope: scope});
    }));

    it('should create confs data model with data fetched from xhr', function() {
      expect(scope.loadedConferences).toBeUndefined();
      $httpBackend.flush();

      expect(scope.loadedConferences).toEqual([{name: 'Agile Australia'}, {year: '2014'}]);
    });

    describe('helper functions', function() {
      var stubConf;
      beforeEach(function() {
        stubConf = {totalSpeakers: 20, numberOfWomen: 3};
      });

      it('should derive number of men from other fields', function() {
        expect(scope.numberOfMen(stubConf)).toEqual(17)
      });

      it('should derive diversity percentage from other fields', function() {
        expect(scope.diversityPercentage(stubConf)).toEqual(15)
      });

    })
  });
});<commit_msg>New tests for diversityScore helper<commit_after>'use strict';

/* jasmine specs for controllers go here */
describe('Controllers', function() {

  describe('ConfListCtrl', function(){
    var scope, ctrl, $httpBackend;

    beforeEach(function() {
      module('smart-table');
      module('app');
    });

    beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) {
      $httpBackend = _$httpBackend_;
      $httpBackend.expectGET('data/confs.json').respond([{name: 'Agile Australia'}, {year: '2014'}]);

      scope = $rootScope.$new();
      ctrl = $controller('ConfListCtrl', {$scope: scope});
    }));

    it('should create confs data model with data fetched from xhr', function() {
      expect(scope.loadedConferences).toBeUndefined();
      $httpBackend.flush();

      expect(scope.loadedConferences).toEqual([{name: 'Agile Australia'}, {year: '2014'}]);
    });

    describe('helper functions', function() {
      var stubConf;
      beforeEach(function() {
        stubConf = {totalSpeakers: 20, numberOfWomen: 3};
      });

      it('numberOfMen should derive number of men from other fields', function() {
        expect(scope.numberOfMen(stubConf)).toEqual(17)
      });

      it('diversityPercentage should derive diversity percentage from other fields', function() {
        expect(scope.diversityPercentage(stubConf)).toEqual(15)
      });

      it('diversityScore should score each diversity percentage using school grades', function() {
        expect(scope.diversityScore({totalSpeakers: 100, numberOfWomen: 50})).toEqual('A');
        expect(scope.diversityScore({totalSpeakers: 100, numberOfWomen: 49})).toEqual('B');
        expect(scope.diversityScore({totalSpeakers: 100, numberOfWomen: 39})).toEqual('C');
        expect(scope.diversityScore({totalSpeakers: 100, numberOfWomen: 29})).toEqual('D');
        expect(scope.diversityScore({totalSpeakers: 100, numberOfWomen: 19})).toEqual('E');
        expect(scope.diversityScore({totalSpeakers: 100, numberOfWomen: 9})).toEqual('F');
        expect(scope.diversityScore({totalSpeakers: 100, numberOfWomen: 0})).toEqual('F');

      });

    })
  });
});
{'fraction_non_alphanumeric': 0.15887582449096643, 'fraction_numerical': 0.018067106395182105, 'mean_word_length': 3.8647140864714085, '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': '3839874', 'n_tokens_mistral': 1067, 'n_tokens_neox': 996, 'n_words': 210}