Skip to content

Commit 9d2cc83

Browse files
test($http): remove use of deprecated success and error calls in tests
1 parent 38520a1 commit 9d2cc83

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

test/ng/httpSpec.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -933,12 +933,13 @@ describe('$http', function() {
933933
it('should handle empty response header', function() {
934934
$httpBackend.expect('GET', '/url', undefined)
935935
.respond(200, '', { 'Custom-Empty-Response-Header': '', 'Constructor': '' });
936-
$http.get('/url').success(callback);
936+
$http.get('/url').then(callback);
937937
$httpBackend.flush();
938938
expect(callback).toHaveBeenCalledOnce();
939-
expect(callback.mostRecentCall.args[2]('custom-empty-response-Header')).toBe('');
940-
expect(callback.mostRecentCall.args[2]('ToString')).toBe(null);
941-
expect(callback.mostRecentCall.args[2]('Constructor')).toBe('');
939+
var headers = callback.mostRecentCall.args[0].headers;
940+
expect(headers('custom-empty-response-Header')).toEqual('');
941+
expect(headers('ToString')).toBe(null);
942+
expect(headers('Constructor')).toBe('');
942943
});
943944

944945
it('should have delete()', function() {
@@ -1731,12 +1732,12 @@ describe('$http', function() {
17311732

17321733
$httpBackend.expect('GET', '/some').respond(200);
17331734

1734-
$http({method: 'GET', url: '/some', timeout: canceler.promise}).error(
1735-
function(data, status, headers, config) {
1736-
expect(data).toBeUndefined();
1737-
expect(status).toBe(-1);
1738-
expect(headers()).toEqual({});
1739-
expect(config.url).toBe('/some');
1735+
$http({method: 'GET', url: '/some', timeout: canceler.promise}).catch(
1736+
function(response) {
1737+
expect(response.data).toBeUndefined();
1738+
expect(response.status).toBe(-1);
1739+
expect(response.headers()).toEqual({});
1740+
expect(response.config.url).toBe('/some');
17401741
callback();
17411742
});
17421743

0 commit comments

Comments
 (0)