UNPKG

@aricma/itemids

Version:

Be faster in creating and updating react state, with the ItemIds object.

71 lines (69 loc) 2.36 kB
"use strict"; var _itemIds = require("./itemIds"); describe("ItemIds", () => { test("is a function", () => { expect(typeof _itemIds.ItemIds).toBe("function"); }); test("returns and empty array per default", () => { const itemIds = (0, _itemIds.ItemIds)(); expect(itemIds).toEqual([]); }); test("takes given array and returns it as an instance of ItemIds", () => { const array = [1, 2, 3]; const itemIds = (0, _itemIds.ItemIds)(array); expect(itemIds).toEqual(array); expect(itemIds).toBeInstanceOf(Array); }); test("throws if given array was not of type Array", () => { expect(() => (0, _itemIds.ItemIds)(1)).toThrow(); expect(() => (0, _itemIds.ItemIds)("string")).toThrow(); expect(() => (0, _itemIds.ItemIds)({})).toThrow(); }); test("does not allow duplicates", () => { const array = [1, 2, 2, 3]; const itemIds = (0, _itemIds.ItemIds)(array); expect(itemIds).toEqual([1, 2, 3]); }); describe("identity", () => { test("has the name prop with the value: \"ItemIds\"", () => { expect((0, _itemIds.ItemIds)().name).toBe("ItemIds"); }); }); describe("static methods", () => { test("isItemIds", () => { expect(typeof _itemIds.ItemIds.isItemIds).toBe("function"); }); test("isItemId", () => { expect(typeof _itemIds.ItemIds.isItemId).toBe("function"); }); test("isItemIdList", () => { expect(typeof _itemIds.ItemIds.isItemIdList).toBe("function"); }); test("unify", () => { expect(typeof _itemIds.ItemIds.unify).toBe("function"); }); }); describe("methods", () => { test("set", () => { expect(typeof (0, _itemIds.ItemIds)().set).toBe("function"); }); test("add", () => { expect(typeof (0, _itemIds.ItemIds)().add).toBe("function"); }); test("remove", () => { expect(typeof (0, _itemIds.ItemIds)().remove).toBe("function"); }); test("toggle", () => { expect(typeof (0, _itemIds.ItemIds)().toggle).toBe("function"); }); test("toggleAll", () => { expect(typeof (0, _itemIds.ItemIds)().toggleAll).toBe("function"); }); test("has", () => { expect(typeof (0, _itemIds.ItemIds)().has).toBe("function"); }); test("isEqualTo", () => { expect(typeof (0, _itemIds.ItemIds)().isEqualTo).toBe("function"); }); }); });