mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
fix(ngMock): respond did not always take a statusText argument
minor fix so that `respond` can take a `statusText` argument even when having status 200 by default Closes #8270
This commit is contained in:
committed by
Pawel Kozlowski
parent
41dc7d5ebd
commit
08cd5c19c7
2
src/ngMock/angular-mocks.js
vendored
2
src/ngMock/angular-mocks.js
vendored
@@ -1142,7 +1142,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
return function() {
|
||||
return angular.isNumber(status)
|
||||
? [status, data, headers, statusText]
|
||||
: [200, status, data];
|
||||
: [200, status, data, headers];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
29
test/ngMock/angular-mocksSpec.js
vendored
29
test/ngMock/angular-mocksSpec.js
vendored
@@ -1059,17 +1059,6 @@ describe('ngMock', function() {
|
||||
expect(callback).toHaveBeenCalledOnceWith(200, 'first', 'header: val', 'OK');
|
||||
});
|
||||
|
||||
it('should take function', function() {
|
||||
hb.expect('GET', '/some').respond(function(m, u, d, h) {
|
||||
return [301, m + u + ';' + d + ';a=' + h.a, {'Connection': 'keep-alive'}, 'Moved Permanently'];
|
||||
});
|
||||
|
||||
hb('GET', '/some', 'data', callback, {a: 'b'});
|
||||
hb.flush();
|
||||
|
||||
expect(callback).toHaveBeenCalledOnceWith(301, 'GET/some;data;a=b', 'Connection: keep-alive', 'Moved Permanently');
|
||||
});
|
||||
|
||||
it('should default status code to 200', function() {
|
||||
callback.andCallFake(function(status, response) {
|
||||
expect(status).toBe(200);
|
||||
@@ -1085,6 +1074,24 @@ describe('ngMock', function() {
|
||||
expect(callback.callCount).toBe(2);
|
||||
});
|
||||
|
||||
it('should default status code to 200 and provide status text', function() {
|
||||
hb.expect('GET', '/url1').respond('first', {'header': 'val'}, 'OK');
|
||||
hb('GET', '/url1', null, callback);
|
||||
hb.flush();
|
||||
|
||||
expect(callback).toHaveBeenCalledOnceWith(200, 'first', 'header: val', 'OK');
|
||||
});
|
||||
|
||||
it('should take function', function() {
|
||||
hb.expect('GET', '/some').respond(function(m, u, d, h) {
|
||||
return [301, m + u + ';' + d + ';a=' + h.a, {'Connection': 'keep-alive'}, 'Moved Permanently'];
|
||||
});
|
||||
|
||||
hb('GET', '/some', 'data', callback, {a: 'b'});
|
||||
hb.flush();
|
||||
|
||||
expect(callback).toHaveBeenCalledOnceWith(301, 'GET/some;data;a=b', 'Connection: keep-alive', 'Moved Permanently');
|
||||
});
|
||||
|
||||
it('should default response headers to ""', function() {
|
||||
hb.expect('GET', '/url1').respond(200, 'first');
|
||||
|
||||
Reference in New Issue
Block a user