mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 09:01:45 +08:00
Problem with JsonResponseData interface, removed it.
This commit is contained in:
@@ -384,6 +384,7 @@ requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, {
|
||||
///////////////////////////////////////
|
||||
// IRequestHandler
|
||||
///////////////////////////////////////
|
||||
var expectedData = { key: 'value'};
|
||||
requestHandler.passThrough();
|
||||
requestHandler.passThrough().passThrough();
|
||||
requestHandler.respond((method, url, data, headers) => [404, 'data', { header: 'value' }, 'responseText']);
|
||||
@@ -391,6 +392,7 @@ requestHandler.respond((method, url, data, headers) => [404, 'data', { header: '
|
||||
requestHandler.respond((method, url, data, headers) => { return [404, { key: 'value' }, { header: 'value' }, 'responseText']; });
|
||||
requestHandler.respond('data');
|
||||
requestHandler.respond('data').respond({});
|
||||
requestHandler.respond(expectedData);
|
||||
requestHandler.respond({ key: 'value' });
|
||||
requestHandler.respond({ key: 'value' }, { header: 'value' });
|
||||
requestHandler.respond({ key: 'value' }, { header: 'value' }, 'responseText');
|
||||
|
||||
27
angularjs/angular-mocks.d.ts
vendored
27
angularjs/angular-mocks.d.ts
vendored
@@ -265,15 +265,6 @@ declare module angular {
|
||||
}
|
||||
|
||||
export module mock {
|
||||
// this interface makes it possible to diferentiate between a function parameter (in the first overload for IRequestHandler)
|
||||
// and the data: string | Object parameter in the second overload. Since a function is an object, and the first overload
|
||||
// takes one function param and the second overload takes a data string or Object with the other two parameters being optional,
|
||||
// there was no type difference between respond((a,b,c,d) => {}) and respond({}). Using the JsonResponseData interface
|
||||
// as a type creates a difference in the signatures changing data: string | Object to data: string | JsonResponseData
|
||||
interface JsonResponseData extends Object {
|
||||
[key: string] : any;
|
||||
}
|
||||
|
||||
// returned interface by the the mocked HttpBackendService expect/when methods
|
||||
interface IRequestHandler {
|
||||
|
||||
@@ -284,15 +275,6 @@ declare module angular {
|
||||
*/
|
||||
respond(func: ((method: string, url: string, data: string | Object, headers: Object) => [number, string | Object, Object, string])): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(data: string | JsonResponseData, headers?: Object, responseText?: string): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
@@ -303,6 +285,15 @@ declare module angular {
|
||||
*/
|
||||
respond(status: number, data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
|
||||
|
||||
// Available when ngMockE2E is loaded
|
||||
/**
|
||||
* Any request matching a backend definition or expectation with passThrough handler will be passed through to the real backend (an XHR request will be made to the server.)
|
||||
|
||||
Reference in New Issue
Block a user