predictype
Version:
PredicType is a library of pre-built and tested predicates for TypeScript, covering various data types and operations.
47 lines (46 loc) • 2.58 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const setIntersection_js_1 = require("./setIntersection.js");
(0, vitest_1.describe)('setIntersection', () => {
(0, vitest_1.it)('should return true for disjoint sets', () => {
const a = new Set([1, 2]);
const b = new Set([3, 4]);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(a, 'disjoint', b)).toBe(true);
});
(0, vitest_1.it)('should return false for disjoint with intersecting sets', () => {
const a = new Set([1, 2]);
const b = new Set([2, 3]);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(a, 'disjoint', b)).toBe(false);
});
(0, vitest_1.it)('should return true for intersects with common elements', () => {
const a = new Set([1, 2, 3]);
const b = new Set([3, 4, 5]);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(a, 'intersects', b)).toBe(true);
});
(0, vitest_1.it)('should return false for intersects with disjoint sets', () => {
const a = new Set([1, 2]);
const b = new Set([3, 4]);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(a, 'intersects', b)).toBe(false);
});
(0, vitest_1.it)('should handle empty sets', () => {
const empty = new Set();
const nonempty = new Set([1, 2]);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(empty, 'disjoint', nonempty)).toBe(true);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(empty, 'intersects', nonempty)).toBe(false);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(empty, 'disjoint', empty)).toBe(true);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(empty, 'intersects', empty)).toBe(false);
});
(0, vitest_1.it)('should handle identical sets', () => {
const a = new Set([1, 2, 3]);
const b = new Set([1, 2, 3]);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(a, 'intersects', b)).toBe(true);
(0, vitest_1.expect)((0, setIntersection_js_1.setIntersection)(a, 'disjoint', b)).toBe(false);
});
(0, vitest_1.it)('should throw for unknown operation', () => {
const a = new Set([1, 2]);
const b = new Set([2, 3]);
// @ts-expect-error
(0, vitest_1.expect)(() => (0, setIntersection_js_1.setIntersection)(a, 'unknown_operation', b)).toThrow('Unknown SetIntersection operation: unknown_operation');
});
});
;