UNPKG

2.17 kBJavaScriptView Raw
1"use strict";
2/**
3 * -------------------------------------------------------------------------------------------
4 * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
5 * See License in the project root for license information.
6 * -------------------------------------------------------------------------------------------
7 */
8Object.defineProperty(exports, "__esModule", { value: true });
9exports.ChaosHandlerOptions = void 0;
10/**
11 * @module ChaosHandlerOptions
12 */
13var ChaosStrategy_1 = require("./ChaosStrategy");
14/**
15 * Class representing ChaosHandlerOptions
16 * @class
17 * Class
18 * @implements MiddlewareOptions
19 */
20var ChaosHandlerOptions = /** @class */ (function () {
21 /**
22 * @public
23 * @constructor
24 * To create an instance of Testing Handler Options
25 * @param {ChaosStrategy} chaosStrategy - Specifies the startegy used for the Testing Handler -> RAMDOM/MANUAL
26 * @param {string} statusMessage - The Message to be returned in the response
27 * @param {number?} statusCode - The statusCode to be returned in the response
28 * @param {number?} chaosPercentage - The percentage of randomness/chaos in the handler
29 * @param {any?} responseBody - The response body to be returned in the response
30 * @returns An instance of ChaosHandlerOptions
31 */
32 function ChaosHandlerOptions(chaosStrategy, statusMessage, statusCode, chaosPercentage, responseBody, headers) {
33 if (chaosStrategy === void 0) { chaosStrategy = ChaosStrategy_1.ChaosStrategy.RANDOM; }
34 if (statusMessage === void 0) { statusMessage = "Some error Happened"; }
35 this.chaosStrategy = chaosStrategy;
36 this.statusCode = statusCode;
37 this.statusMessage = statusMessage;
38 this.chaosPercentage = chaosPercentage !== undefined ? chaosPercentage : 10;
39 this.responseBody = responseBody;
40 this.headers = headers;
41 if (this.chaosPercentage > 100) {
42 throw new Error("Error Pecentage can not be more than 100");
43 }
44 }
45 return ChaosHandlerOptions;
46}());
47exports.ChaosHandlerOptions = ChaosHandlerOptions;
48//# sourceMappingURL=ChaosHandlerOptions.js.map
\No newline at end of file