predictype
Version:
PredicType is a library of pre-built and tested predicates for TypeScript, covering various data types and operations.
40 lines (39 loc) • 2.08 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const functionArity_js_1 = require("./functionArity.js");
(0, vitest_1.describe)('functionArity', () => {
(0, vitest_1.it)('should return true for equals', () => {
const fn = (_a, _b) => { };
(0, vitest_1.expect)((0, functionArity_js_1.functionArity)(fn, 'equals', 2)).toBe(true);
});
(0, vitest_1.it)('should return true for not_equals', () => {
const fn = (_a) => { };
(0, vitest_1.expect)((0, functionArity_js_1.functionArity)(fn, 'not_equals', 2)).toBe(true);
});
(0, vitest_1.it)('should return true for greater_than', () => {
const fn = (_a, _b, _c) => { };
(0, vitest_1.expect)((0, functionArity_js_1.functionArity)(fn, 'greater_than', 2)).toBe(true);
});
(0, vitest_1.it)('should return true for greater_or_equal', () => {
const fn = (_a, _b) => { };
(0, vitest_1.expect)((0, functionArity_js_1.functionArity)(fn, 'greater_or_equal', 2)).toBe(true);
const fn2 = (_a, _b, _c) => { };
(0, vitest_1.expect)((0, functionArity_js_1.functionArity)(fn2, 'greater_or_equal', 2)).toBe(true);
});
(0, vitest_1.it)('should return true for less_than', () => {
const fn = (_a) => { };
(0, vitest_1.expect)((0, functionArity_js_1.functionArity)(fn, 'less_than', 2)).toBe(true);
});
(0, vitest_1.it)('should return true for less_or_equal', () => {
const fn = (_a) => { };
(0, vitest_1.expect)((0, functionArity_js_1.functionArity)(fn, 'less_or_equal', 2)).toBe(true);
const fn2 = (_a, _b) => { };
(0, vitest_1.expect)((0, functionArity_js_1.functionArity)(fn2, 'less_or_equal', 2)).toBe(true);
});
(0, vitest_1.it)('should throw for unknown operator', () => {
const fn = (_a) => { };
// @ts-expect-error
(0, vitest_1.expect)(() => (0, functionArity_js_1.functionArity)(fn, 'invalid_operator', 2)).toThrow('Unknown FunctionArity operation: invalid_operator');
});
});
;