import { describe, test, expect, Result } from './tests.uts' export function testSet(): Result { return describe("Set", () => { test('size', () => { const set1 = new Set(); const object1 = {}; set1.add(42); set1.add('forty two'); set1.add('forty two'); set1.add(object1); expect(set1.size).toEqual(3); }) test('add', () => { const set1 = new Set(); set1.add(42); set1.add(42); set1.add(13); set1.forEach((item)=>{ expect(set1.has(item)).toEqual(true); }) console.log(set1) let set2 = set1.add(66); console.log(set2) }) test('clear', () => { const set1 = new Set(); set1.add(1); set1.add('foo'); expect(set1.size).toEqual(2); set1.clear(); expect(set1.size).toEqual(0); }) test('delete', () => { const set1 = new Set(); set1.add(10); set1.add(20); set1.delete(10); expect(set1.size).toEqual(1); }) test('has', () => { const set1 = new Set([1, 2, 3, 4, 5]); expect(set1.has(1)).toEqual(true); expect(set1.has(5)).toEqual(true); expect(set1.has(6)).toEqual(false); }) test('forEach', () => { const set1 = new Set(['foo', 'bar']) const logSetElements = (value:any) => { expect(set1.has(value)).toEqual(true); } set1.forEach(logSetElements); }) test("entries", () => { // const mySet = new Set(); // mySet.add("foo"); // mySet.add("bar"); // mySet.add("baz"); // const setIter = mySet.entries(); // expect(setIter.next().value).toEqual(["foo", "foo"]); // expect(setIter.next().value).toEqual(["bar", "bar"]); // expect(setIter.next().value).toEqual(["baz", "baz"]); // expect(setIter.next().done).toEqual(true); }) test("keys", () => { // const mySet = new Set(); // mySet.add("foo"); // mySet.add("bar"); // mySet.add("baz"); // const setIter = mySet.keys(); // expect(setIter.next().value).toEqual("foo"); // expect(setIter.next().value).toEqual("bar"); // expect(setIter.next().value).toEqual("baz"); // expect(setIter.next().done).toEqual(true); }) test("values", () => { // const mySet = new Set(); // mySet.add("foo"); // mySet.add("bar"); // mySet.add("baz"); // const setIter = mySet.values(); // expect(setIter.next().value).toEqual("foo"); // expect(setIter.next().value).toEqual("bar"); // expect(setIter.next().value).toEqual("baz"); // expect(setIter.next().done).toEqual(true); }) }) }