<commit_before>describe('cloudTenantFormController', function() {
  var $scope, vm, $httpBackend, miqService;

  beforeEach(module('ManageIQ'));

  beforeEach(inject(function(_$httpBackend_, $rootScope, _$controller_, _miqService_) {
    miqService = _miqService_;

    spyOn(miqService, 'miqAjaxButton');
    spyOn(miqService, 'miqFlash');

    $scope = $rootScope.$new();

    var mock_data = { name: 'test', ems_id: 1 };

    $httpBackend = _$httpBackend_;
    $httpBackend.when('GET', '/cloud_tenant/show_list').respond(mock_data);
    
    vm = _$controller_('cloudTenantFormController as vm', {
      $scope: $scope,
      miqService: miqService,
      cloudTenantFormId: 'new',
    });
  }));

  describe('#cancelClicked', function() {
    beforeEach(function() {
      $scope.angularForm = {
        $setPristine: function(value) {},
      };
      
      setTimeout(vm.cancelClicked);
    });

    it('delegates to miqService.miqAjaxButton', function(done) {
      setTimeout(function() {
        var redirectUrl = '/cloud_tenant/create/new?button=cancel';
        expect(miqService.miqAjaxButton).toHaveBeenCalledWith(redirectUrl);
        done();
      });
    });
  });

  describe('#saveClicked', function() {
    beforeEach(function() {
      $scope.angularForm = {
        $setPristine: function(value) {},
      };
      
      setTimeout(vm.saveClicked);
    });

    it('delegates to miqService.miqAjaxButton', function(done) {
      setTimeout(function() {
        var redirectUrl = '/cloud_tenant/create/new?button=add';
        expect(miqService.miqAjaxButton).toHaveBeenCalledWith(redirectUrl, vm.cloudTenantModel, { complete: false });
        done();
      });
    });
  });

  describe('#resetClicked', function() {
    beforeEach(function() {
      $scope.angularForm = {
        $setPristine: function(value) {},
      };
      
      setTimeout(vm.resetClicked);
    });

    it('warns the user with flash', function(done) {
      setTimeout(function() {
        expect(miqService.miqFlash).toHaveBeenCalled();
        done();
      });
    });
  });
});<commit_msg>Cloud tenant - specs - test addClicked instead of saveClicked<commit_after>describe('cloudTenantFormController', function() {
  var $scope, vm, miqService;

  beforeEach(module('ManageIQ'));

  beforeEach(inject(function($rootScope, _$controller_, _miqService_) {
    miqService = _miqService_;

    spyOn(miqService, 'miqAjaxButton');
    spyOn(miqService, 'miqFlash');

    $scope = $rootScope.$new();

    vm = _$controller_('cloudTenantFormController as vm', {
      $scope: $scope,
      miqService: miqService,
      cloudTenantFormId: 'new',
    });
  }));

  describe('#cancelClicked', function() {
    beforeEach(function() {
      $scope.angularForm = {
        $setPristine: function(value) {},
      };
      
      setTimeout(vm.cancelClicked);
    });

    it('delegates to miqService.miqAjaxButton', function(done) {
      setTimeout(function() {
        var redirectUrl = '/cloud_tenant/create/new?button=cancel';
        expect(miqService.miqAjaxButton).toHaveBeenCalledWith(redirectUrl);
        done();
      });
    });
  });

  describe('#addClicked', function() {
    beforeEach(function() {
      $scope.angularForm = {
        $setPristine: function(value) {},
      };
      
      setTimeout(vm.addClicked);
    });

    it('delegates to miqService.miqAjaxButton', function(done) {
      setTimeout(function() {
        var redirectUrl = '/cloud_tenant/create/new?button=add';
        expect(miqService.miqAjaxButton).toHaveBeenCalledWith(redirectUrl, vm.cloudTenantModel, { complete: false });
        done();
      });
    });
  });

  describe('#resetClicked', function() {
    beforeEach(function() {
      $scope.angularForm = {
        $setPristine: function(value) {},
      };
      
      setTimeout(vm.resetClicked);
    });

    it('warns the user with flash', function(done) {
      setTimeout(function() {
        expect(miqService.miqFlash).toHaveBeenCalled();
        done();
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.15255076770678555, 'fraction_numerical': 0.00024764735017335313, 'mean_word_length': 3.0715725806451615, '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': '1566758', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1280, 'n_words': 181}