This is a controller with a send function:
$scope.submit = function(){ $http.post('/api/project', $scope.project) .success(function(data, status){ $modalInstance.dismiss(true); }) .error(function(data){ console.log(data); }) } }
This is my test.
it('should make a post to /api/project on submit and close the modal on success', function() { scope.submit(); $httpBackend.expectPOST('/api/project').respond(200, 'test'); $httpBackend.flush(); expect(modalInstance.dismiss).toHaveBeenCalledWith(true); });
The error I get is:
Error: Unexpected request: GET views/appBar.html
views / appBar.html is my url template:
.state('project', { url: '/', templateUrl:'views/appBar.html', controller: 'ProjectsCtrl' })
So somehow ui-router does my $ httpBackend item for this instead of my send function. I have the same problem in all my tests using $ httpBackend.
Is there any solution for this?
javascript angularjs angular-ui-router karma-runner angular-ui
Per May 14 '14 at 12:52 2014-05-14 12:52
source share