predictype
Version:
PredicType is a library of pre-built and tested predicates for TypeScript, covering various data types and operations.
33 lines (32 loc) • 1.69 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const functionNamePattern_js_1 = require("./functionNamePattern.js");
(0, vitest_1.describe)('functionNamePattern', () => {
(0, vitest_1.it)('should return true for matches', () => {
const fn = function fooBar() { };
const pattern = /^foo/;
(0, vitest_1.expect)((0, functionNamePattern_js_1.functionNamePattern)(fn, 'matches', pattern)).toBe(true);
});
(0, vitest_1.it)('should return false for matches if not matching', () => {
const fn = function bar() { };
const pattern = /^foo/;
(0, vitest_1.expect)((0, functionNamePattern_js_1.functionNamePattern)(fn, 'matches', pattern)).toBe(false);
});
(0, vitest_1.it)('should return true for not_matches', () => {
const fn = function bar() { };
const pattern = /^foo/;
(0, vitest_1.expect)((0, functionNamePattern_js_1.functionNamePattern)(fn, 'not_matches', pattern)).toBe(true);
});
(0, vitest_1.it)('should return false for not_matches if matching', () => {
const fn = function fooBar() { };
const pattern = /^foo/;
(0, vitest_1.expect)((0, functionNamePattern_js_1.functionNamePattern)(fn, 'not_matches', pattern)).toBe(false);
});
(0, vitest_1.it)('should throw for unknown operator', () => {
const fn = function fooBar() { };
const pattern = /^foo/;
// @ts-expect-error
(0, vitest_1.expect)(() => (0, functionNamePattern_js_1.functionNamePattern)(fn, 'invalid_operator', pattern)).toThrow('Unknown FunctionNamePattern operation: invalid_operator');
});
});
;