UNPKG

predictype

Version:

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

42 lines (41 loc) 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const bigintRange_js_1 = require("./bigintRange.js"); (0, vitest_1.describe)('bigintRange', () => { (0, vitest_1.it)('should return true for between', () => { const value = BigInt(5); const min = BigInt(1); const max = BigInt(10); (0, vitest_1.expect)((0, bigintRange_js_1.bigintRange)(value, 'between', min, max)).toBe(true); }); (0, vitest_1.it)('should return true for strict_between (exclusive)', () => { const value = BigInt(5); const min = BigInt(1); const max = BigInt(10); (0, vitest_1.expect)((0, bigintRange_js_1.bigintRange)(value, 'strict_between', min, max)).toBe(true); (0, vitest_1.expect)((0, bigintRange_js_1.bigintRange)(BigInt(1), 'strict_between', min, max)).toBe(false); (0, vitest_1.expect)((0, bigintRange_js_1.bigintRange)(BigInt(10), 'strict_between', min, max)).toBe(false); }); (0, vitest_1.it)('should return true for strict_not_between (exclusive)', () => { const value = BigInt(1); const min = BigInt(1); const max = BigInt(10); (0, vitest_1.expect)((0, bigintRange_js_1.bigintRange)(value, 'strict_not_between', min, max)).toBe(true); (0, vitest_1.expect)((0, bigintRange_js_1.bigintRange)(BigInt(10), 'strict_not_between', min, max)).toBe(true); (0, vitest_1.expect)((0, bigintRange_js_1.bigintRange)(BigInt(5), 'strict_not_between', min, max)).toBe(false); }); (0, vitest_1.it)('should return true for not_between', () => { const value = BigInt(15); const min = BigInt(1); const max = BigInt(10); (0, vitest_1.expect)((0, bigintRange_js_1.bigintRange)(value, 'not_between', min, max)).toBe(true); }); (0, vitest_1.it)('should throw for unknown operator', () => { const value = BigInt(5); const min = BigInt(1); const max = BigInt(10); // @ts-expect-error (0, vitest_1.expect)(() => (0, bigintRange_js_1.bigintRange)(value, 'invalid_operator', min, max)).toThrow('Unknown BigIntRange operation: invalid_operator'); }); });