/** * 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 each of our actions to verify that they return expected * results. * * To run just this set of unit tests, run "npm run test -- src/actions.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, { apiKey: "eyJhbGciOiJSUzI1NiJ9.eyJhY2NvdW50X2lkIjoxLCJhY2NvdW50cyI6IiIsImVtYWlsIjoibGFiaWIremRAY2FrZW1haWwuY29tIiwiZXhwIjo0OTAzODYwOTU2LCJpYXQiOjE3NTAyNjA5NTYsImlkIjoxODU0NjQyLCJpc3MiOiJ1cm46Y2FrZW1haWwiLCJsaW5lYWdlIjoiMSIsInNjb3BlcyI6WyJ1c2VyIl0sInR6IjoiQW1lcmljYS9OZXdfWW9yayIsInVzZXJfa2V5IjoiMmEwMGI0MmQzNmMyMjJmZGQ5ZDkwMDIzYzY3NTJhOWQifQ.C8djC1AD6JraVS2UeqJ1FlhMluxk3xbHhfSM6KAwUmcNKzO2yhwBX77RVO_qAysplfoGv_IP4rD1NuwYFgQL7gLjrhq85brG7HqfdeGvi39heW2G5QKnu27FZ0aD8H5iCubdWVqUPWcS9qOE0Nyb5tIvtG8WI_PnWaNyApmPm7_LoGnTu-8OML6A6HkI8cXRBWZFgr5H-QM0EOXO9gcSEAKyuOQJV9d8dsYZcq2R-Y5cFRVIeSeHZRNx8Osn9RHI50k0E5NkEUGQc95rfaZniM9VIKz7yQF3HntLw2La6LkVaknP9Q6cnnaI8OufNGA7rGuYLxptLYiz2THb-7xY5g", }); const expectedItems = [ { id: 1, name: "Widgets", quantity: 20, }, { id: 2, name: "Whatsits", quantity: 100, }, { id: 3, name: "Gadgets", quantity: 5, }, ]; describe("Test Actions", () => { test("Verify raw request works as expected", async () => { const result = await harness.action("rawRequest", { cakemailConnection, url: "/webhook", method: "get", responseType: "json", queryParams: [{ account_id: "1154021" }], }); console.log("im here for the love of game"); console.log(result?.data); expect(result?.data).toStrictEqual([expectedItems[1]]); }); });