Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Update documentation for the mock $httpBackend #3075

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,10 +851,13 @@ angular.mock.dump = function(object) {
}

// testing controller
var $httpBackend;
var $httpBackend,
$http;

beforeEach(inject(function($injector) {
// No configuration necessary; $httpBackend replaces the normal $http backend when the mock library is loaded
$httpBackend = $injector.get('$httpBackend');
$http = $injector.get('$http');

// backend definition common for all tests
$httpBackend.when('GET', '/auth.py').respond({userId: 'userX'}, {'A-Token': 'xxx'});
Expand All @@ -869,6 +872,7 @@ angular.mock.dump = function(object) {

it('should fetch authentication token', function() {
$httpBackend.expectGET('/auth.py');
new MyController({}, $http);
var controller = scope.$new(MyController);
$httpBackend.flush();
});
Expand Down