mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
tests
This commit is contained in:
@@ -29,6 +29,88 @@ describe("parseEnvVarsWithContext", () => {
|
||||
process.env = originalEnv;
|
||||
});
|
||||
|
||||
describe("workflow_dispatch event", () => {
|
||||
beforeEach(() => {
|
||||
process.env = {
|
||||
...BASE_ENV,
|
||||
BASE_BRANCH: "main",
|
||||
};
|
||||
});
|
||||
|
||||
test("should parse workflow_dispatch event correctly", () => {
|
||||
const mockWorkflowDispatchContext = createMockContext({
|
||||
eventName: "workflow_dispatch",
|
||||
payload: {
|
||||
inputs: {
|
||||
task: "Run automated task",
|
||||
},
|
||||
repository: {
|
||||
name: "test-repo",
|
||||
owner: {
|
||||
login: "test-owner",
|
||||
},
|
||||
},
|
||||
sender: {
|
||||
login: "test-user",
|
||||
},
|
||||
workflow: "test.yml",
|
||||
},
|
||||
});
|
||||
|
||||
const result = prepareContext(
|
||||
mockWorkflowDispatchContext,
|
||||
"",
|
||||
"main",
|
||||
undefined,
|
||||
);
|
||||
|
||||
expect(result.repository).toBe("test-owner/test-repo");
|
||||
expect(result.eventData.eventName).toBe("workflow_dispatch");
|
||||
expect(result.eventData.isPR).toBe(false);
|
||||
expect(result.eventData.baseBranch).toBe("main");
|
||||
// triggerUsername is not extracted for workflow_dispatch events
|
||||
expect(result.triggerUsername).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("schedule event", () => {
|
||||
beforeEach(() => {
|
||||
process.env = {
|
||||
...BASE_ENV,
|
||||
BASE_BRANCH: "main",
|
||||
};
|
||||
});
|
||||
|
||||
test("should parse schedule event correctly", () => {
|
||||
const mockScheduleContext = createMockContext({
|
||||
eventName: "schedule",
|
||||
payload: {
|
||||
schedule: "0 0 * * *",
|
||||
repository: {
|
||||
name: "test-repo",
|
||||
owner: {
|
||||
login: "test-owner",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const result = prepareContext(
|
||||
mockScheduleContext,
|
||||
"",
|
||||
"main",
|
||||
undefined,
|
||||
);
|
||||
|
||||
expect(result.repository).toBe("test-owner/test-repo");
|
||||
expect(result.eventData.eventName).toBe("schedule");
|
||||
expect(result.eventData.isPR).toBe(false);
|
||||
expect(result.eventData.baseBranch).toBe("main");
|
||||
// triggerUsername is not extracted for schedule events
|
||||
expect(result.triggerUsername).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("issue_comment event", () => {
|
||||
describe("on issue", () => {
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user