@contract-case/case-core
Version:
Core functionality for the ContractCase contract testing suite
28 lines (25 loc) • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNamedVariant = exports.MockExecutors = void 0;
const case_plugin_base_1 = require("@contract-case/case-plugin-base");
exports.MockExecutors = {};
const getNamedVariant = (mockDescriptor, context) => {
const mockType = mockDescriptor['_case:mock:type'];
const interactionImplementation = exports.MockExecutors[mockType];
if (!interactionImplementation) {
context.logger.maintainerDebug('Error: Missing interaction executor function for', mockDescriptor);
const message = `Missing interaction executor function for interaction type '${mockType}'.`;
if (typeof mockType === 'string' && mockType.startsWith('_case')) {
throw new case_plugin_base_1.CaseCoreError(`${message}
As this interaction type is a core type, this is an error in ContractCase.`, context);
}
throw new case_plugin_base_1.CaseCoreError(`${message}
This can indicate an error in ContractCase.
However, as the interaction type is not from a core plugin,
it may also indicate that you need to load the plugin that provides
the interaction type '${mockType}'.`, context);
}
return interactionImplementation.ensureMatchersAreNamed(mockDescriptor, context);
};
exports.getNamedVariant = getNamedVariant;
//# sourceMappingURL=mockExecutors.js.map