UNPKG

@contract-case/case-core

Version:

Core functionality for the ContractCase contract testing suite

29 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.objectEachKeyMatches = exports.objectEachValueMatches = void 0; const case_entities_internal_1 = require("@contract-case/case-entities-internal"); /** * Matches an object where each value matches the provided matcher. * * @param matcher - The object, array, primitive or matcher to match against * @param example - An example object that passes this matcher */ const objectEachValueMatches = (matcher, example) => ({ '_case:matcher:type': case_entities_internal_1.OBJECT_VALUES_MATCH_TYPE, '_case:matcher:matcher': matcher, ...(example !== undefined ? { '_case:matcher:example': example } : {}), }); exports.objectEachValueMatches = objectEachValueMatches; /** * Matches an object where each key matches the provided matcher. * * @param matcher - The matcher that all keys must pass * @param exampleKey - An example key that passes this matcher */ const objectEachKeyMatches = (matcher, exampleKey) => ({ '_case:matcher:type': case_entities_internal_1.OBJECT_KEYS_MATCH_TYPE, '_case:matcher:matcher': matcher, ...(exampleKey !== undefined ? { '_case:matcher:example': exampleKey } : {}), }); exports.objectEachKeyMatches = objectEachKeyMatches; //# sourceMappingURL=objects.js.map