@contract-case/case-core
Version:
Core functionality for the ContractCase contract testing suite
15 lines • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringMatcher = void 0;
const case_plugin_base_1 = require("@contract-case/case-plugin-base");
const testExactMatch_1 = require("./internal/testExactMatch");
const check = (matcher, matchContext, actual) => (0, case_plugin_base_1.combineResults)((0, case_plugin_base_1.errorWhen)(matchContext['_case:context:matchBy'] === 'exact', (0, testExactMatch_1.testExactMatch)(matcher, matchContext, actual)), (0, case_plugin_base_1.errorWhen)(typeof actual !== 'string', (0, case_plugin_base_1.matchingError)(matcher, `'${typeof actual}' is not a string`, actual, matchContext)));
exports.StringMatcher = {
describe: (matcher, matchContext) => matchContext['_case:context:matchBy'] === 'exact'
? `"${matcher['_case:matcher:example']}"`
: '<any string>',
check,
strip: (matcher) => matcher['_case:matcher:example'],
validate: () => Promise.resolve(),
};
//# sourceMappingURL=StringMatcher.js.map