import { complement, intersection, testSubset } from './sets'; describe('Complement set', () => { it('should return the complement of a set', () => { let universe = [0, 1, 2, 3, 4, 5]; let set = [1, 3, 5]; let complementarySet = complement(universe, set); expect(complementarySet).toEqual([0, 2, 4]); }); }); describe('Intersection between sets', () => { it('should return the intersection between two sets', () => { let setA = [0, 1, 2, 3, 4]; let setB = [3, 4, 5, 6, 7]; let intersectionAB = intersection(setA, setB); expect(intersectionAB).toEqual([3, 4]); }); it("should correctly intersect on 0's", () => { let setA = [0]; let setB = [0]; let intersectionAB = intersection(setA, setB); expect(intersectionAB).toEqual([0]); }); }); describe('Test whether set is a subset of another set or not', () => { it('should return true if one set is a subset of another', () => { let subset = [0, 1, 2]; let superset = [0, 1, 2, 3, 4, 5]; let isSubset = testSubset(subset, superset); expect(isSubset).toBe(true); }); it('should return false if one set is not a subset of another', () => { let subset = [0, 1, 2]; let superset = [1, 2, 3, 4, 5]; let isSubset = testSubset(subset, superset); expect(isSubset).toBe(false); }); });