predictype
Version:
PredicType is a library of pre-built and tested predicates for TypeScript, covering various data types and operations.
28 lines (27 loc) • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const mapKey_js_1 = require("./mapKey.js");
(0, vitest_1.describe)('mapKey', () => {
(0, vitest_1.it)('should return true for contains_key', () => {
const m = new Map([[1, 'a']]);
(0, vitest_1.expect)((0, mapKey_js_1.mapKey)(m, 'contains_key', 1)).toBe(true);
});
(0, vitest_1.it)('should return false for contains_key with missing key', () => {
const m = new Map([[1, 'a']]);
(0, vitest_1.expect)((0, mapKey_js_1.mapKey)(m, 'contains_key', 2)).toBe(false);
});
(0, vitest_1.it)('should return true for lacks_key', () => {
const m = new Map([[1, 'a']]);
(0, vitest_1.expect)((0, mapKey_js_1.mapKey)(m, 'lacks_key', 2)).toBe(true);
});
(0, vitest_1.it)('should return false for lacks_key with present key', () => {
const m = new Map([[1, 'a']]);
(0, vitest_1.expect)((0, mapKey_js_1.mapKey)(m, 'lacks_key', 1)).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, mapKey_js_1.mapKey)(m, 'unknown', 1)).toThrow('Unknown MapKey operation');
});
});