Fix discorfd.spec.ts's reliance on the node-fetch mock.
This commit is contained in:
parent
6d70dd1924
commit
c8fadc33d9
|
@ -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)
|
|
||||||
})
|
|
||||||
})
|
|
|
@ -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)
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue