UNPKG

@case-contract-testing/case

Version:

Next-generation contract testing suite

28 lines (27 loc) 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findLookup = exports.addLookup = void 0; const entities_1 = require("../../../../entities"); const rawEquals_1 = require("./rawEquals"); const addLookup = (matcherLookup, lookupType, uniqueName, matcher, context) => { const lookupName = `${lookupType}:${uniqueName}`; context.logger.maintainerDebug(`Saving lookup ${lookupType}:`, matcher); if (matcherLookup[lookupName]) { if (!(0, rawEquals_1.rawEquality)(matcher, matcherLookup[lookupName])) { context.logger.error(`The ${lookupType} with the name '${lookupName}' has more than one definition, and they are not the same`); context.logger.error('New matcher is', matcher); context.logger.error('Existing matcher is', matcherLookup[lookupName]); throw new entities_1.CaseConfigurationError(`The ${lookupType} with the name '${lookupName}' has more than one definition, and they are not the same`); } else { context.logger.maintainerDebug(`The ${lookupType} with the name '${lookupName}' is already stored exactly as given`); } } return { ...matcherLookup, [lookupName]: matcher, }; }; exports.addLookup = addLookup; const findLookup = (matcherLookup, lookupType, uniqueName) => matcherLookup[`${lookupType}:${uniqueName}`]; exports.findLookup = findLookup;