import { pluck } from "../../src/array/pluck"; describe("pluck = (Record[], string | string[]) => string[] | string[][]", () => { const objects = [ { foo: 1, bar: 2, baz: 3 }, { foo: 4, bar: 5, qux: 6 }, { foo: 3, bar: 7, baz: false }, ]; it("takes an array and a key and returns array of values ", () => { expect(pluck(objects, "baz")).toEqual([3, null, false]); }); it("takes an array and an array of strings and returns array of subhashes containing the string as key", () => { expect(pluck(objects, ["foo", "baz"])).toEqual([ [1, 3], [4, null], [3, false], ]); }); });