UNPKG

@case-contract-testing/case

Version:

Next-generation contract testing suite

14 lines (13 loc) 868 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StringMatcher = void 0; const results_1 = require("../../../entities/results"); const testExactMatch_1 = require("./internal/testExactMatch"); const check = (matcher, matchContext, actual) => (0, results_1.combineResults)((0, results_1.errorWhen)(matchContext['case:context:matchBy'] === 'exact', (0, testExactMatch_1.testExactMatch)(matcher, matchContext, actual)), (0, results_1.errorWhen)(typeof actual !== 'string', (0, results_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'], };