Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

1.4 KB
Raw Blame
import { strict as assert } from "node:assert";
import { test } from "vitest";
import { isAiPromptImeCompositionEvent, shouldSubmitAiPromptOnKeydown } from "../../apps/desktop/src/lib/ai/aiPromptKeyboard.ts";

test("submits AI prompt on plain Enter", () => {
  assert.equal(shouldSubmitAiPromptOnKeydown({ key: "Enter" }), true);
});

test("does not submit AI prompt while entering a newline", () => {
  assert.equal(shouldSubmitAiPromptOnKeydown({ key: "Enter", shiftKey: true }), false);
});

test("does not submit AI prompt while IME composition is active", () => {
  assert.equal(shouldSubmitAiPromptOnKeydown({ key: "Enter", isComposing: true }), false);
  assert.equal(shouldSubmitAiPromptOnKeydown({ key: "Enter" }, true), false);
});

test("does not submit AI prompt for IME composition key events", () => {
  assert.equal(shouldSubmitAiPromptOnKeydown({ key: "Enter", keyCode: 229 }), false);
  assert.equal(shouldSubmitAiPromptOnKeydown({ key: "Process" }), false);
});

test("detects AI prompt IME composition key events before mention handling", () => {
  assert.equal(isAiPromptImeCompositionEvent({ key: "Enter", isComposing: true }), true);
  assert.equal(isAiPromptImeCompositionEvent({ key: "Enter", keyCode: 229 }), true);
  assert.equal(isAiPromptImeCompositionEvent({ key: "Process" }), true);
  assert.equal(isAiPromptImeCompositionEvent({ key: "Enter" }), false);
});