UNPKG

@contract-case/case-core

Version:

Core functionality for the ContractCase contract testing suite

31 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uriEncodedString = exports.httpStatus = void 0; const case_core_plugin_http_dsl_1 = require("@contract-case/case-core-plugin-http-dsl"); /** * Matches http status codes. Matches may be provided as a string, eg '4XX' or '401', or a number. * If an array is provided, any status codes in the array will be matched. * * @param match - the status code to match * @param example - optionally, an example to use during the test. If you do not provide one, case uses a code that passes the matcher. * @returns */ const httpStatus = (match, example) => { if (Array.isArray(match)) { return (0, case_core_plugin_http_dsl_1.httpStatusCodeMatcher)(match.map((r) => `${r}`), example); } return (0, case_core_plugin_http_dsl_1.httpStatusCodeMatcher)(`${match}`, example); }; exports.httpStatus = httpStatus; /** * Convenience matcher to treat the string as a uri encoded string. Useful in `path` segments. * * During matching, the actual value is decoded with `decodeUriComponent()` and passed to the child matcher. * * @param child - Any string matcher or literal string */ const uriEncodedString = (child) => // TODO: Check here that the child matcher will accept a string (0, case_core_plugin_http_dsl_1.coreUrlEncodedString)(child); exports.uriEncodedString = uriEncodedString; //# sourceMappingURL=http.js.map