wiremock-mapper
Advanced tools
Comparing version 0.5.0 to 0.7.0
@@ -9,2 +9,3 @@ import { WireMockMapping } from './wiremock_mapping'; | ||
static getRequests(getRequestOptions?: GetRequestOptions): Promise<RequestsResponse>; | ||
static deleteRequests(deleteRequestOptions?: GetRequestOptions): Promise<void>; | ||
} |
@@ -93,2 +93,9 @@ "use strict"; | ||
}; | ||
WireMockMapper.deleteRequests = function (deleteRequestOptions) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, wiremock_service_1.WireMockService.deleteRequests(deleteRequestOptions)]; | ||
}); | ||
}); | ||
}; | ||
return WireMockMapper; | ||
@@ -95,0 +102,0 @@ }()); |
@@ -496,3 +496,52 @@ "use strict"; | ||
}); | ||
describe('deleteRequests', function () { | ||
it('sends a DELETE request to wiremock', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var promise; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
(0, nock_1.default)('http://localhost:8080', {}).delete('/__admin/requests').reply(200); | ||
promise = wiremock_mapper_1.WireMockMapper.deleteRequests(); | ||
return [4 /*yield*/, expect(promise).resolves.toBeUndefined()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
it('sends a DELETE request with stub id to wiremock', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var stubId, promise; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
stubId = 'abc'; | ||
(0, nock_1.default)('http://localhost:8080', {}) | ||
.delete("/__admin/requests/".concat(stubId)) | ||
.reply(200); | ||
promise = wiremock_mapper_1.WireMockMapper.deleteRequests({ stubId: stubId }); | ||
return [4 /*yield*/, expect(promise).resolves.toBeUndefined()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
it('rejects the promise if there was an error with the request', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var promise; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
(0, nock_1.default)('http://localhost:8080') | ||
.delete('/__admin/requests') | ||
.replyWithError('something went wrong...sorry dude...'); | ||
promise = wiremock_mapper_1.WireMockMapper.deleteRequests(); | ||
return [4 /*yield*/, expect(promise).rejects.toThrow()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
}); | ||
//# sourceMappingURL=wiremock_mapper.spec.js.map |
@@ -7,2 +7,3 @@ import { RequestBuilder } from './builders/request_builder'; | ||
static deleteFromWireMock(mappingId: string): Promise<void>; | ||
static deleteRequests(option?: DeleteRequestOptions): Promise<void>; | ||
static getRequests(option?: GetRequestOptions): Promise<string>; | ||
@@ -19,2 +20,3 @@ static sendToWireMock(requestBuilder: RequestBuilder, responseBuilder: ResponseBuilder, scenarioBuilder: ScenarioBuilder): Promise<string>; | ||
export type GetRequestOptions = undefined | RequestsByStubId; | ||
export type DeleteRequestOptions = undefined | RequestsByStubId; | ||
export {}; |
@@ -117,2 +117,23 @@ "use strict"; | ||
}; | ||
WireMockService.deleteRequests = function (option) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
var request = http.request({ | ||
hostname: configuration_1.Configuration.wireMockHost, | ||
method: 'DELETE', | ||
path: [_this.WIREMOCK_REQUESTS_PATH, option === null || option === void 0 ? void 0 : option.stubId] | ||
.filter(Boolean) | ||
.join('/'), | ||
port: configuration_1.Configuration.wireMockPort | ||
}, WireMockService.responseHandler(function () { | ||
resolve(); | ||
}, reject)); | ||
request.on('error', reject); | ||
request.end(); | ||
})]; | ||
}); | ||
}); | ||
}; | ||
WireMockService.getRequests = function (option) { | ||
@@ -119,0 +140,0 @@ return __awaiter(this, void 0, void 0, function () { |
{ | ||
"name": "wiremock-mapper", | ||
"version": "0.5.0", | ||
"version": "0.7.0", | ||
"description": "DSL for setting up WireMock mappings.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
155753
2070