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

fix($httpBackend): Add missing expectHEAD() and expectOPTIONS() methods #7320

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
fix($httpBackend): Add missing expectHEAD() method
This was documented but not implemented.

With accompanying unit test to ensure the $httpBackend.expect*()
methods exist.
Dave Smith committed Apr 30, 2014
commit 0a6f19855fc843d22a40aebbe1951153d9826c78
2 changes: 1 addition & 1 deletion src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
@@ -1520,7 +1520,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {


function createShortMethods(prefix) {
angular.forEach(['GET', 'DELETE', 'JSONP'], function(method) {
angular.forEach(['GET', 'DELETE', 'JSONP', 'HEAD'], function(method) {
$httpBackend[prefix + method] = function(url, headers) {
return $httpBackend[prefix](method, url, undefined, headers);
};
8 changes: 8 additions & 0 deletions test/ngMock/angular-mocksSpec.js
Original file line number Diff line number Diff line change
@@ -929,6 +929,14 @@ describe('ngMock', function() {
hb = $httpBackend;
}));

it('should provide "expect" methods for each HTTP verb', function() {
expect(typeof hb.expectGET).toBe("function");
expect(typeof hb.expectPOST).toBe("function");
expect(typeof hb.expectPUT).toBe("function");
expect(typeof hb.expectPATCH).toBe("function");
expect(typeof hb.expectDELETE).toBe("function");
expect(typeof hb.expectHEAD).toBe("function");
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jshint error is here, it doesn't like your indentation. The expect(...) calls should be indented 2 spaces, rather than 4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After checking it out, it looks like the lines don't have a real 0x10 newline character between them, so they all appear on the same line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh facepalm. Fixing now. :(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to xxd, it has the proper 0x0a (a.k.a "\n") char at the end of each line.


it('should respond with first matched definition', function() {
hb.when('GET', '/url1').respond(200, 'content', {});