@serenity-js/rest
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,6 +0,16 @@ | ||
<a name="1.0.0"></a> | ||
# 1.0.0 (2017-12-21) | ||
<a name="1.1.0"></a> | ||
# 1.1.0 (2018-01-10) | ||
<a name="1.1.0"></a> | ||
# 1.1.0 (2018-01-10) | ||
### Features | ||
* **interactions:** new "Patch" interaction plus the CallAnApi ability returns axios responses so th ([747580b](https://github.com/jan-molak/serenity-js/commit/747580b)) | ||
<a name="1.0.0"></a> | ||
@@ -7,0 +17,0 @@ # 1.0.0 (2017-12-21) |
@@ -10,3 +10,3 @@ import { Ability, UsesAbilities } from '@serenity-js/core/lib/screenplay'; | ||
/** | ||
* ability to Call and api at a specific baseUrl | ||
* Ability to Call and api at a specified baseUrl | ||
* Timeout is set to 1s and headers Accept application/json and application/xml | ||
@@ -33,4 +33,4 @@ * | ||
/** | ||
* Call the api method get on the url. | ||
* Every response will be resolved and put into the lastResponse. | ||
* Send a GET request to a specified url. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
@@ -41,6 +41,6 @@ * @param {string} url | ||
*/ | ||
get(url: string, config?: AxiosRequestConfig): PromiseLike<void>; | ||
get(url: string, config?: AxiosRequestConfig): PromiseLike<AxiosResponse>; | ||
/** | ||
* Call the api method post on the url. | ||
* Every response will be resolved and put into the lastResponse. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
@@ -52,5 +52,5 @@ * @param {string} url | ||
*/ | ||
post(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<void>; | ||
post(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<AxiosResponse>; | ||
/** | ||
* Call the api method delete on the url. | ||
* Send a DELETE request to a specified url. | ||
* Every response will be resolved and put into the lastResponse. | ||
@@ -62,6 +62,6 @@ * | ||
*/ | ||
delete(url: string, config?: AxiosRequestConfig): PromiseLike<void>; | ||
delete(url: string, config?: AxiosRequestConfig): PromiseLike<AxiosResponse>; | ||
/** | ||
* Call the api method put on the url. | ||
* Every response will be resolved and put into the lastResponse. | ||
* PATCH the resource at a specified url. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
@@ -73,5 +73,15 @@ * @param {string} url | ||
*/ | ||
put(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<void>; | ||
patch(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<AxiosResponse>; | ||
/** | ||
* Send a PUT request to a specified url. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
* @param {string} url | ||
* @param data | ||
* @param {AxiosRequestConfig} config | ||
* @returns {PromiseLike<void>} | ||
*/ | ||
put(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<AxiosResponse>; | ||
getLastResponse(): PromiseLike<AxiosResponse>; | ||
constructor(axiosInstance: AxiosInstance); | ||
} |
@@ -12,3 +12,3 @@ "use strict"; | ||
/** | ||
* ability to Call and api at a specific baseUrl | ||
* Ability to Call and api at a specified baseUrl | ||
* Timeout is set to 1s and headers Accept application/json and application/xml | ||
@@ -46,4 +46,4 @@ * | ||
/** | ||
* Call the api method get on the url. | ||
* Every response will be resolved and put into the lastResponse. | ||
* Send a GET request to a specified url. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
@@ -56,7 +56,7 @@ * @param {string} url | ||
var _this = this; | ||
return this.axiosInstance.get(url, config).then(function (fulfilled) { return Promise.resolve(_this.lastResponse = fulfilled); }, function (rejected) { return Promise.resolve(_this.lastResponse = rejected.response); }); | ||
return this.axiosInstance.get(url, config).then(function (fulfilled) { return _this.lastResponse = fulfilled; }, function (rejected) { return _this.lastResponse = rejected.response; }); | ||
}; | ||
/** | ||
* Call the api method post on the url. | ||
* Every response will be resolved and put into the lastResponse. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
@@ -70,6 +70,6 @@ * @param {string} url | ||
var _this = this; | ||
return this.axiosInstance.post(url, data, config).then(function (fulfilled) { return Promise.resolve(_this.lastResponse = fulfilled); }, function (rejected) { return Promise.resolve(_this.lastResponse = rejected.response); }); | ||
return this.axiosInstance.post(url, data, config).then(function (fulfilled) { return _this.lastResponse = fulfilled; }, function (rejected) { return _this.lastResponse = rejected.response; }); | ||
}; | ||
/** | ||
* Call the api method delete on the url. | ||
* Send a DELETE request to a specified url. | ||
* Every response will be resolved and put into the lastResponse. | ||
@@ -83,7 +83,7 @@ * | ||
var _this = this; | ||
return this.axiosInstance.delete(url, config).then(function (fulfilled) { return Promise.resolve(_this.lastResponse = fulfilled); }, function (rejected) { return Promise.resolve(_this.lastResponse = rejected.response); }); | ||
return this.axiosInstance.delete(url, config).then(function (fulfilled) { return _this.lastResponse = fulfilled; }, function (rejected) { return _this.lastResponse = rejected.response; }); | ||
}; | ||
/** | ||
* Call the api method put on the url. | ||
* Every response will be resolved and put into the lastResponse. | ||
* PATCH the resource at a specified url. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
@@ -95,5 +95,18 @@ * @param {string} url | ||
*/ | ||
CallAnApi.prototype.patch = function (url, data, config) { | ||
var _this = this; | ||
return this.axiosInstance.patch(url, data, config).then(function (fulfilled) { return _this.lastResponse = fulfilled; }, function (rejected) { return _this.lastResponse = rejected.response; }); | ||
}; | ||
/** | ||
* Send a PUT request to a specified url. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
* @param {string} url | ||
* @param data | ||
* @param {AxiosRequestConfig} config | ||
* @returns {PromiseLike<void>} | ||
*/ | ||
CallAnApi.prototype.put = function (url, data, config) { | ||
var _this = this; | ||
return this.axiosInstance.put(url, data, config).then(function (fulfilled) { return Promise.resolve(_this.lastResponse = fulfilled); }, function (rejected) { return Promise.resolve(_this.lastResponse = rejected.response); }); | ||
return this.axiosInstance.put(url, data, config).then(function (fulfilled) { return _this.lastResponse = fulfilled; }, function (rejected) { return _this.lastResponse = rejected.response; }); | ||
}; | ||
@@ -100,0 +113,0 @@ CallAnApi.prototype.getLastResponse = function () { |
@@ -8,3 +8,3 @@ "use strict"; | ||
this.resource = resource; | ||
this.toString = function () { return "{0} execute a DELETE on resource " + _this.resource; }; | ||
this.toString = function () { return "#actor executes a DELETE on resource " + _this.resource; }; | ||
} | ||
@@ -11,0 +11,0 @@ Delete.prototype.performAs = function (actor) { |
@@ -8,3 +8,3 @@ "use strict"; | ||
this.resource = resource; | ||
this.toString = function () { return "{0} execute a GET on resource " + _this.resource; }; | ||
this.toString = function () { return "#actor executes a GET on resource " + _this.resource; }; | ||
} | ||
@@ -11,0 +11,0 @@ Get.prototype.performAs = function (actor) { |
export * from './delete'; | ||
export * from './get'; | ||
export * from './patch'; | ||
export * from './post'; | ||
export * from './put'; |
@@ -8,4 +8,5 @@ "use strict"; | ||
__export(require("./get")); | ||
__export(require("./patch")); | ||
__export(require("./post")); | ||
__export(require("./put")); | ||
//# sourceMappingURL=index.js.map |
@@ -9,3 +9,3 @@ "use strict"; | ||
this.resource = resource; | ||
this.toString = function () { return "{0} execute a POST on resource " + _this.resource + " with item: " + _this.item; }; | ||
this.toString = function () { return "#actor executes a POST on resource " + _this.resource + " with item: " + _this.item; }; | ||
} | ||
@@ -12,0 +12,0 @@ Post.prototype.performAs = function (actor) { |
@@ -9,3 +9,3 @@ "use strict"; | ||
this.resource = resource; | ||
this.toString = function () { return "{0} execute a PUT on resource " + _this.resource + " with item: " + _this.item; }; | ||
this.toString = function () { return "#actor executes a PUT on resource " + _this.resource + " with item: " + _this.item; }; | ||
} | ||
@@ -12,0 +12,0 @@ Put.prototype.performAs = function (actor) { |
{ | ||
"name": "@serenity-js/rest", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Enables Serenity/JS test scenarios to integrate with REST-based HTTP APIs.", | ||
@@ -33,3 +33,3 @@ "author": "Kenny Baas <kenny.baas@baasie.com>, Jan Molak <jan.molak@smartcodeltd.co.uk>", | ||
"@types/axios": "0.14.0", | ||
"nock": "9.1.4" | ||
"axios-mock-adapter": "1.10.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "dependencies": { |
@@ -1,3 +0,3 @@ | ||
import {Ability, UsesAbilities} from '@serenity-js/core/lib/screenplay'; | ||
import axios, {AxiosInstance, AxiosRequestConfig, AxiosResponse} from 'axios'; | ||
import { Ability, UsesAbilities } from '@serenity-js/core/lib/screenplay'; | ||
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
@@ -12,3 +12,3 @@ /** | ||
/** | ||
* ability to Call and api at a specific baseUrl | ||
* Ability to Call and api at a specified baseUrl | ||
* Timeout is set to 1s and headers Accept application/json and application/xml | ||
@@ -23,3 +23,3 @@ * | ||
timeout: 2000, | ||
headers: {Accept: 'application/json,application/xml'}, | ||
headers: { Accept: 'application/json,application/xml' }, | ||
}); | ||
@@ -50,4 +50,4 @@ return new CallAnApi(axiosInstance); | ||
/** | ||
* Call the api method get on the url. | ||
* Every response will be resolved and put into the lastResponse. | ||
* Send a GET request to a specified url. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
@@ -58,6 +58,6 @@ * @param {string} url | ||
*/ | ||
get(url: string, config?: AxiosRequestConfig): PromiseLike<void> { | ||
get(url: string, config?: AxiosRequestConfig): PromiseLike<AxiosResponse> { | ||
return this.axiosInstance.get(url, config).then( | ||
fulfilled => Promise.resolve(this.lastResponse = fulfilled), | ||
rejected => Promise.resolve(this.lastResponse = rejected.response), | ||
fulfilled => this.lastResponse = fulfilled, | ||
rejected => this.lastResponse = rejected.response, | ||
); | ||
@@ -68,3 +68,3 @@ } | ||
* Call the api method post on the url. | ||
* Every response will be resolved and put into the lastResponse. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
@@ -76,6 +76,6 @@ * @param {string} url | ||
*/ | ||
post(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<void> { | ||
post(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<AxiosResponse> { | ||
return this.axiosInstance.post(url, data, config).then( | ||
fulfilled => Promise.resolve(this.lastResponse = fulfilled), | ||
rejected => Promise.resolve(this.lastResponse = rejected.response), | ||
fulfilled => this.lastResponse = fulfilled, | ||
rejected => this.lastResponse = rejected.response, | ||
); | ||
@@ -85,3 +85,3 @@ } | ||
/** | ||
* Call the api method delete on the url. | ||
* Send a DELETE request to a specified url. | ||
* Every response will be resolved and put into the lastResponse. | ||
@@ -93,6 +93,6 @@ * | ||
*/ | ||
delete(url: string, config?: AxiosRequestConfig): PromiseLike<void> { | ||
delete(url: string, config?: AxiosRequestConfig): PromiseLike<AxiosResponse> { | ||
return this.axiosInstance.delete(url, config).then( | ||
fulfilled => Promise.resolve(this.lastResponse = fulfilled), | ||
rejected => Promise.resolve(this.lastResponse = rejected.response), | ||
fulfilled => this.lastResponse = fulfilled, | ||
rejected => this.lastResponse = rejected.response, | ||
); | ||
@@ -102,4 +102,4 @@ } | ||
/** | ||
* Call the api method put on the url. | ||
* Every response will be resolved and put into the lastResponse. | ||
* PATCH the resource at a specified url. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
@@ -111,6 +111,22 @@ * @param {string} url | ||
*/ | ||
put(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<void> { | ||
patch(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<AxiosResponse> { | ||
return this.axiosInstance.patch(url, data, config).then( | ||
fulfilled => this.lastResponse = fulfilled, | ||
rejected => this.lastResponse = rejected.response, | ||
); | ||
} | ||
/** | ||
* Send a PUT request to a specified url. | ||
* Response will be resolved and made available as lastResponse. | ||
* | ||
* @param {string} url | ||
* @param data | ||
* @param {AxiosRequestConfig} config | ||
* @returns {PromiseLike<void>} | ||
*/ | ||
put(url: string, data?: any, config?: AxiosRequestConfig): PromiseLike<AxiosResponse> { | ||
return this.axiosInstance.put(url, data, config).then( | ||
fulfilled => Promise.resolve(this.lastResponse = fulfilled), | ||
rejected => Promise.resolve(this.lastResponse = rejected.response), | ||
fulfilled => this.lastResponse = fulfilled, | ||
rejected => this.lastResponse = rejected.response, | ||
); | ||
@@ -117,0 +133,0 @@ } |
@@ -15,3 +15,3 @@ import {Interaction, UsesAbilities} from '@serenity-js/core/lib/screenplay'; | ||
toString = () => `{0} execute a DELETE on resource ${this.resource}`; | ||
toString = () => `#actor executes a DELETE on resource ${this.resource}`; | ||
} |
@@ -14,3 +14,3 @@ import { Interaction, UsesAbilities } from '@serenity-js/core/lib/screenplay'; | ||
toString = () => `{0} execute a GET on resource ${this.resource}`; | ||
toString = () => `#actor executes a GET on resource ${this.resource}`; | ||
} |
export * from './delete'; | ||
export * from './get'; | ||
export * from './patch'; | ||
export * from './post'; | ||
export * from './put'; |
@@ -15,3 +15,3 @@ import {Interaction, UsesAbilities} from '@serenity-js/core/lib/screenplay'; | ||
toString = () => `{0} execute a POST on resource ${this.resource} with item: ${this.item}`; | ||
toString = () => `#actor executes a POST on resource ${this.resource} with item: ${this.item}`; | ||
} |
@@ -15,3 +15,3 @@ import {Interaction, UsesAbilities} from '@serenity-js/core/lib/screenplay'; | ||
toString = () => `{0} execute a PUT on resource ${this.resource} with item: ${this.item}`; | ||
toString = () => `#actor executes a PUT on resource ${this.resource} with item: ${this.item}`; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42711
53
572