@case-contract-testing/case
Version:
Next-generation contract testing suite
18 lines (17 loc) • 949 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BooleanMatcher = void 0;
const results_1 = require("../../../entities/results");
const testExactMatch_1 = require("./internal/testExactMatch");
const check = (matcher, matchContext, actual) => (0, results_1.combineResults)(matchContext['case:context:matchBy'] === 'exact'
? (0, testExactMatch_1.testExactMatch)(matcher, matchContext, actual)
: (0, results_1.makeResults)(), typeof actual !== 'boolean'
? (0, results_1.makeResults)((0, results_1.matchingError)(matcher, `${(0, results_1.actualToString)(actual)} is not a boolean`, actual, matchContext))
: (0, results_1.makeResults)());
exports.BooleanMatcher = {
describe: (matcher, matchContext) => matchContext['case:context:matchBy'] === 'exact'
? `${matcher['case:matcher:example']}`
: '<any boolean>',
check,
strip: (matcher) => matcher['case:matcher:example'],
};