'use strict';

describe('middlewareAddDatasourceController', function() {
  var rootScope;
  var $scope;
  var $controller;
  var $httpBackend;
  var miqService;

  beforeEach(module('ManageIQ'));

  beforeEach(inject(function(_$httpBackend_, _$rootScope_, _$controller_, _miqService_) {
    miqService = _miqService_;
    rootScope = _$rootScope_;
    $scope = rootScope.$new();
    $httpBackend = _$httpBackend_;

    $controller = _$controller_('mwAddDatasourceController', {
      $scope: $scope,
      miqService: miqService,
    });

    spyOn(rootScope, '$broadcast');
  }));

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

  describe('Test Add Datasource Controller', function() {
    it('should have first wizard step defined ', function() {
      expect($scope.dsModel.step).toBeDefined();
      expect($scope.dsModel.step).toBe('CHOOSE_DS');
    });

    it('should have datasources populated ', function() {
      expect($scope.chooseDsModel.datasources).toBeDefined();
      expect($scope.chooseDsModel.datasources.length).toBeGreaterThan(1);
    });

    it('should submit fire mwAddDatasourceEvent on finishAddDatasource step', function() {
      $scope.finishAddDatasource();

      expect(rootScope.$broadcast).toHaveBeenCalled();
    });
  });
}
);

@@ -529,24 +529,97 @@
 e,%0A    %7D);%0A%0A
+    $scope.dsAddForm = %7B%0A      $setPristine: function (value) %7B%7D%0A    %7D;%0A%0A
     spyOn(ro

Fix JS test missing $scope.dsAddForm.$setPristine