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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
import { describe, expect, it, vi } from "vitest";
import { createUiScaleApplyQueue } from "@/lib/app/uiScaleApplyQueue";
function deferred() {
let resolve: (() => void) | undefined;
return {
promise: new Promise<void>((done) => {
resolve = done;
}),
resolve: () => resolve?.(),
};
}
describe("ui scale apply queue", () => {
it("serializes zoom IPC and only publishes the newest completed target", async () => {
const first = deferred();
const latest = deferred();
const apply = vi.fn((scale: number) => (scale === 0.75 ? first.promise : latest.promise));
const applied = vi.fn();
const queue = createUiScaleApplyQueue(apply, applied, vi.fn());
queue.request(0.75);
queue.request(1.25);
expect(apply).toHaveBeenCalledTimes(1);
expect(apply).toHaveBeenLastCalledWith(0.75);
first.resolve();
await Promise.resolve();
expect(apply).toHaveBeenCalledTimes(2);
expect(apply).toHaveBeenLastCalledWith(1.25);
expect(applied).not.toHaveBeenCalled();
latest.resolve();
await queue.whenIdle();
expect(applied).toHaveBeenCalledTimes(1);
expect(applied).toHaveBeenCalledWith(1.25);
});
});