@contract-case/case-core-plugin-http-dsl
Version:
ContractCase HTTP plugin CaseExample definition DSL
37 lines • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.coreBasicAuthValue = exports.coreUrlEncodedString = exports.httpResponseMatcher = exports.httpRequestMatcher = exports.httpStatusCodeMatcher = void 0;
const constants_types_1 = require("./constants.types");
const httpStatusCodeMatcher = (codes, example) => ({
'_case:matcher:type': constants_types_1.HTTP_STATUS_CODE_MATCHER_TYPE,
'_case:matcher:rule': codes,
'_case:matcher:resolvesTo': 'HttpStatusCode',
...(example ? { '_case:matcher:example': example } : {}),
});
exports.httpStatusCodeMatcher = httpStatusCodeMatcher;
const httpRequestMatcher = (request) => ({
...request,
'_case:matcher:type': constants_types_1.HTTP_REQUEST_MATCHER_TYPE,
});
exports.httpRequestMatcher = httpRequestMatcher;
const httpResponseMatcher = (response) => ({
...response,
'_case:matcher:type': constants_types_1.HTTP_RESPONSE_MATCHER_TYPE,
});
exports.httpResponseMatcher = httpResponseMatcher;
const coreUrlEncodedString = (child) => ({
'_case:matcher:type': constants_types_1.URL_ENCODED_STRING_TYPE,
'_case:matcher:child': child,
// TODO: The `accepts` concept is unused, we should remove it
'_case:matcher:accepts': 'string',
'_case:matcher:resolvesTo': 'string',
});
exports.coreUrlEncodedString = coreUrlEncodedString;
const coreBasicAuthValue = (username, password) => ({
'_case:matcher:type': constants_types_1.HTTP_BASIC_AUTH_TYPE,
'_case:matcher:username': username,
'_case:matcher:password': password,
'_case:matcher:resolvesTo': 'string',
});
exports.coreBasicAuthValue = coreBasicAuthValue;
//# sourceMappingURL=http.js.map