UNPKG

predictype

Version:

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

32 lines (31 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const mapEntry_js_1 = require("./mapEntry.js"); (0, vitest_1.describe)('mapEntry', () => { (0, vitest_1.it)('should return true for contains_entry', () => { const m = new Map([[1, 'a']]); const entry = [1, 'a']; (0, vitest_1.expect)((0, mapEntry_js_1.mapEntry)(m, 'contains_entry', entry)).toBe(true); }); (0, vitest_1.it)('should return false for contains_entry with wrong value', () => { const m = new Map([[1, 'a']]); const entry = [1, 'b']; (0, vitest_1.expect)((0, mapEntry_js_1.mapEntry)(m, 'contains_entry', entry)).toBe(false); }); (0, vitest_1.it)('should return true for lacks_entry', () => { const m = new Map([[1, 'a']]); const entry = [2, 'b']; (0, vitest_1.expect)((0, mapEntry_js_1.mapEntry)(m, 'lacks_entry', entry)).toBe(true); }); (0, vitest_1.it)('should return false for lacks_entry with present entry', () => { const m = new Map([[1, 'a']]); const entry = [1, 'a']; (0, vitest_1.expect)((0, mapEntry_js_1.mapEntry)(m, 'lacks_entry', entry)).toBe(false); }); (0, vitest_1.it)('should throw for unknown operation', () => { const m = new Map([[1, 'a']]); // @ts-expect-error (0, vitest_1.expect)(() => (0, mapEntry_js_1.mapEntry)(m, 'unknown', [1, 'a'])).toThrow('Unknown MapEntry operation'); }); });