cypress-maildev
Version:
An easy-to-use cypress bunch of commands to use Maildev API for tests messages reception !
43 lines (42 loc) • 1.33 kB
JavaScript
/* global cy */
Object.defineProperty(exports, "__esModule", { value: true });
var Request = /** @class */ (function () {
function Request(_a) {
var baseUrl = _a.baseUrl;
this.baseUrl = baseUrl || "http://localhost:1080";
this.headers = {
Accept: "application/json",
};
}
Request.prototype.buildOptions = function (method, path) {
return {
method: method,
url: "".concat(this.baseUrl).concat(path),
headers: {
Accept: this.headers.Accept,
},
body: {},
};
};
Request.prototype.request = function (method, path, body) {
var options = this.buildOptions(method, path);
options.body = body || undefined;
return cy.request(options).its("body");
};
Request.prototype.get = function (path) {
return this.request("GET", path);
};
Request.prototype.post = function (path, body) {
return this.request("POST", path, body);
};
Request.prototype.put = function (path, body) {
return this.request("PUT", path, body);
};
Request.prototype.delete = function (path) {
return this.request("DELETE", path);
};
return Request;
}());
exports.default = Request;
module.exports = Request;
;