UNPKG

predictype

Version:

PredicType is a library of pre-built and tested predicates for TypeScript, covering various data types and operations.

36 lines (35 loc) 1.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const functionName_js_1 = require("./functionName.js"); (0, vitest_1.describe)('functionName', () => { (0, vitest_1.it)('should return true for equals', () => { const fn = function foo() { }; (0, vitest_1.expect)((0, functionName_js_1.functionName)(fn, 'equals', 'foo')).toBe(true); }); (0, vitest_1.it)('should return true for starts_with', () => { const fn = function barTest() { }; (0, vitest_1.expect)((0, functionName_js_1.functionName)(fn, 'starts_with', 'bar')).toBe(true); }); (0, vitest_1.it)('should return true for ends_with', () => { const fn = function testEnd() { }; (0, vitest_1.expect)((0, functionName_js_1.functionName)(fn, 'ends_with', 'End')).toBe(true); }); (0, vitest_1.it)('should return true for includes', () => { const fn = function mySpecialFunction() { }; (0, vitest_1.expect)((0, functionName_js_1.functionName)(fn, 'includes', 'Special')).toBe(true); }); (0, vitest_1.it)('should return true for excludes', () => { const fn = function myFunction() { }; (0, vitest_1.expect)((0, functionName_js_1.functionName)(fn, 'excludes', 'NotInName')).toBe(true); }); (0, vitest_1.it)('should return false for equals if not equal', () => { const fn = function baz() { }; (0, vitest_1.expect)((0, functionName_js_1.functionName)(fn, 'equals', 'foo')).toBe(false); }); (0, vitest_1.it)('should throw for unknown operator', () => { const fn = function foo() { }; // @ts-expect-error (0, vitest_1.expect)(() => (0, functionName_js_1.functionName)(fn, 'invalid_operator', 'foo')).toThrow('Unknown FunctionName operation: invalid_operator'); }); });