Files
workavia-drive/tdrive/backend/node/test/unit/pick.test.ts
T
Montassar Ghanmy e0615fa867 📁 Changed TDrive root folder (#16)
📁 Changed TDrive root folder
2023-04-11 10:04:29 +01:00

36 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "@jest/globals";
import * as pickUtils from "../../src/utils/pick";
describe("The pick utils", () => {
describe("The pick function", () => {
it("should return an object wich contains only the defined properties", () => {
class TestClass {
keep: string;
me: string;
skip: string;
}
const keysToKeep = ["keep", "me"] as const;
const object = { keep: "foo", me: "bar", skip: "baz" } as TestClass;
const result = pickUtils.pick(object, ...keysToKeep);
expect(result).toEqual({ keep: "foo", me: "bar" });
expect(result).not.toContain("skip");
});
it("should return an empty object when input is empty", () => {
class TestClass {
keep: string;
me: string;
skip: string;
}
const keysToKeep = [] as const;
const object = { keep: "foo", me: "bar", skip: "baz" } as TestClass;
const result = pickUtils.pick(object, ...keysToKeep);
expect(result).toEqual({});
});
});
});