UNPKG

@case-contract-testing/case

Version:

Next-generation contract testing suite

18 lines (17 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LookupMatcher = void 0; const context_1 = require("../../entities/context"); const getMatcher = (matcher, matchContext) => { if ('case:matcher:child' in matcher) { matchContext.saveLookupableMatcher(matcher); } return matchContext.lookupMatcher(matcher['case:matcher:uniqueName']); }; const strip = (matcher, matchContext) => matchContext.descendAndStrip(getMatcher(matcher, matchContext), (0, context_1.addLocation)(`:lookup[${matcher['case:matcher:uniqueName']}]`, matchContext)); const check = async (matcher, matchContext, actual) => matchContext.descendAndCheck(getMatcher(matcher, matchContext), (0, context_1.addLocation)(`:lookup[${matcher['case:matcher:uniqueName']}]`, matchContext), actual); exports.LookupMatcher = { describe: (matcher, matchContext) => matchContext.descendAndDescribe(getMatcher(matcher, matchContext), (0, context_1.addLocation)(`:lookup[${matcher['case:matcher:uniqueName']}]`, matchContext)), check, strip, };