UNPKG

@case-contract-testing/case

Version:

Next-generation contract testing suite

29 lines (28 loc) 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.objectEachKeyMatches = exports.objectEachValueMatches = void 0; const types_1 = require("../../../entities/types"); /** * 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': types_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': types_1.OBJECT_KEYS_MATCH_TYPE, 'case:matcher:matcher': matcher, ...(exampleKey !== undefined ? { 'case:matcher:example': exampleKey } : {}), }); exports.objectEachKeyMatches = objectEachKeyMatches;