Q: test event that grabs e.currentTarget in Angular using karma I've been trying to get this work for a lot of hours now. I want to test an $scope.function that makes an api call based on target = e.currentTarget and input.val() but I'm in a dead point right now.
The question is, how can I simulate the e.currentTarget to make the test pass?
If this isn't the correct approach, what do you recommend?
I hope that there's a way, really. A lot of the functions I use have that "if e.currentTarget = xxx" behavior.
Here's my controller, which works fine


angular.module('myapp')
    .controller('myctrl', function($scope, $http) {
      var offset = 0;
      //search function
      var generalSearch = function(target) {
        $('.somediv').hide();
        if (target.hasClass('someclass') && $scope.paginationNext == true) {
          dostuff
        }
        if (target.hasClass('someclass') && $scope.paginationPrev == true) {
          dostuff
        }
        var getArtist = function (type='somevalue') {
          var query = $('#somediv').val();e
          var url = "someurl?query=" + query + '&offset='+ offset +'&limit=20&type='+ type;
          if (query !== '' && query !== null) {
            $http.get(url, {cache:true})
              .then(function(res) {
                $scope.somevar = res.data;
                if ($scope.result.length > 0) {
                  $('#somediv').hide();
                  $('.somediv').show(); //shows results
                }else {
                  $('#somediv').show();
                  $('.somep').text('').append("<i class='fa fa-frown-o' aria-hidden='true'></i> We couldn't find any artist nor album with that name");
                  setTimeout(
                    function() {
                      $('.somep').text('Your result will appear here');
                    }, 5000);
                }
                if (res.data.next !== null || res.data.albums.next !== null) {
                  $scope.paginationNext = true;
                }else {
                  $scope.paginationNext = false;
                }
                if (res.data.previous !== null || res.data.albums.previous !== null) {
                  $scope.paginationPrev = true;
                }else {
                  $scope.paginationPrev = false;
                }
            }, function(error) {
              //if the user search more than once, and there's no results, this will show the magnify again
              $('#somediv').show(); 
            });
          }else {
            $('.somep').text('').append("ERROR: We can't find what you want if you don't tell us what it is");
            setTimeout(
              function() {
                $('.somep').text('Your result will appear here');
              }, 5000);
          }     
        }
        getArtist();
      }
      $scope.startSearch = function Search(e) {    
        var target = $(e.currentTarget);
        generalSearch(target);
      }


And here is my test, i thought i could use httpBackend with a template and a trigger to simulate the e.current target, but always got TypeError: Cannot read property 'currentTarget' of undefined


describe('movie app tests', function () {
  var $controller;
  var $httpBackend;
  var $scope;
    var el, $compile, simpleHtml;
    
  beforeEach(module('spotify'));
  beforeEach(inject(function($rootScope, _$controller_, _$httpBackend_, $templateCache, _$compile_) {
    $controller = _$controller_;
    $scope = $rootScope.$new();
    $httpBackend = _$httpBackend_;
    $templateCache.put('./views/search/search.html', [
      '<section class="searcher-container visiond-20" id="searcher">',
      ' <form class="visiond-18 visiond-lg-8">',
      '     <fieldset class="searcher-wrapper">',
      '         <input type="text" id="artist" value="lamb of god">',
      '         <button ng-click="startSearch($event)" type="submit" class="searcher-button visiond-13 visiond-lg-5" id="searchButton">search</button> ',
      '     </fieldset>',
      ' </form>',
      '</section>'
    ].join(''));
    $compile = _$compile_;
  }));
  describe('http tests (original example)', function() {
    it('should load user defined movies on search', function () {
      $controller('ctrlSearch', { $scope: $scope });
        simpleHtml = '<div ng-search id="searcher-container"></div>';
        el = $compile(angular.element(simpleHtml))($scope);
        $scope.$digest();
      var input = el.find('#artist');
      $scope.$apply(function() {
        angular.element(input).val('lamb of god');
      });
      el.find('.searcher-button').click();
      //$scope.startSearch();
      //$httpBackend.flush();
      //expect($scope.movies).toEqual(testData.query.starwars);
    });
  });
});


As you in use two to 3 elements as conditionals, I think I could follow another approach like, test if startSearch is launched and then test the other functions separately...

A: I'm not sure if your "if e.currentTarget = xxx" approach is correct, but I wrote a simple working test for it:
angular.module('spotify', [])
  .controller('SearchController', function($scope) {

    $scope.startSearch = function(e) {
     $scope.currentTarget = e.currentTarget;
    }
  });

describe('SearchController', function() {

  var $scope, $compile;

  beforeEach(module('spotify'));

  beforeEach(inject(function($rootScope, _$compile_) {
    $compile = _$compile_;
    $scope = $rootScope.$new();
  }));

  it('should start search', function() {   
    var html = [
      '<div ng-controller="SearchController">',
      ' <button ng-click="startSearch($event)" class="test-class">search</button>',
      '</div>'].join('');
    var elm = $compile(angular.element(html))($scope);
    var button = elm.find("button");
    $(button).click();

    expect(elm.scope().currentTarget).toBeDefined();
    expect(elm.scope().currentTarget.className).toBe('test-class');
  });
});

Run JSFiddle
It compiles simple controller html with one button and then clicks it. To trigger a click I tried to use something similar to el.find('.searcher-button').click(); from your code, but it resulted in click being undefined error. Using jQuery helped with that.
Take a notice that you need to use elm.scope() instead of $scope in assertions. elm.scope() returns the child scope created during linking of the ngController directive element with $scope. You can learn more about it in $compile docs.
