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