mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-28 00:06:50 +00:00
* fix: 修复 Canvas 单元格文本提前截断 * fix: 清理 Dremio 未使用连接 URL 判断 --------- Co-authored-by: staff <staff@qimaos-MacBook-Pro.local>
24 lines
796 B
TypeScript
24 lines
796 B
TypeScript
import { strict as assert } from "node:assert";
|
|
import { test } from "vitest";
|
|
import { fitCanvasText } from "../../apps/desktop/src/lib/canvasDataGridRenderer.ts";
|
|
|
|
function measureContext(charWidth = 1): CanvasRenderingContext2D {
|
|
return {
|
|
font: "13px sans-serif",
|
|
measureText: (text: string) => ({ width: text.length * charWidth }),
|
|
} as CanvasRenderingContext2D;
|
|
}
|
|
|
|
test("fitCanvasText keeps text that fits the available cell width", () => {
|
|
const ctx = measureContext();
|
|
const text = "1234567890abcdefghijklmnopqrst";
|
|
|
|
assert.equal(fitCanvasText(ctx, text, text.length), text);
|
|
});
|
|
|
|
test("fitCanvasText truncates only when text exceeds the available cell width", () => {
|
|
const ctx = measureContext();
|
|
|
|
assert.equal(fitCanvasText(ctx, "1234567890", 8), "12345...");
|
|
});
|