1
0
Fork 0
mirror of https://github.com/actions/toolkit synced 2025-05-08 16:17:40 +00:00

Start writing tests

This commit is contained in:
Bethany 2023-08-04 13:00:58 -07:00
parent 8a5343d54a
commit 4c6d88f93a
3 changed files with 37 additions and 3 deletions

View file

@ -0,0 +1,34 @@
import * as config from "../src/internal/shared/config"
import { createArtifactTwirpClient } from "../src/internal/shared/artifact-twirp-client"
import * as core from "@actions/core"
jest.mock("@actions/http-client")
describe("artifact-http-client", () => {
beforeAll(() => {
// mock all output so that there is less noise when running tests
jest.spyOn(console, "log").mockImplementation(() => {})
jest.spyOn(core, "debug").mockImplementation(() => {})
jest.spyOn(core, "info").mockImplementation(() => {})
jest.spyOn(core, "warning").mockImplementation(() => {})
})
it("should successfully create a client", () => {
jest.spyOn(config, "getResultsServiceUrl").mockReturnValue("http://localhost:8080")
jest.spyOn(config, "getRuntimeToken").mockReturnValue("token")
const client = createArtifactTwirpClient("upload")
expect(client).toBeDefined()
})
it("should make a request", async () => {
const client = createArtifactTwirpClient("upload")
const artifact = client.CreateArtifact(
{
workflowRunBackendId: "1234",
workflowJobRunBackendId: "5678",
name: "artifact",
version: 4}
)
expect(artifact).toBeDefined()
})
})