@contract-case/case-core
Version:
Core functionality for the ContractCase contract testing suite
62 lines • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.anyNull = exports.anyBoolean = exports.anyString = exports.anyInteger = exports.anyNumber = void 0;
const case_entities_internal_1 = require("@contract-case/case-entities-internal");
const entities_1 = require("../../../entities");
const meta_1 = require("./meta");
/**
* Matches any number.
*
* When in a JSON match context, this will be following [RFC 8259 JSON](https://www.rfc-editor.org/rfc/rfc8259) - ie, not NaN or Infinity
*
* @param example - An example number
*/
const anyNumber = (example = 1.1) => ({
...(0, entities_1.coreNumberMatcher)(example),
'_case:context:matchBy': 'type',
});
exports.anyNumber = anyNumber;
/**
* Matches any integer.
*
* @param example - An example integer
*/
const anyInteger = (example = 1) => (0, meta_1.and)((0, entities_1.coreIntegerMatcher)(example), (0, exports.anyNumber)(example));
exports.anyInteger = anyInteger;
/**
* Matches any string.
*
* @param example - An example string
*/
const anyString = (example = 'someString') => ({
...(0, entities_1.coreStringMatcher)(example),
'_case:context:matchBy': 'type',
});
exports.anyString = anyString;
/**
* Matches any Boolean.
*
* @param example - An example boolean
*/
const anyBoolean = (example = true) => ({
'_case:matcher:type': case_entities_internal_1.BOOLEAN_MATCHER_TYPE,
'_case:matcher:example': example,
'_case:context:matchBy': 'type',
'_case:matcher:resolvesTo': 'boolean',
});
exports.anyBoolean = anyBoolean;
/**
* Matches any null.
*
* You don't actually need this matcher, you can just use the literal `null`
*
* @param example - An example null
*/
const anyNull = (example = null) => ({
'_case:matcher:type': case_entities_internal_1.NULL_MATCHER_TYPE,
'_case:matcher:example': example,
'_case:context:matchBy': 'type',
'_case:matcher:resolvesTo': 'null',
});
exports.anyNull = anyNull;
//# sourceMappingURL=primitives.js.map