diff --git a/packages/server/src/automations/tests/discord.spec.js b/packages/server/src/automations/tests/discord.spec.js deleted file mode 100644 index 84c7e6f46e..0000000000 --- a/packages/server/src/automations/tests/discord.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -const setup = require("./utilities") -const fetch = require("node-fetch") - -jest.mock("node-fetch") - -describe("test the outgoing webhook action", () => { - let inputs - let config = setup.getConfig() - - beforeAll(async () => { - await config.init() - inputs = { - username: "joe_bloggs", - url: "http://www.example.com", - } - }) - - afterAll(setup.afterAll) - - it("should be able to run the action", async () => { - const res = await setup.runStep(setup.actions.discord.stepId, inputs) - expect(res.response.url).toEqual("http://www.example.com") - expect(res.response.method).toEqual("post") - expect(res.success).toEqual(true) - }) -}) diff --git a/packages/server/src/automations/tests/discord.spec.ts b/packages/server/src/automations/tests/discord.spec.ts new file mode 100644 index 0000000000..07eab7205c --- /dev/null +++ b/packages/server/src/automations/tests/discord.spec.ts @@ -0,0 +1,26 @@ +import { getConfig, afterAll as _afterAll, runStep, actions } from "./utilities" +import nock from "nock" + +describe("test the outgoing webhook action", () => { + let config = getConfig() + + beforeAll(async () => { + await config.init() + }) + + afterAll(_afterAll) + + beforeEach(() => { + nock.cleanAll() + }) + + it("should be able to run the action", async () => { + nock("http://www.example.com/").post("/").reply(200, { foo: "bar" }) + const res = await runStep(actions.discord.stepId, { + url: "http://www.example.com", + username: "joe_bloggs", + }) + expect(res.response.foo).toEqual("bar") + expect(res.success).toEqual(true) + }) +})