mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
Add mode support (#333)
* Add mode support * update "as any" with proper "as unknwon as ModeName" casting * Add documentation to README and registry.ts * Add tests for differen event types, integration flows, and error conditions * Clean up some tests * Minor test fix * Minor formatting test + switch from interface to type * correct the order of mkdir call * always configureGitAuth as there's already a fallback to handle null users by using the bot ID * simplify registry setup --------- Co-authored-by: km-anthropic <km-anthropic@users.noreply.github.com>
This commit is contained in:
28
test/modes/registry.test.ts
Normal file
28
test/modes/registry.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { getMode, isValidMode, type ModeName } from "../../src/modes/registry";
|
||||
import { tagMode } from "../../src/modes/tag";
|
||||
|
||||
describe("Mode Registry", () => {
|
||||
test("getMode returns tag mode by default", () => {
|
||||
const mode = getMode("tag");
|
||||
expect(mode).toBe(tagMode);
|
||||
expect(mode.name).toBe("tag");
|
||||
});
|
||||
|
||||
test("getMode throws error for invalid mode", () => {
|
||||
const invalidMode = "invalid" as unknown as ModeName;
|
||||
expect(() => getMode(invalidMode)).toThrow(
|
||||
"Invalid mode 'invalid'. Valid modes are: 'tag'. Please check your workflow configuration.",
|
||||
);
|
||||
});
|
||||
|
||||
test("isValidMode returns true for tag mode", () => {
|
||||
expect(isValidMode("tag")).toBe(true);
|
||||
});
|
||||
|
||||
test("isValidMode returns false for invalid mode", () => {
|
||||
expect(isValidMode("invalid")).toBe(false);
|
||||
expect(isValidMode("review")).toBe(false);
|
||||
expect(isValidMode("freeform")).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user