//@ts-nocheck import { testFetch } from "../utils"; import enrichmentFunction from "./index"; import Chance from "chance"; import { MISSING_ADDRESS_ERROR_MESSAGE, MISSING_AVATAR_ERROR_MESSAGE, MISSING_EMAIL_ERROR_MESSAGE } from "../constants"; const enrichment = enrichmentFunction(testFetch); const chance = new Chance(); describe("avatars", () => { it("should fail if no avatarID", async () => { const resp = await enrichment.avatar({}).catch((err) => err); expect(resp.error).toEqual(MISSING_AVATAR_ERROR_MESSAGE); }); it("should succeed", async () => { const id = chance.guid(); const resp = await enrichment.avatar({ avatarID: id }); expect(resp.url).toEqual(`/avatars/${id}`); }); }); describe("lookup", () => { it("should fail if no email", async () => { const resp = await enrichment.lookup({}).catch((err) => err); expect(resp.error).toEqual(MISSING_EMAIL_ERROR_MESSAGE); }); it("should succeed", async () => { const email = chance.email(); const resp = await enrichment.lookup({ email: email }); expect(resp.url).toEqual(`/enrichment/profile?email=${email}`); }); }); describe("list industries", () => { it("should succeed", async () => { const resp = await enrichment.listIndustries(); expect(resp.url).toEqual('/industries'); }); }); describe("lookup address", () => { it("should fail if no search string", async () => { const resp = await enrichment.lookupAddress({}).catch((err) => err); expect(resp.error).toEqual(MISSING_ADDRESS_ERROR_MESSAGE); }); it("should succeed", async () => { const search = chance.address(); const resp = await enrichment.lookupAddress({ search: search }); const params = new URLSearchParams({ search: search}); expect(resp.url).toEqual(`/enrichment/address?${params}`); }); });