mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 09:10:09 +00:00
Update protractor-http-mock to v0.4.0
This commit is contained in:
@@ -1,212 +1,242 @@
|
||||
/// <reference path="./protractor-http-mock.d.ts" />
|
||||
|
||||
function TestConfig() {
|
||||
function TestConfig() {
|
||||
mock.config = {
|
||||
rootDirectory: 'root',
|
||||
protractorConfig: 'protractor.conf.js'
|
||||
};
|
||||
rootDirectory: "root",
|
||||
protractorConfig: "protractor.conf.js"
|
||||
};
|
||||
}
|
||||
|
||||
function TestCtorOverloads() {
|
||||
let noParam: mock.ProtractorHttpMock = mock();
|
||||
let noParam: mock.ProtractorHttpMock = mock();
|
||||
let emptyArray: mock.ProtractorHttpMock = mock([]);
|
||||
let mockFiles: mock.ProtractorHttpMock = mock(['mock1', 'mock2']);
|
||||
let skipDefaults: mock.ProtractorHttpMock = mock([], true);
|
||||
let mockFiles: mock.ProtractorHttpMock = mock(["mock1", "mock2"]);
|
||||
let skipDefaults: mock.ProtractorHttpMock = mock([], true);
|
||||
|
||||
let del: mock.requests.Delete<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'DELETE'
|
||||
},
|
||||
response: {
|
||||
status: 400,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let put: mock.requests.Put<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'PUT'
|
||||
},
|
||||
response: {
|
||||
status: 400,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let mocks: mock.ProtractorHttpMock = mock([del, put]);
|
||||
let del: mock.requests.Delete<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "DELETE"
|
||||
},
|
||||
response: {
|
||||
status: 400,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let put: mock.requests.Put<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "PUT"
|
||||
},
|
||||
response: {
|
||||
status: 400,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let mocks: mock.ProtractorHttpMock = mock([del, put]);
|
||||
}
|
||||
|
||||
function TestTeardown() {
|
||||
mock.teardown();
|
||||
mock.teardown();
|
||||
}
|
||||
|
||||
function TestRequestsMade() {
|
||||
let values: Array<mock.ReceivedRequest>;
|
||||
mock.requestsMade().then(v => values = v);
|
||||
let values: Array<mock.ReceivedRequest>;
|
||||
mock.requestsMade().then(v => values = v);
|
||||
}
|
||||
|
||||
function TestClearRequests() {
|
||||
let promiseValue: boolean;
|
||||
mock.clearRequests().then(value => {
|
||||
promiseValue = value;
|
||||
});
|
||||
let promiseValue: boolean;
|
||||
mock.clearRequests().then(value => {
|
||||
promiseValue = value;
|
||||
});
|
||||
}
|
||||
|
||||
function TestDynamicAdd() {
|
||||
let put: mock.requests.Put<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "PUT"
|
||||
},
|
||||
response: {
|
||||
status: 400,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let resolved: boolean;
|
||||
mock.add([put]).then(r => resolved = r);
|
||||
}
|
||||
|
||||
function TestDyanmicRemove() {
|
||||
let put: mock.requests.Put<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "PUT"
|
||||
},
|
||||
response: {
|
||||
status: 400,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let resolved: boolean;
|
||||
mock.remove([put]).then(r => resolved = r);
|
||||
}
|
||||
|
||||
function TestGetRequestDefinitions() {
|
||||
let getMinium: mock.requests.Get<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'GET'
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
let getMinium: mock.requests.Get<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "GET"
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
|
||||
let getParams: mock.requests.Get<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'GET',
|
||||
params: {
|
||||
param1: 'param1',
|
||||
param2: 2
|
||||
}
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
let getParams: mock.requests.Get<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "GET",
|
||||
params: {
|
||||
param1: "param1",
|
||||
param2: 2
|
||||
}
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
|
||||
let post: mock.requests.Post<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'POST'
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
let post: mock.requests.Post<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "POST"
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
|
||||
let getQueryString: mock.requests.Get<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'GET',
|
||||
queryString: {
|
||||
query1: 'query1',
|
||||
query2: 2
|
||||
}
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
let getQueryString: mock.requests.Get<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "GET",
|
||||
queryString: {
|
||||
query1: "query1",
|
||||
query2: 2
|
||||
}
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
|
||||
let getHeaders: mock.requests.Get<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
head1: 'head1',
|
||||
head2: 'head2'
|
||||
}
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
let getHeaders: mock.requests.Get<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "GET",
|
||||
headers: {
|
||||
head1: "head1",
|
||||
head2: "head2"
|
||||
}
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function TestPostRequestDefinitions() {
|
||||
let post: mock.requests.Post<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'POST'
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
let post: mock.requests.Post<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "POST"
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
|
||||
let postData: mock.requests.PostData<number, string> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'POST',
|
||||
data: 'data'
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
let postData: mock.requests.PostData<number, string> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "POST",
|
||||
data: "data"
|
||||
},
|
||||
response: {
|
||||
data: 1,
|
||||
status: 500
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function TestHeadRequestDefinitions() {
|
||||
let head: mock.requests.Head<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'HEAD'
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let head: mock.requests.Head<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "HEAD"
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function TestDeleteRequestDefinitions() {
|
||||
let del: mock.requests.Delete<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'DELETE'
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let del: mock.requests.Delete<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "DELETE"
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function TestPutRequestDefinitions() {
|
||||
let put: mock.requests.Put<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'PUT'
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let put: mock.requests.Put<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "PUT"
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function TestPatchRequestDefinitions() {
|
||||
let patch: mock.requests.Patch<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'PATCH'
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let patch: mock.requests.Patch<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "PATCH"
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function TestJsonpRequestDefinitions() {
|
||||
let jsonp: mock.requests.Jsonp<number> = {
|
||||
request: {
|
||||
path: 'path',
|
||||
method: 'JSONP'
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
let jsonp: mock.requests.Jsonp<number> = {
|
||||
request: {
|
||||
path: "path",
|
||||
method: "JSONP"
|
||||
},
|
||||
response: {
|
||||
status: 500,
|
||||
data: 1
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
43
protractor-http-mock/protractor-http-mock.d.ts
vendored
43
protractor-http-mock/protractor-http-mock.d.ts
vendored
@@ -57,6 +57,24 @@ declare namespace mock {
|
||||
*/
|
||||
protractorConfig?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add mock dynamically.
|
||||
* Returns a promise that will be resolved with a true boolean
|
||||
* when mocks have been added.
|
||||
*
|
||||
* @param mocks An array of mock modules to load into the application.
|
||||
*/
|
||||
add<T>(mocks: Array<requests.BaseRequest<T>>): webdriver.promise.Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Remove mock dynamically.
|
||||
* Returns a promise that will be resolved with a true boolean
|
||||
* when mocks have been removed.
|
||||
*
|
||||
* @param mocks An array of mock modules to remove from the application.
|
||||
*/
|
||||
remove<T>(mocks: Array<requests.BaseRequest<T>>): webdriver.promise.Promise<boolean>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,12 +86,17 @@ declare namespace mock {
|
||||
}
|
||||
|
||||
namespace requests {
|
||||
/**
|
||||
* Request methods type
|
||||
*/
|
||||
type Method = "GET" | "POST" | "DELETE" | "PUT" | "HEAD" | "PATCH" | "JSONP";
|
||||
|
||||
/**
|
||||
* Base request mock used for all mocks.
|
||||
*/
|
||||
interface BaseRequest<TResponse> {
|
||||
request: {
|
||||
method: string;
|
||||
method: Method;
|
||||
path: string;
|
||||
};
|
||||
response: {
|
||||
@@ -87,7 +110,7 @@ declare namespace mock {
|
||||
*/
|
||||
interface Get<TResponse> extends BaseRequest<TResponse> {
|
||||
request: {
|
||||
method: string;
|
||||
method: Method;
|
||||
path: string;
|
||||
params?: Object;
|
||||
queryString?: Object;
|
||||
@@ -107,7 +130,7 @@ declare namespace mock {
|
||||
interface PostData<TResponse, TPayload> extends BaseRequest<TResponse> {
|
||||
request: {
|
||||
path: string;
|
||||
method: string;
|
||||
method: Method;
|
||||
data: TPayload;
|
||||
};
|
||||
response: {
|
||||
@@ -122,7 +145,7 @@ declare namespace mock {
|
||||
interface Post<TResponse> extends BaseRequest<TResponse> {
|
||||
request: {
|
||||
path: string;
|
||||
method: string;
|
||||
method: Method;
|
||||
};
|
||||
response: {
|
||||
status: number;
|
||||
@@ -136,7 +159,7 @@ declare namespace mock {
|
||||
interface Head<TResponse> extends BaseRequest<TResponse> {
|
||||
request: {
|
||||
path: string;
|
||||
method: string;
|
||||
method: Method;
|
||||
};
|
||||
response: {
|
||||
status: number;
|
||||
@@ -150,7 +173,7 @@ declare namespace mock {
|
||||
interface Delete<TResponse> extends BaseRequest<TResponse> {
|
||||
request: {
|
||||
path: string;
|
||||
method: string;
|
||||
method: Method;
|
||||
};
|
||||
response: {
|
||||
status: number;
|
||||
@@ -164,7 +187,7 @@ declare namespace mock {
|
||||
interface Put<TResponse> extends BaseRequest<TResponse> {
|
||||
request: {
|
||||
path: string;
|
||||
method: string;
|
||||
method: Method;
|
||||
};
|
||||
response: {
|
||||
status: number;
|
||||
@@ -178,7 +201,7 @@ declare namespace mock {
|
||||
interface Patch<TResponse> extends BaseRequest<TResponse> {
|
||||
request: {
|
||||
path: string;
|
||||
method: string;
|
||||
method: Method;
|
||||
};
|
||||
response: {
|
||||
status: number;
|
||||
@@ -192,7 +215,7 @@ declare namespace mock {
|
||||
interface Jsonp<TResponse> extends BaseRequest<TResponse> {
|
||||
request: {
|
||||
path: string;
|
||||
method: string;
|
||||
method: Method;
|
||||
};
|
||||
response: {
|
||||
status: number;
|
||||
@@ -204,6 +227,6 @@ declare namespace mock {
|
||||
|
||||
declare var mock: mock.ProtractorHttpMock;
|
||||
|
||||
declare module 'protractor-http-mock' {
|
||||
declare module "protractor-http-mock" {
|
||||
export = mock;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user