mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-04-21 03:40:31 +08:00
fix(test): update component tests to match current implementation
- Add JsonEditor mock to McpFormModal tests (component uses CodeMirror instead of Textarea) - Fix assertion for missing command error message - Update ImportExportSection tests for new button behavior and file display format
This commit is contained in:
@@ -79,6 +79,17 @@ vi.mock("@/components/ui/textarea", () => ({
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock("@/components/JsonEditor", () => ({
|
||||
default: ({ value, onChange, placeholder, ...rest }: any) => (
|
||||
<textarea
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
onChange={(event) => onChange?.(event.target.value)}
|
||||
{...rest}
|
||||
/>
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock("@/components/ui/checkbox", () => ({
|
||||
Checkbox: ({ id, checked, onCheckedChange, ...rest }: any) => (
|
||||
<input
|
||||
@@ -256,7 +267,7 @@ describe("McpFormModal", () => {
|
||||
await waitFor(() => expect(toastErrorMock).toHaveBeenCalled());
|
||||
expect(upsertMock).not.toHaveBeenCalled();
|
||||
const [message] = toastErrorMock.mock.calls.at(-1) ?? [];
|
||||
expect(message).toBe("mcp.error.jsonInvalid");
|
||||
expect(message).toBe("mcp.error.commandRequired");
|
||||
});
|
||||
|
||||
it("支持向导生成配置并自动填充 ID", async () => {
|
||||
|
||||
Reference in New Issue
Block a user