Skip to content

Commit

Permalink
test: fixed SDK tests for metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Dec 29, 2024
1 parent e6223ff commit cb14447
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions tests/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ describe("SDK worker tests", () => {
expect(res.status).toEqual(400);
});
it("Should handle thrown errors", async () => {
jest.unstable_mockModule(githubActionImportPath, () => ({
default: {
context: {
runId: "1",
payload: {
inputs: {},
},
repo: "repo",
sha: "1234",
},
},
}));
const createComment = jest.fn();
server.use(
http.post(
Expand Down Expand Up @@ -187,7 +199,7 @@ describe("SDK worker tests", () => {
issueCommentedEvent.eventPayload,
{ shouldFail: true },
"test",
"main",
"http://localhost:4000",
null
);

Expand All @@ -207,7 +219,7 @@ describe("SDK worker tests", () => {
! test error
\`\`\`
<!-- Ubiquity - undefined - - undefined
<!-- UbiquityOS - @gentlementlegen - http://localhost - handler - 1234
{
"caller": "handler"
}
Expand All @@ -216,10 +228,18 @@ describe("SDK worker tests", () => {
});
});
it("Should accept correct request", async () => {
const inputs = await getWorkerInputs("stateId", issueCommentedEvent.eventName, issueCommentedEvent.eventPayload, { shouldFail: false }, "test", "main", {
name: "test",
parameters: { param1: "test" },
});
const inputs = await getWorkerInputs(
"stateId",
issueCommentedEvent.eventName,
issueCommentedEvent.eventPayload,
{ shouldFail: false },
"test",
"http://localhost:4000",
{
name: "test",
parameters: { param1: "test" },
}
);

const res = await app.request("/", {
headers: {
Expand Down Expand Up @@ -250,12 +270,14 @@ describe("SDK actions tests", () => {
parameters: { param1: "test" },
});
jest.unstable_mockModule(githubActionImportPath, () => ({
default: {},
context: {
runId: "1",
payload: {
inputs: githubInputs,
},
repo: repo,
sha: "1234",
},
}));
const setOutput = jest.fn();
Expand Down Expand Up @@ -308,6 +330,7 @@ describe("SDK actions tests", () => {
const githubInputs = await getWorkflowInputs("stateId", issueCommentedEvent.eventName, issueCommentedEvent.eventPayload, {}, "test_token", "main", null);

jest.unstable_mockModule("@actions/github", () => ({
default: {},
context: {
runId: "1",
payload: {
Expand Down Expand Up @@ -344,6 +367,7 @@ describe("SDK actions tests", () => {
const githubInputs = await getWorkflowInputs("stateId", issueCommentedEvent.eventName, issueCommentedEvent.eventPayload, {}, "test_token", "main", null);

jest.unstable_mockModule(githubActionImportPath, () => ({
default: {},
context: {
runId: "1",
payload: {
Expand Down

0 comments on commit cb14447

Please sign in to comment.