Skip to content

Commit

Permalink
Test log labels
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeharder committed Feb 5, 2025
1 parent 4ac5dc8 commit b8f3f60
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion .github/workflows/test/arm-auto-signoff-preview.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";

Check failure on line 1 in .github/workflows/test/arm-auto-signoff-preview.test.js

View workflow job for this annotation

GitHub Actions / Protected Files

File '.github/workflows/test/arm-auto-signoff-preview.test.js' should only be updated by the Azure SDK team. If intentional, the PR may be merged by the Azure SDK team via bypassing the branch protections.
import { createMockCore } from "../../test/mocks.js";
import { armAutoSignoffPreviewImpl } from "../src/arm-auto-signoff-preview.js";

describe("armAutoSignoffPreviewImpl", () => {
it("rejects if inputs null", async () => {
await expect(armAutoSignoffPreviewImpl({})).rejects.toThrow();
});

it("logs labels", async () => {
const core = createMockCore();

const github = createMockGithub();
github.rest.issues.listLabelsOnIssue.mockResolvedValue({
data: [{ name: "TestLabel1" }, { name: "TestLabel2" }],
});

await expect(
armAutoSignoffPreviewImpl({
owner: "TestOwner",
repo: "TestRepo",
issue_number: 123,
head_sha: "abc123",
github: github,
core: core,
}),
).resolves.toBeUndefined();

expect(core.info).toBeCalledWith('["TestLabel1","TestLabel2"]');
});
});

function createMockGithub() {
return {
rest: {
issues: {
listLabelsOnIssue: vi.fn(),
},
},
};
}

0 comments on commit b8f3f60

Please sign in to comment.