@case-contract-testing/case
Version:
Next-generation contract testing suite
29 lines (28 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.coreShapedLike = exports.coreAndMatcher = exports.coreArrayLengthMatcher = void 0;
const types_1 = require("./types");
const coreArrayLengthMatcher = ({ minLength, maxLength, }) => ({
'case:matcher:type': types_1.ARRAY_LENGTH_MATCHER_TYPE,
'case:matcher:minLength': minLength !== undefined ? minLength : 1,
'case:matcher:maxLength': maxLength !== undefined ? maxLength : types_1.ARRAY_LENGTH_PARAMETER_INFINITE,
});
exports.coreArrayLengthMatcher = coreArrayLengthMatcher;
const coreAndMatcher = (...matchers) => ({
'case:matcher:type': types_1.COMBINE_MATCHERS_TYPE,
'case:matcher:children': [...matchers],
});
exports.coreAndMatcher = coreAndMatcher;
/**
* Everything inside this matcher will be matched on the shape of the data (ie, type alone), unless overriden with other matchers
*
* Use this to switch out of the default `exactlyLike` matching.
*
* @param content - The example object, array, primitive or matcher to match against
*/
const coreShapedLike = (content) => ({
'case:matcher:type': types_1.CASCADING_CONTEXT_MATCHER_TYPE,
'case:matcher:child': content,
'case:context:matchBy': 'type',
});
exports.coreShapedLike = coreShapedLike;