window.TestServ = function(name) {
  var _this = this;

  if (!!name) {
    inject([name, function(service) {
      _this = service;
    }]);
    return _this;
  }
};

window.TestServ.prototype = {
  addPromise: function(name) {
    var _this = this;
    _this[name] = function() {};
    spyOn(_this, name).and.returnValue({
      then: function(success, fail) {
        _this[name].success = success;
        _this[name].fail = fail;
      }
    });
  },

  addMethod: function(name, returnedValue) {
    this[name] = function() {};

    spyOn(this, name).and.returnValue(
      typeof returnedValue === "function" ? returnedValue() : returnedValue);
  }
}



window.TestElement = function(name) {
  var _this = this;
  inject(function($rootScope, $compile, $timeout, $controller, $templateCache) {
    _this._$scope = $rootScope.$new();
    _this.$originalScope = $rootScope.$new();
    _this.$compile = $compile;
    _this.$timeout = $timeout;
    _this.$controller = $controller;
    _this.$templateCache = $templateCache;
  });
  _this.name = name;
};

window.TestElement.prototype = {
  createDirective: function(html, scope) {
    var elem = angular.element(html);
    this._$scope = angular.extend(this.$originalScope, scope);
    this._el = this.$compile(elem)(this._$scope);
    this._$scope.$digest();

    try {
      this.$timeout.verifyNoPendingTasks();
    } catch (e) {
      this.$timeout.flush();
    }
    return this._el;
  },

  createCtrl: function(name, services) {
    services.$scope = this._$scope;
    this._ctrl = this.$controller(name, services);
    return this._ctrl;
  },

  addTemplate: function(path, ctrlAs) {
    var template;
    template = this.$templateCache.get(path);
    this._el = angular.element(template);

    if (!!ctrlAs) {
      this._$scope[ctrlAs] = this._ctrl;
    }

    this.$compile(this._el)(this._$scope);
    this._$scope.$digest();

    try {
      this.$timeout.verifyNoPendingTasks();
    } catch (e) {
      this.$timeout.flush();
    }

    return this._el;
  },

  get scope() {
    return this._$scope;
  },

  get ctrl() {
    return this._ctrl ? this._ctrl : angular.element(this._el).controller(this.name);
  },

  get dom() {
    return angular.element(this._el);
  },

  destroy: function() {
    this._$scope.$destroy();
    this._el = null;
  },

  clickOn: function(selector) {
    if (this.dom.find(selector)[0]) {
      this.dom.find(selector).click();
    } else {
      $(selector).click();
    }
    this._$scope.$digest();
    return this._getFlushedThenable();
  },

  inputOn: function(selector, value) {
    if (this.dom.find(selector)[0]) {
      this.dom.find(selector).val(value || '').trigger('input').trigger('keydown');
    } else {
      $(selector).val(value || '').trigger('input').trigger('keydown');
    }
    this._$scope.$digest();
    return this._getFlushedThenable();
  },

  _getFlushedThenable: function() {
    try {
      this.$timeout.verifyNoPendingTasks();
    } catch (e) {
      this.$timeout.flush();
    }
    return {
      then: function(fn) {
        fn();
      }
    };
  },
}

@@ -676,36 +676,32 @@
 ment = function(
-name
 ) %7B%0A  var _this 
@@ -1026,29 +1026,8 @@
 %7D);%0A
-  _this.name = name;%0A
 %7D;%0A%0A
@@ -1071,17 +1071,12 @@
 eate
-Directive
+Ctrl
 : fu
@@ -1086,377 +1086,73 @@
 ion(
-html, scope) %7B%0A    var elem = angular.element(html);%0A    this._$scope = angular.extend(this.$originalScope, scope);%0A    this._el = this.$compile(elem)(this._$scope);%0A    this._$scope.$digest();%0A%0A    try %7B%0A      this.$timeout.verifyNoPendingTasks();%0A    %7D catch (e) %7B%0A      this.$timeout.flush();%0A    %7D%0A    return this._el;%0A  %7D,%0A%0A  createCtrl: function(name, services) %7B
+name, services) %7B%0A    if (!services) %7B%0A      services = %7B%7D;%0A    %7D
 %0A   
@@ -1682,24 +1682,381 @@
 ._el;%0A  %7D,%0A%0A
+  createDirective: function(html, scope) %7B%0A    var elem = angular.element(html);%0A    this._$scope = angular.extend(this.$originalScope, scope);%0A    this._el = this.$compile(elem)(this._$scope);%0A    this._$scope.$digest();%0A%0A    try %7B%0A      this.$timeout.verifyNoPendingTasks();%0A    %7D catch (e) %7B%0A      this.$timeout.flush();%0A    %7D%0A    return this._el;%0A  %7D,%0A%0A
   get scope(

fix for creating controller without services