<commit_before>'use strict';

describe('Controller: MainCtrl', function () {

  // load the controller's module
  //beforeEach(module('moneyApp'));
  beforeEach(angular.mock.module('moneyApp'));

  var MainCtrl,
    scope,
    $httpBackend;

  // Initialize the controller and a mock scope
  beforeEach(inject(function (_$httpBackend_, $controller, $rootScope) {
    $httpBackend = _$httpBackend_;
    $httpBackend.expectGET('/api/v1/moneybooks')
      .respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']);
    scope = $rootScope.$new();
    MainCtrl = $controller('MainCtrl', {
      $scope: scope
    });
  }));

  it('should attach a list of moneybooks data to the scope', function () {
    console.log('[main] data....'+JSON.stringify(scope.moneyBooks));
    expect(scope.moneyBooks.$params.page).toBe(1);
    expect(scope.moneyBooks.$params.count).toBe(10);
  });

  it('should have a properly working MainCtrl controller', inject(function($rootScope, $controller, $httpBackend) {
    var searchTestAtr = 'cars';
    var response = $httpBackend.expectJSONP('/api/v1/moneybooks?q=' + searchTestAtr);
    response.respond(null);

    var $scope = $rootScope.$new();
    var ctrl = $controller('MainCtrl', {
      $scope : $scope,
      $routeParams : {
        q : searchTestAtr
      }
    });
  }));

  it('should have a properly working MainCtrl controller', inject(function($rootScope, $controller, $httpBackend) {
    var searchID = '1';
    var response = $httpBackend.expectJSONP('/api/v1/moneybooks/' + searchID);
    response.respond(null);

    var $scope = $rootScope.$new();
    var ctrl = $controller('MainCtrl', {
      $scope : $scope,
      $routeParams : {
        id : searchID
      }
    });
  }));
/*
  it('should have a MainCtrl controller', function() {
    expect(moneyApp.MainCtrl).not.to.equal(null);
  });
<commit_msg> 사용하여 angularjs controller 테스트<commit_after>'use strict';

describe('Controller: MainCtrl', function () {

  // load the controller's module
  //beforeEach(module('moneyApp'));
  beforeEach(angular.mock.module('moneyApp'));

  var MainCtrl,
    scope,
    $httpBackend;

  // Initialize the controller and a mock scope
  beforeEach(inject(function (_$httpBackend_, $controller, $rootScope) {
    $httpBackend = _$httpBackend_;
    $httpBackend.expectGET('/api/v1/moneybooks/')
      .respond({"results":{"total_count":1,"page_count":1,"page_size":"10","data":[{"item":"item to delete","amount":1200,"date":"2014-04-24"}]}});
    scope = $rootScope.$new();
    MainCtrl = $controller('MainCtrl', {
      $scope: scope
    });
  }));

  it('should have default parameters', function () {
    expect(scope.moneyBooks.$params.page).toBe(1);
    expect(scope.moneyBooks.$params.count).toBe(10);
  });

  it('should attach a list of data to the scope', inject(function($rootScope, $controller, $httpBackend) {
    scope.init();
    $httpBackend.flush();
    console.log('scope.data....'+JSON.stringify(scope.data));
    expect(scope.data.length).toBe(1);

  }));

  it('should suceed modifying moneybook', inject(function($rootScope, $controller, $httpBackend) {
    var searchID = '1';
    var data = {"id":searchID,"item":"item to modify","amount":1100,"date":"2014-05-07"};

    scope.init();
    $httpBackend.flush();

    $httpBackend.expectPUT('/api/v1/moneybooks/'+searchID, data)
      .respond(200, {"status":"ok"});

    $httpBackend.expectGET('/api/v1/moneybooks/')
      .respond({"results":{"total_count":1,"page_count":1,"page_size":"10","data":[{"item":"item to delete","amount":1200,"date":"2014-04-24"}]}});

    scope.update(data);
    $httpBackend.flush();
  }));

/*
  it('should have a MainCtrl controller', function() {
    expect(moneyApp.MainCtrl).not.to.equal(null);
  });
{'fraction_non_alphanumeric': 0.1834177552652626, 'fraction_numerical': 0.016795521194348174, 'mean_word_length': 4.022757697456493, 'pattern_counts': {'":': 21, '<': 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': '7133444', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1185, 'n_words': 219}