/** * Your custom connector can be tested locally prior to publishing it. * In this file, we create a testing harness for our custom connector * and we invoke our data source to verify it returns expected results. * * To run just this set of unit tests, run "npm run test -- src/dataSources.test.ts" * * For more information on unit tests, see * https://prismatic.io/docs/custom-connectors/unit-testing/ */ import { createConnection, createHarness, } from "@prismatic-io/spectral/dist/testing"; import myComponent from "."; import { cakemailApiKey } from "./connections"; const harness = createHarness(myComponent); const cakemailConnection = createConnection(cakemailApiKey, { baseUrl: "https://my-json-server.typicode.com/prismatic-io/placeholder-data", apiKey: "P@s$W0rD", }); describe("Test DataSource", () => { test("Test selectItem dropdown menu datasource", async () => { const { result } = await harness.dataSource("selectItem", { cakemailConnection, }); expect(result).toStrictEqual([ { key: "1", label: "Widgets" }, { key: "2", label: "Whatsits" }, { key: "3", label: "Gadgets" }, ]); }); });