<commit_before>'use strict';

/* jasmine specs for controllers */

describe('HeaderController', function() {
  var scope, ctrl, location;

  beforeEach(inject(function($rootScope, $controller, $location) {
    scope = $rootScope.$new();
    ctrl = $controller(HeaderController, {$scope: scope});
    location = $location
  }));


  it('should provide "alreadyhome" function', function() {
    expect(typeof scope.alreadyhome).toEqual('function');

    location.path('/');
    expect(scope.alreadyhome()).toBe(false);
    location.path('/playground');
    expect(scope.alreadyhome()).toBe(false);
    location.path('/playground/');
    expect(scope.alreadyhome()).toBe(true);
    location.path('/playground/p/42/');
    expect(scope.alreadyhome()).toBe(false);
  });

});


describe('PageController', function() {
  var scope, controller, $httpBackend;

  beforeEach(module('playgroundApp'));
  beforeEach(inject(function($rootScope, $controller, $injector) {
    scope = $rootScope.$new();
    controller = $controller;
    $httpBackend = $injector.get('$httpBackend');

    $httpBackend
    .when('GET', '/playground/getconfig')
    .respond({
        "PLAYGROUND_USER_CONTENT_HOST": "localhost:9100",
        "email": "user_q0inuf3vs5",
        "git_playground_url": "http://code.google.com/p/cloud-playground/",
        "is_admin": false,
        "is_logged_in": false,
        "playground_namespace": "_playground",
    });

    $httpBackend
    .when('GET', '/playground/getprojects')
    .respond([]);
  }));


  afterEach(function() {
    $httpBackend.verifyNoOutstandingExpectation();
    $httpBackend.verifyNoOutstandingRequest();
  });


  it('should, when instantiated, get configuration, then project data', inject(function($timeout) {
    expect(scope.config).toBeUndefined();
    expect(scope.projects).toBeUndefined();
    $httpBackend.expectGET('/playground/getconfig');
    $httpBackend.expectGET('/playground/getprojects');
    var ctrl = controller(PageController, {$scope: scope});
    flushDoSerial($timeout);
    $httpBackend.flush();
    expect(scope.config).toBeDefined();
    expect(scope.config.email).toBeDefined();
    expect(scope.config.playground_namespace).toBe('_playground');
    expect(scope.projects).toBeDefined();
    expect(scope.projects.length).toBe(0);
  }));

});<commit_msg>separate describe section for PageController initialization<commit_after>'use strict';

/* jasmine specs for controllers */

describe('HeaderController', function() {
  var scope, ctrl, location;

  beforeEach(inject(function($rootScope, $controller, $location) {
    scope = $rootScope.$new();
    ctrl = $controller(HeaderController, {$scope: scope});
    location = $location
  }));


  it('should provide "alreadyhome" function', function() {
    expect(typeof scope.alreadyhome).toEqual('function');

    location.path('/');
    expect(scope.alreadyhome()).toBe(false);
    location.path('/playground');
    expect(scope.alreadyhome()).toBe(false);
    location.path('/playground/');
    expect(scope.alreadyhome()).toBe(true);
    location.path('/playground/p/42/');
    expect(scope.alreadyhome()).toBe(false);
  });

});


describe('PageController', function() {
  var scope, controller, $httpBackend;

  describe('initialization', function () {
    beforeEach(module('playgroundApp'));
    beforeEach(inject(function($rootScope, $controller, $injector) {
      scope = $rootScope.$new();
      controller = $controller;
      $httpBackend = $injector.get('$httpBackend');

      $httpBackend
      .when('GET', '/playground/getconfig')
      .respond({
          "PLAYGROUND_USER_CONTENT_HOST": "localhost:9100",
          "email": "user_q0inuf3vs5",
          "git_playground_url": "http://code.google.com/p/cloud-playground/",
          "is_admin": false,
          "is_logged_in": false,
          "playground_namespace": "_playground",
      });

      $httpBackend
      .when('GET', '/playground/getprojects')
      .respond([]);
    }));


    afterEach(function() {
      $httpBackend.verifyNoOutstandingExpectation();
      $httpBackend.verifyNoOutstandingRequest();
    });


    it('should, when instantiated, get configuration, then project data', inject(function($timeout) {
      expect(scope.config).toBeUndefined();
      expect(scope.projects).toBeUndefined();
      $httpBackend.expectGET('/playground/getconfig');
      $httpBackend.expectGET('/playground/getprojects');
      var ctrl = controller(PageController, {$scope: scope});
      flushDoSerial($timeout);
      $httpBackend.flush();
      expect(scope.config).toBeDefined();
      expect(scope.config.email).toBeDefined();
      expect(scope.config.playground_namespace).toBe('_playground');
      expect(scope.projects).toBeDefined();
      expect(scope.projects.length).toBe(0);
    }));

  });

});
{'fraction_non_alphanumeric': 0.16812317935913443, 'fraction_numerical': 0.004161464835622139, 'mean_word_length': 4.070675105485232, 'pattern_counts': {'":': 12, '<': 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': '3839873', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1400, 'n_words': 211}